How to make Slide to Unlock alike iPhone (unlock)?

How to make Slide to Unlock alike iPhone (unlock)?

Postby dutch » Tue Apr 11, 2023 10:46 am

Dear All,

I would like to make slide to unlock the lock screen on touch screen.
How to do it or any example?

Thanks in advance,
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1540
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to make Slide to Unlock alike iPhone (unlock)?

Postby Antonio Linares » Tue Apr 11, 2023 5:35 pm

Dear Dutch,

A first approach:
slide.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oCursor, oBar, oBtn, nMCol

   DEFINE WINDOW oWnd

   DEFINE CURSOR oCursor HAND

   DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007
   oWnd:oTop = nil
   oWnd:oBar = nil
   oBar:nTop = 80
   oBar:nLeft = 50
   oBar:nWidth -= 100

   @ 0, 0 BTNBMP oBtn OF oBar SIZE 60, 60 ACTION MsgInfo( "ok" )

   oBtn:oDragCursor = oCursor
   oBtn:bLClicked = { | nRow, nCol | nMCol := nCol, oBtn:lPressed := .T. }
   oBtn:bMMoved = { | nRow, nCol | If( oBtn:lPressed, If( oBtn:nLeft + nCol - nMCol < 0, oBtn:nLeft := 0, oBtn:nLeft += nCol - nMCol ), ) }
   oBtn:bLButtonUp = { || ReleaseCapture(), If( oBtn:nLeft >= oBar:nWidth - 60, MsgInfo( "Yes" ), MsgInfo( "No" ) ) }

   oBar:Refresh()

   ACTIVATE WINDOW oWnd CENTERED

   oCursor:End()

return nil  
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to make Slide to Unlock alike iPhone (unlock)?

Postby Antonio Linares » Tue Apr 11, 2023 6:15 pm

Enhanced version:

slide.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oCursor, oBar, oBtn, nMCol

   DEFINE WINDOW oWnd

   DEFINE CURSOR oCursor HAND

   DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007
   oWnd:oTop = nil
   oWnd:oBar = nil
   oBar:nTop = 80
   oBar:nLeft = 50
   oBar:nWidth -= 100

   @ 0, 0 BTNBMP oBtn OF oBar SIZE 60, 60 ACTION MsgInfo( "slide ok" )

   oBtn:oDragCursor = oCursor
   oBtn:bLClicked = { | nRow, nCol | nMCol := nCol, oBtn:lPressed := .T. }
   oBtn:bMMoved = { | nRow, nCol | If( oBtn:lPressed,;
                                       ( If( oBtn:nLeft + nCol - nMCol > oBar:nWidth - 60,;
                                         Eval( oBtn:bAction ),), If( oBtn:nLeft + nCol - nMCol < 0,;
                                         ( oBtn:nLeft := 0, oBtn:lPressed := .F. ), oBtn:nLeft += nCol - nMCol ) ) ,) }

   oBar:Refresh()

   ACTIVATE WINDOW oWnd CENTERED

   oCursor:End()

return nil  
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to make Slide to Unlock alike iPhone (unlock)?

Postby Antonio Linares » Tue Apr 11, 2023 7:13 pm

Enhanced version:

slide.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oCursor, oBar, oBtn, nMCol

   DEFINE WINDOW oWnd

   DEFINE CURSOR oCursor HAND

   DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007
   oWnd:oTop = nil
   oWnd:oBar = nil
   oBar:nTop = 80
   oBar:nLeft = 50
   oBar:nWidth -= 100

   @ 0, 0 BTNBMP oBtn OF oBar SIZE 60, 60 ACTION MsgInfo( "slide ok" )

   oBtn:oDragCursor = oCursor
   oBtn:bLClicked = { | nRow, nCol | nMCol := nCol, oBtn:lPressed := .T. }
   oBtn:bMMoved = { | nRow, nCol | If( oBtn:lPressed .and. GetAsyncKey( VK_LBUTTON ),;
                                       ( If( oBtn:nLeft + nCol - nMCol > oBar:nWidth - 60,;
                                         Eval( oBtn:bAction ),), If( oBtn:nLeft + nCol - nMCol < 0,;
                                         ( oBtn:nLeft := 0, oBtn:lPressed := .F. ), oBtn:nLeft += nCol - nMCol ) ) , oBtn:nLeft := 0 ) }
   oBtn:bLButtonUp = { || oBtn:nLeft := 0, oBtn:lPressed := .F. }                                      

   oBar:Refresh()

   ACTIVATE WINDOW oWnd CENTERED

   oCursor:End()

return nil  
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to make Slide to Unlock alike iPhone (unlock)?

Postby dutch » Wed Apr 12, 2023 2:01 am

Dear Antonio,

Thank you so much, It's so nice. I will try.
Antonio Linares wrote:Enhanced version:

