How to provide Exit option in Menu class ?

Post Reply
Milan Mehta
Posts: 115
Joined: Mon Oct 17, 2005 4:42 am
Location: India

How to provide Exit option in Menu class ?

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

Post 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
Milan Mehta
Posts: 115
Joined: Mon Oct 17, 2005 4:42 am
Location: India

Post 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----------------------------
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Post 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
Post Reply