How do I send oWnd in SET KEY?

How do I send oWnd in SET KEY?

Postby dutch » Tue Jul 07, 2009 12:24 am

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
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: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I send oWnd in SET KEY?

Postby Willi Quintana » Tue Jul 07, 2009 3:10 am

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)
User avatar
Willi Quintana
 
Posts: 1019
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: How do I send oWnd in SET KEY?

Postby dutch » Tue Jul 07, 2009 1:21 pm

Dear Willi,

Thanks

Regards,
Dutch
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: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I send oWnd in SET KEY?

Postby driessen » Tue Jul 07, 2009 11:53 pm

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.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: How do I send oWnd in SET KEY?

Postby James Bott » Wed Jul 08, 2009 5:37 am

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: How do I send oWnd in SET KEY?

Postby dutch » Wed Jul 08, 2009 6:43 am

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
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: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I send oWnd in SET KEY?

Postby James Bott » Wed Jul 08, 2009 11:29 am

>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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests