Bypass window valid statement

Bypass window valid statement

Postby anserkk » Sat Aug 30, 2008 8:21 am

Friends,

I have a main Window with the following code

Code: Select all  Expand view
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:

Code: Select all  Expand view
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
Image

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

Code: Select all  Expand view
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]
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Antonio Linares » Sat Aug 30, 2008 8: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
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby anserkk » Sat Aug 30, 2008 9: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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Antonio Linares » Sat Aug 30, 2008 9:28 am

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

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

Postby anserkk » Sat Aug 30, 2008 9: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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Horizon » Wed Oct 29, 2008 9: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
Code: Select all  Expand view
#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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby anserkk » Thu Oct 30, 2008 4:52 am

Hakan,

Code: Select all  Expand view
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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Horizon » Thu Oct 30, 2008 6: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,

Code: Select all  Expand view
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.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Postby Detlef Hoefner » Thu Oct 30, 2008 7:55 am

Hakan,

you may try this:
Code: Select all  Expand view
   ACTIVATE DIALOG oDlg VALID !GETKEYSTATE( VK_ESCAPE )

Regards,
Detlef
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby Antonio Linares » Thu Oct 30, 2008 9:58 am

Full control on ESC and Close:

Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Horizon » Thu Oct 30, 2008 12:12 pm

Thanks Deflet, Antonio,

Both solution is worked for me.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 79 guests

cron