Page 1 of 1

How to provide Exit option in Menu class ?

PostPosted: Sat Nov 19, 2005 10:41 am
by Milan Mehta
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.

Re: How to provide Exit option in Menu class ?

PostPosted: Sat Nov 19, 2005 10:57 am
by Enrico Maria Giordano
Can I see a reduced complete sample of the problem?

EMG

PostPosted: Sun Nov 20, 2005 5:51 pm
by James Bott
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

PostPosted: Mon Nov 21, 2005 5:32 am
by Milan Mehta
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----------------------------

PostPosted: Mon Nov 21, 2005 8:27 am
by dutch
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