LB Booster
« Shortcut keys? »

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



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: Shortcut keys?  (Read 765 times)
Pablo
New Member
Image


member is offline

Avatar




PM


Posts: 3
xx Re: Shortcut keys?
« Reply #2 on: Dec 21st, 2016, 11:38pm »

Yes. But I want to right align the "F1" , "Ctrl+S" etc, like in the File menu in http://www.computerhope.com/shortcut.htm

Thanks.

- Pablo
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Shortcut keys?
« Reply #3 on: Dec 22nd, 2016, 08:57am »

on Dec 21st, 2016, 11:38pm, Pablo wrote:
I want to right align the "F1" , "Ctrl+S" etc

It's an annoying feature of Liberty BASIC (which LBB copies) that the text of a menu item must be supplied as a 'constant string', not as a variable. This doesn't work:

Non-working Code:
    menu$ = "Help Topics"+chr$(9)+"F1"
    menu #w, "Help", menu$, [help]
    open "Non-working test" for window as #w
    wait 

What you get as the text of the menu item is 'menu$'!

As a result of this limitation you cannot insert the 'tab' character chr$(9) that is required to right-justify the F1. To allow that LBB would have to be modified either to accept a string variable as the menu text, or to adopt some 'escape convention' to represent a tab character, perhaps \t like C does.

In the absence of such a modification I think you are forced to use the Windows API to modify the text of the menu item, which is messy:

Code:
    nomainwin
    menu #w, "Help", "Help Topics F1", [help]
    open "Menu shortcut" for window as #w
    hw = hwnd(#w)
    calldll #user32, "GetMenu", hw as ulong, hMenuBar as ulong
    calldll #user32, "GetSubMenu", hMenuBar as ulong, 0 as long, hHelpMenu as ulong
    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 ulong, dwTypeData as ptr, cch as ulong
    mii.cbSize.struct = len(mii.struct)
    mii.fMask.struct = _MIIM_TYPE
    mii.fType.struct = _MFT_STRING
    mii.dwTypeData.struct = "Help Topics" + chr$(9) + "F1"
    calldll #user32, "SetMenuItemInfoA", hHelpMenu as ulong, 0 as long, 1 as long, _
        mii as struct, ret as long
    #w "trapclose [quit]"
    timer 10, [testkey]
    wait
    
[quit]
    close #w
    end
    
[testkey]
    calldll #user32, "GetAsyncKeyState", _VK_F1 as long, pressed as short
    if pressed < 0 then goto [help]
    wait
    
[help]
    notice "Help Topics selected"
    wait 

Richard.
« Last Edit: Dec 22nd, 2016, 09:28am by Richard Russell » 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