slide.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oCursor, oBar, oBtn, nMCol

   DEFINE WINDOW oWnd

   DEFINE CURSOR oCursor HAND

   DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007
   oWnd:oTop = nil
   oWnd:oBar = nil
   oBar:nTop = 80
   oBar:nLeft = 50
   oBar:nWidth -= 100

   @ 0, 0 BTNBMP oBtn OF oBar SIZE 60, 60 ACTION MsgInfo( "slide ok" )

   oBtn:oDragCursor = oCursor
   oBtn:bLClicked = { | nRow, nCol | nMCol := nCol, oBtn:lPressed := .T. }
   oBtn:bMMoved = { | nRow, nCol | If( oBtn:lPressed .and. GetAsyncKey( VK_LBUTTON ),;
                                       ( If( oBtn:nLeft + nCol - nMCol > oBar:nWidth - 60,;
                                         Eval( oBtn:bAction ),), If( oBtn:nLeft + nCol - nMCol < 0,;
                                         ( oBtn:nLeft := 0, oBtn:lPressed := .F. ), oBtn:nLeft += nCol - nMCol ) ) , oBtn:nLeft := 0 ) }
   oBtn:bLButtonUp = { || oBtn:nLeft := 0, oBtn:lPressed := .F. }                                      

   oBar:Refresh()

   ACTIVATE WINDOW oWnd CENTERED

   oCursor:End()

return nil  
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1540
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to make Slide to Unlock alike iPhone (unlock)?

Postby Antonio Linares » Wed Apr 12, 2023 10:32 am

Dear Dutch,

This version is simpler and respect the colors:

The code can be also modified so the slider stays at the right if it was properly slided...

slide.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oBar, oBtn, nMCol

   DEFINE WINDOW oWnd

   DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007
   oWnd:oTop = nil
   oWnd:oBar = nil
   oBar:nTop = 80
   oBar:nLeft = 50
   oBar:nWidth -= 100

   @ 0, 0 BTNBMP oBtn OF oBar SIZE 60, 60 ;
      ACTION If( oBtn:nLeft > oBar:nWidth - 60, MsgInfo( "slide ok" ),)

   oBtn:bMMoved = { | nRow, nCol | If( oBtn:lPressed .and. nMCol == nil, nMCol := nCol, ),;
                                   If( oBtn:lPressed .and. GetAsyncKey( VK_LBUTTON ),;
                                      If( oBtn:nLeft + nCol - nMCol < 0,,;
                                          oBtn:nLeft += nCol - nMCol ),;
                                          ( oBtn:nLeft := 0, nMCol := nil ) ) }
   ACTIVATE WINDOW oWnd CENTERED

return nil  
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to make Slide to Unlock alike iPhone (unlock)?

Postby dutch » Fri Apr 14, 2023 3:32 pm

Dear Antonio,

Does it use with Dialog? I try but it shows an error
Code: Select all  Expand view
Path : D:\V6\EZ4FO\RELEASE\
==========================
Path and name : D:\V6\EZ4FO\Release\EZ4FO6.EXE (32 bits)
Sizes :  10,717,696 bytes
Time from start : 0 hours 0 mins 18 secs
Error occurred at : 14/04/23, 22:29:50
Description : Warning BASE/1004  Message not found: TBAR:DEFCONTROL

Stack Calls
==========================
   Called from : source\rtl\tobject.prg => TBAR:ERROR(0)
   Called from : source\rtl\tobject.prg => TBAR:MSGNOTFOUND(0)
   Called from : source\rtl\tobject.prg => TBAR:DEFCONTROL(0)
   Called from : .\source\classes\BTNBMP.PRG => TBTNBMP:NEW(412)
   Called from : D:\V6\EZ4FO\EZHKM.PRG => LOCKSCR(229)
   Called from : D:\V6\EZ4FO\EZHKM.PRG => (b)HKMOBILE(152)
   Called from : .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(697)
   Called from : .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(983)
   Called from : .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONDOWN(921)
   Called from : .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1788)
   Called from : .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(2006)
   Called from : .\source\classes\WINDOW.PRG => _FWH(3541)

Antonio Linares wrote:Dear Dutch,

This version is simpler and respect the colors:

The code can be also modified so the slider stays at the right if it was properly slided...

slide.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oWnd, oBar, oBtn, nMCol

   DEFINE WINDOW oWnd

   DEFINE BUTTONBAR oBar OF oWnd SIZE 60, 60 2007
   oWnd:oTop = nil
   oWnd:oBar = nil
   oBar:nTop = 80
   oBar:nLeft = 50
   oBar:nWidth -= 100

   @ 0, 0 BTNBMP oBtn OF oBar SIZE 60, 60 ;
      ACTION If( oBtn:nLeft > oBar:nWidth - 60, MsgInfo( "slide ok" ),)

   oBtn:bMMoved = { | nRow, nCol | If( oBtn:lPressed .and. nMCol == nil, nMCol := nCol, ),;
                                   If( oBtn:lPressed .and. GetAsyncKey( VK_LBUTTON ),;
                                      If( oBtn:nLeft + nCol - nMCol < 0,,;
                                          oBtn:nLeft += nCol - nMCol ),;
                                          ( oBtn:nLeft := 0, nMCol := nil ) ) }
   ACTIVATE WINDOW oWnd CENTERED

return nil  
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1540
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How to make Slide to Unlock alike iPhone (unlock)?

Postby Antonio Linares » Fri Apr 14, 2023 7:02 pm

Dear Dutch,

Create the ButtonBar and the button from the ON INIT clause of the ACTIVATE DIALOG ... ON INIT ... call a function where you build it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests