Author |
Topic: Clickable top-level menus (Read 529 times) |
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Clickable top-level menus
« Thread started on: Feb 19th, 2015, 8:09pm » |
|
Somebody has asked how to create a top-level menu bar that doesn't open drop-down menus (a sort of toolbar substitute). This code works equally well in LB 4.04:
Code: struct mii, cbSize as ulong, fMask as ulong, fType as ulong, _
fState as ulong, wID as ulong, hSubMenu as ulong, _
hbmpChecked as ulong, hbmpUnchecked as ulong, _
dwItemData as long, dwTypeData as ptr, cch as ulong
mii.cbSize.struct = len(mii.struct)
mii.fMask.struct = _MIIM_ID or _MIIM_SUBMENU
menu #w, "Menu 1", "Dummy 1", [menu1]
menu #w, "Menu 2", "Dummy 2", [menu2]
menu #w, "Menu 3", "Dummy 3", [menu3]
menu #w, "Menu 4", "Dummy 4", [menu4]
open "Top-level menu demo" for window as #w
#w "trapclose [quit]"
hw = hwnd(#w)
calldll #user32, "GetMenu", hw as ulong, hMenuBar as ulong
for m = 0 to 3
calldll #user32, "GetSubMenu", hMenuBar as ulong, _
m as ulong, hSubMenu as ulong
calldll #user32, "GetMenuItemID", hSubMenu as ulong, _
0 as long, menuID as ulong
calldll #user32, "RemoveMenu", hSubMenu as ulong,_
menuID as ulong, 0 as long, result as long
mii.wID.struct = menuID
calldll #user32, "SetMenuItemInfoA", hMenuBar as ulong, _
m as long, 1 as long, mii as struct, result as long
next m
wait
[menu1]
print "Menu 1 clicked"
wait
[menu2]
print "Menu 2 clicked"
wait
[menu3]
print "Menu 3 clicked"
wait
[menu4]
print "Menu 4 clicked"
wait
[quit]
close #w
end Richard.
|
|
Logged
|
|
|
|
SarmedNafi
Junior Member
member is offline
Posts: 93
|
|
Re: Clickable top-level menus
« Reply #1 on: Feb 20th, 2015, 01:48am » |
|
What a smartness. What a cleverness.
I never imagine that such marvels text tool bar could be achieved by Liberty Basic or LBB.
It is done by Richard R.
But Richard, Have you noticed the code could be simpler on BBC or even shorter. However thanks a lot for this example, it will not pull my eyes from BBC.
Regards, Sarmed
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Clickable top-level menus
« Reply #2 on: Feb 20th, 2015, 08:35am » |
|
on Feb 20th, 2015, 01:48am, SarmedNafi wrote:Have you noticed the code could be simpler on BBC or even shorter. |
|
Languages differ in their strengths and weaknesses. Sometimes Liberty BASIC code may be longer or more complex than the equivalent in another language, but often it will be shorter and simpler.
So long as the code works, it isn't important how complex it is. If you prefer to keep it 'out of sight' put it in a separate file and 'include it.
Richard.
|
|
Logged
|
|
|
|
|