LB Booster
« Clickable top-level menus »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:39am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Clickable top-level menus  (Read 530 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

SarmedNafi
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 93
xx 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
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls