FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to provide Exit option in Menu class ?
Posts: 115
Joined: Mon Oct 17, 2005 04:42 AM
How to provide Exit option in Menu class ?
Posted: Sat Nov 19, 2005 10:41 AM

Hello All,

My following code results in the error :

DEFINE WINDOW oWnd FROM 4, 4 TO 25, 75 ;
TITLE "xCalib : Calibration Chart Generation Program" ;
MENU BuildMenu(oWnd) ;
BRUSH oBrush ;
ICON oIcon MDI

in the BuildMenu(oWnd) function

MENUITEM "Exit" ACTION oWnd:End()

What am I doing wrong ?

TIA
Milan.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to provide Exit option in Menu class ?
Posted: Sat Nov 19, 2005 10:57 AM

Can I see a reduced complete sample of the problem?

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
How to provide Exit option in Menu class ?
Posted: Sun Nov 20, 2005 05:51 PM

That should work, the problem must be elsewhere in your code. What was the error message?

Unrelated, but I suggest this:

       MENUITEM "E&xit  Alt+F4" ACTION wndMain():End()

WndMain() returns the main window object. If you use this, then you don't have to pass around the oWnd object.

The ampersand allows the user to use the (standard) X hotkey, and Alt-F4 works to exit all Windows applications (no programming required). When you enter the above line, use the Tab key between "E&xit" and "Alt-F4."

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 115
Joined: Mon Oct 17, 2005 04:42 AM
How to provide Exit option in Menu class ?
Posted: Mon Nov 21, 2005 05:32 AM

Dear James / Enrico,

The following code did solve my problem.
MENUITEM "E&xit Alt+F4" ACTION wndMain():End().

However my code that does not work is as follows :

TIA
Milan.

--------------------------Cut------------------------------

include "FiveWin.ch"

function Main()

local oWnd, oBrush, oBar, oBmp, oIcon

DEFINE ICON oIcon RESOURCE 'Task'

DEFINE BRUSH oBrush STYLE BORLAND // FiveWin new predefined Brushes

DEFINE WINDOW oWnd FROM 4, 4 TO 25, 75 ;
TITLE "Test Menu Program" ;
MENU BuildMenu(oWnd) ;
BRUSH oBrush ;
ICON oIcon MDI

ACTIVATE WINDOW oWnd MAXIMIZED

return nil

function BuildMenu (oWnd)

local oMenu

MENU oMenu

  MENUITEM "&File"
  MENU
    MENUITEM "Exit" ACTION oWnd:End()
 ENDMENU

ENDMENU

return oMenu
--------------------------Paste----------------------------

Posts: 1598
Joined: Fri Oct 07, 2005 05:56 PM
How to provide Exit option in Menu class ?
Posted: Mon Nov 21, 2005 08:27 AM

Try to change oWnd be Static instead of local

Static oWnd

Function Main()

return

function BuildMenu

local oMenu

MENU oMenu

Regards,
Dutch
MENUITEM "&File"
MENU
MENUITEM "Exit" ACTION oWnd:End()
ENDMENU

ENDMENU

return oMenu

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)

Continue the discussion