Page 1 of 1

How do I send oWnd in SET KEY?

PostPosted: Tue Jul 07, 2009 12:24 am
by dutch
Dear All,

How do I send "oWnd" in SET KEY? The problem is oWnd has define after SET KEY.
Code: Select all  Expand view
     SET KEY VK_F6 TO LogOff(oWnd)
      DEFINE ICON oIcon RESOURCE 'EASYFO'

      DEFINE WINDOW oWnd TITLE 'EASYFO Inventory Control V.'+InvVersion+' : '+MEMVAR->CONAME+' - Period : '+cCurMonth+'/'+cCurYear+'  ['+rtrim(us_name)+']'  ;
                         ICON oIcon ;
                         COLOR CLR_BLACK ;
                         MENU BuildMenu(oWnd)

      SET MESSAGE OF oWnd ;
         TO TE("ÅÔ¢ÊÔ·¸Ôìâ´ÂºÃÔÉÑ· ÍÕ«Õèâ¿ ¨Ó¡Ñ´ ","Copyright (C) for EASYFO Co., Ltd. ")+"1998-"+str(year(date()),4) ;
         NOINSET DATE TIME KEYBOARD


      ACTIVATE WINDOW oWnd MAXIMIZED ;
               ON INIT  (MenuSel(Lang,.T.),  GetTopWin()) ;
               VALID    if(lExit,.T., if(MsgYesNo(' Do you want to exit program ? '),.T.,.F.) )
 


Best regards,
Dutch

Re: How do I send oWnd in SET KEY?

PostPosted: Tue Jul 07, 2009 3:10 am
by Willi Quintana
Hi Dutch

DEFINE ICON oIcon RESOURCE 'EASYFO'

DEFINE WINDOW oWnd TITLE 'EASYFO Inventory Control V.'+InvVersion+' : '+MEMVAR->CONAME+' - Period : '+cCurMonth+'/'+cCurYear+' ['+rtrim(us_name)+']' ;
ICON oIcon ;
COLOR CLR_BLACK ;
MENU BuildMenu(oWnd)

SET MESSAGE OF oWnd ;
TO TE("ÅÔ¢ÊÔ·¸Ôìâ´ÂºÃÔÉÑ· ÍÕ«Õèâ¿ ¨Ó¡Ñ´ ","Copyright (C) for EASYFO Co., Ltd. ")+"1998-"+str(year(date()),4) ;
NOINSET DATE TIME KEYBOARD


ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT (MenuSel(Lang,.T.), GetTopWin(),SetKeyOff(oWnd)) ;
VALID if(lExit,.T., if(MsgYesNo(' Do you want to exit program ? '),.T.,.F.) )


Return(Nil)


Function SetKeyOff(oWnd)
SET KEY VK_F6 TO LogOff(oWnd)
Return(Nil)

Re: How do I send oWnd in SET KEY?

PostPosted: Tue Jul 07, 2009 1:21 pm
by dutch
Dear Willi,

Thanks

Regards,
Dutch

Re: How do I send oWnd in SET KEY?

PostPosted: Tue Jul 07, 2009 11:53 pm
by driessen
Dutch,

To my opinion "SET KEY VK_F6 TO LogOff(oWnd)" will never work.

You can't send a parameter to a function using SET KEY.

In that case, I define oWnd as a private variable, so that the function LogOff() knows oWnd without receiving it as a parameter.

Good luck.

Re: How do I send oWnd in SET KEY?

PostPosted: Wed Jul 08, 2009 5:37 am
by James Bott
First I never recommend using privates--they are to prone to cause very hard to find bugs.

You don't need to pass oWnd you can always get it by calling wndMain().

I don't recommend any confirmation dialogs. In your case the user can merely run the program again if they accidentally exited. Users hate confirmation dialogs.

Alt-F4 is the universal hot-key for exiting a program. This works for all Windows programs.

So you can simply do:

...valid logoff()

An then just return .t. from the logoff() function.

James

Re: How do I send oWnd in SET KEY?

PostPosted: Wed Jul 08, 2009 6:43 am
by dutch
Dear All,

My LogOff() is just popup LogIn Screen and I need to hide or minimize the main window and show or maximize it. I try Static or Public are fine.

Thanks for all ideas.

Regards,
Dutch

Re: How do I send oWnd in SET KEY?

PostPosted: Wed Jul 08, 2009 11:29 am
by James Bott
>I try Static or Public are fine.

You don't need a static or public either.

Code: Select all  Expand view
function logoff()
   Local oWnd:= wndMain()
   ...
return .t.


You can get the main window object anywhere in your program.

James