FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How do I send oWnd in SET KEY?
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
How do I send oWnd in SET KEY?
Posted: 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 (fw): Select all Collapse
      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 2304 / 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)
Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM
Re: How do I send oWnd in SET KEY?
Posted: Tue Jul 07, 2009 03: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)

Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I send oWnd in SET KEY?
Posted: Tue Jul 07, 2009 01:21 PM

Dear Willi,

Thanks

Regards,
Dutch

Regards,

Dutch



FWH 2304 / 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)
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: How do I send oWnd in SET KEY?
Posted: 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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: How do I send oWnd in SET KEY?
Posted: Wed Jul 08, 2009 05: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
Re: How do I send oWnd in SET KEY?
Posted: Wed Jul 08, 2009 06: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 2304 / 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)
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: How do I send oWnd in SET KEY?
Posted: Wed Jul 08, 2009 11:29 AM
>I try Static or Public are fine.

You don't need a static or public either.

Code (fw): Select all Collapse
function logoff()
   Local oWnd:= wndMain()
   ...
return .t.


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

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion