FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bypass window valid statement
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Bypass window valid statement
Posted: Sat Aug 30, 2008 08:21 AM
Friends,

I have a main Window with the following code

nScrHeight:=GetSysMetrics(1)  // Screen Height
nScrWidth :=GetSysMetrics(0)  // Screen Width
DEFINE WINDOW oWnd FROM 1, 1 TO nScrHeight, nScrWidth MDI ;
      TITLE "Accounting Software" ;
      MENU  BuildMenu() ;
      COLOR "B/W" 

ACTIVATE WINDOW oWnd MAXIMIZED ;
	  ON INIT Select_Co();
      VALID MsgYesNo( "Do you want to quit this application ?" )


I am calling a function Select_Co() to display a Login Dialog which asks the user for a valid username and password. The dialog also contains a Login Button and Cancel Button.

Suppose the user press the Cancel button, then I need to end the application without executing the Valid statement in the Man Window.

My Intention is that if the user press cancel button from the Login Dialog, then End the application at that point itself without executing the VALID MsgYesNo( "Do you want to quit this application ?" )

I am asking this question just to know whether we have some commands to force the End.

The other possible work around is to use a variable to hold a logical value to identify whether the user pressed cancel button without a proper Login. And use that variable to decide whether to execute the Valid of oWnd.

For eg:

ACTIVATE WINDOW oWnd MAXIMIZED;
	  ON INIT Select_Co();
      VALID if(mValidLogin,MsgYesNo( "Do you want to quit this application ?" ),.T.)



I just wanted to know whether other alternatives are availabe or not and that I am doing it in the right way or not.

Regards

Anser

Screen Snapshots

Login Screen


Main Window Valid screen
[img=http://img214.imageshack.us/img214/9291/exitconfirmationsf2.th.jpg]

If you notice my Login screen, the size of the text box for user name and password different. I need the text box of both the usname and password to be same.

Right now I have used to say and get. The fields variable size of both usrname and password are different. Is there any way to overcome this display problem faced by me.

My code for the Login Dialog

mUserName:=spac(30)  *--- See the variable size it is 30
mPass:=spac(20)         *--- Size is only 20

DEFINE DIALOG oDlg TITLE "Login"

@01,02 say "Login Name"
@02,02 say "Password"

@01,06 get mUserName picture "@!" valid !empty(mUserName)
@02,06 get mPass picture "@!" valid !empty(mPass)
@03,08 BUTTON oBtn PROMPT "Login" ACTION { ||  mResult:=ValidateLogin(),;
											   if(mResult,oDlg:End(),if(nNoOfTries > 2,oWnd:End(),) ) }  
@03,15 BUTTON "Cancel" ACTION { oDlg:End(),oWnd:End()} CANCEL	

ACTIVATE DIALOG oDlg CENTERED


Right now I am not used with using the resources to design the dialogs and windows. I thought I will try by the coding way and later as I advance in my learning skills I' ll start using the resources and the usage of "redefine".

Regards

Anser[/img]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bypass window valid statement
Posted: Sat Aug 30, 2008 08:40 AM
Here you have a working example. Please notice the use of SIZE in the GETs (can be used for other controls too) and how oWnd:bValid is set to nil:

test.prg
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON INIT Login( oWnd ) ;
      VALID MsgYesNo( "Do you want to end ?" )

return nil

function Login( oWnd )

   local oDlg, mUserName := Space( 30 ), mPass := Space( 20 )

   DEFINE DIALOG oDlg TITLE "Login" 

   @ 01, 02 SAY "Login Name" 
   @ 02, 02 SAY "Password" 

   @ 01.2, 06 GET mUserName PICTURE "@!" VALID ! Empty( mUserName ) SIZE 90, 12 
   @ 02.3, 06 GET mPass PICTURE "@!" VALID ! Empty( mPass ) SIZE 90, 12 

   @ 03, 08 BUTTON oBtn PROMPT "Login" ;
      ACTION ( mResult := .T., If( mResult,oDlg:End(), If( nNoOfTries > 2, ( oWnd:bValid := nil, oWnd:End() ),) ) )  
      
   @ 03, 15 BUTTON "Cancel" ACTION ( oDlg:End(), oWnd:bValid := nil, oWnd:End() ) CANCEL    

   ACTIVATE DIALOG oDlg CENTERED

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Bypass window valid statement
Posted: Sat Aug 30, 2008 09:17 AM

Thankyou Antonio,

You gave me exactly what I needed. By the way I forgot to ask in my post on how to use the mask in get for passwords entries.

Regards

Anser

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bypass window valid statement
Posted: Sat Aug 30, 2008 09:28 AM
@ 02.3, 06 GET mPass PICTURE "@!" VALID ! Empty( mPass ) SIZE 90, 12 PASSWORD
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Bypass window valid statement
Posted: Sat Aug 30, 2008 09:32 AM
Antonio Linares wrote:@ 02.3, 06 GET mPass PICTURE "@!" VALID ! Empty( mPass ) SIZE 90, 12 PASSWORD


Thank you Antonio,

Just now I got it from TestPass.Prg in Samples too

Regards
Anser
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Bypass window valid statement
Posted: Wed Oct 29, 2008 09:58 PM
Antonio,

How can I control ESC and Close button in this example.

Thanks,

Antonio Linares wrote:Here you have a working example. Please notice the use of SIZE in the GETs (can be used for other controls too) and how oWnd:bValid is set to nil:

test.prg
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON INIT Login( oWnd ) ;
      VALID MsgYesNo( "Do you want to end ?" )

return nil

function Login( oWnd )

   local oDlg, mUserName := Space( 30 ), mPass := Space( 20 )

   DEFINE DIALOG oDlg TITLE "Login" 

   @ 01, 02 SAY "Login Name" 
   @ 02, 02 SAY "Password" 

   @ 01.2, 06 GET mUserName PICTURE "@!" VALID ! Empty( mUserName ) SIZE 90, 12 
   @ 02.3, 06 GET mPass PICTURE "@!" VALID ! Empty( mPass ) SIZE 90, 12 

   @ 03, 08 BUTTON oBtn PROMPT "Login" ;
      ACTION ( mResult := .T., If( mResult,oDlg:End(), If( nNoOfTries > 2, ( oWnd:bValid := nil, oWnd:End() ),) ) )  
      
   @ 03, 15 BUTTON "Cancel" ACTION ( oDlg:End(), oWnd:bValid := nil, oWnd:End() ) CANCEL    

   ACTIVATE DIALOG oDlg CENTERED

return nil
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Bypass window valid statement
Posted: Thu Oct 30, 2008 04:52 AM
Hakan,

nStyle :=nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION ) // Removes the ? and x from the dialogue title bar
DEFINE DIALOG oDlg TITLE "Login" style nStyle


Regards

Anser
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Bypass window valid statement
Posted: Thu Oct 30, 2008 06:41 AM
Thanks Anser,

It removed the ? and x from dialog bar, but ESC key still works.

How can i cancel the ESC key?

Thanks again.


anserkk wrote:Hakan,

nStyle :=nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION ) // Removes the ? and x from the dialogue title bar
DEFINE DIALOG oDlg TITLE "Login" style nStyle


Regards

Anser
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
Bypass window valid statement
Posted: Thu Oct 30, 2008 07:55 AM
Hakan,

you may try this:
   ACTIVATE DIALOG oDlg VALID !GETKEYSTATE( VK_ESCAPE )

Regards,
Detlef
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Bypass window valid statement
Posted: Thu Oct 30, 2008 09:58 AM
Full control on ESC and Close:

#include "FiveWin.ch" 

function Main() 

   local oWnd 

   DEFINE WINDOW oWnd 

   ACTIVATE WINDOW oWnd MAXIMIZED ; 
      ON INIT Login( oWnd ) ; 
      VALID MsgYesNo( "Do you want to end ?" ) 

return nil 

function Login( oWnd ) 

   local oDlg, mUserName := Space( 30 ), mPass := Space( 20 ), lOk := .F. 

   DEFINE DIALOG oDlg TITLE "Login" 

   @ 01, 02 SAY "Login Name" 
   @ 02, 02 SAY "Password" 

   @ 01.2, 06 GET mUserName PICTURE "@!" VALID ! Empty( mUserName ) SIZE 90, 12 
   @ 02.3, 06 GET mPass PICTURE "@!" VALID ! Empty( mPass ) SIZE 90, 12 PASSWORD

   @ 03, 08 BUTTON oBtn PROMPT "Login" ; 
      ACTION ( lOk := .T., oDlg:End() )  
      
   @ 03, 15 BUTTON "Cancel" ACTION ( lOk := .F., oDlg:End() ) CANCEL    

   ACTIVATE DIALOG oDlg CENTERED 

   if ! lOk
      oWnd:bValid = nil
      oWnd:End()
   endif   

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Bypass window valid statement
Posted: Thu Oct 30, 2008 12:12 PM

Thanks Deflet, Antonio,

Both solution is worked for me.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06

Continue the discussion