How to provide Exit option in Menu class ?

How to provide Exit option in Menu class ?

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

Re: How to provide Exit option in Menu class ?

Postby Enrico Maria Giordano » Sat Nov 19, 2005 10:57 am

Can I see a reduced complete sample of the problem?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

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

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

Postby dutch » Mon Nov 21, 2005 8: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
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests