Re: Win32Lib: PushButton (etc) on MenuBar ??
David,
I tried altering your menu example, & couldn't make an item directly on the
menu bar be able to respond to a "click on it" event; am I doing something
wrong or misunderstanding something? Idea is to be able to click on "Exit"
item that's right on the menu bar & exit right away, without going down
into submenus. Demo below.
Dan Moyer
-- example8x2.exw (AMENDED)
-- This example places a menu in a window
--***********************************************************
-- amended to try make item on menu bar clickable?
-- ADDED: item on menu bar, "Exit"; event handler at end, "onClick[ Exit ]"
-- REMOVED: most except core of demo
--***********************************************************
include win32lib.ew
without warning
constant MenuWin =
create( Window, "Menus (with easy Exit?)", 0, Default, Default, 300,
100, 0 )
constant
FileMenu = create( Menu, "&File", MenuWin, 0, 0, 0, 0, 0 ),
MenuExit = create( MenuItem, "&Exit", FileMenu, 0,0,0,0,0 ),
EditMenu = create( Menu, "&Edit", MenuWin, 0, 0, 0, 0, 0 ),
HelpMenu = create( Menu, "&Help", MenuWin, 0, 0, 0, 0, 0 ),
MenuAbout = create( MenuItem, "&About...\tAlt+A", HelpMenu, 0,0,0,0,0
),
--****************************************************************
-- ADDED THIS TO BE CLICKED ON IN MENU BAR:
Exit = create( Menu, "E&xit", MenuWin, 0, 0, 0, 0, 0 )
--****************************************************************
-- about... behavior
procedure onMenu_MenuAbout()
integer result
result = message_box( "Win32Lib Menu Demo", -- text
"About This Demo", -- title
MB_ICONINFORMATION+MB_TASKMODAL ) -- icon
end procedure
onClick[ MenuAbout ] = routine_id( "onMenu_MenuAbout" )
-- exit behavior
procedure onMenu_MenuExit()
closeWindow( MenuWin )
end procedure
onClick[ MenuExit ] = routine_id( "onMenu_MenuExit" )
--************************************************************
-- ADDED THIS TO PERCEIVE CLICK ON ITEM ON MENU BAR:
onClick[ Exit ] = routine_id( "onMenu_MenuExit" )
--************************************************************
WinMain( MenuWin, Normal )
On Mon, 15 Nov 1999 11:53:52 -0800, David Cuny <dcuny at LANSET.COM> wrote:
>Dan Moyer wrote:
>
>
>> Is there any way to put a PushButton or something
>> into the MenuBar, so a single click on it would be
>> able to do an action instead of going down the
>> menu tree?
>
>You should be able to attach an event to the menu bar with no submenu being
>selected. If not, I need to add it to the code.
>
>-- David Cuny
|
Not Categorized, Please Help
|
|