Results 1 to 8 of 8

Thread: LoadAccelerators

  1. #1

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

    Unhappy LoadAccelerators

    Does someone know how to use the LoadAccelerators function?
    My code looks like that:

    Dim vAccel As ACCEL
    vAccel.cmd = GetMenuItemID(GetSystemMenu(frmMain.hwnd, 0&), 8)
    vAccel.fVirt = FSHIFT
    vAccel.key = Asc("Y")
    CreateAcceleratorTable vAccel, 1
    'and now that odd part:

    LoadAccelerators ????????

    the msdn library says:

    LoadAccelerators
    The LoadAccelerators function loads the specified accelerator table.

    HACCEL LoadAccelerators(
    HINSTANCE hInstance, // handle to application instance
    LPCTSTR lpTableName // address of table-name string
    );

    Parameters
    hInstance
    Handle to an instance of the module whose executable file contains the accelerator table to load.
    lpTableName
    Pointer to a null-terminated string that names the accelerator table to load. Alternatively, this parameter can specify the resource identifier of an accelerator-table resource in the low-order word and zero in the high-order word. The MAKEINTRESOURCE macro can be used to create this value.

    I absolutely don't have any clue about what the author meant by this explanation

  2. #2

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

    Unhappy

    I've tried

    Dim vAccel As ACCEL
    vAccel.cmd = GetMenuItemID(GetSystemMenu(frmMain.hwnd, 0&), 8)
    vAccel.fVirt = FSHIFT
    vAccel.key = Asc("Y")
    CreateAcceleratorTable vAccel, 1
    LoadAccelerators GetWindowWord(frmMain.hwnd, GWL_HINSTANCE), "MyAccel"

    but the GetWindowWord gives just 0, and what name should I use to add "Shift+Y" to an item in the systemmenu?

  3. #3
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Why Shift-Y, thats a bad combo, as no-one can type shift why anywhere in your menu.

    Just use the VB menu editor to add Ctrl-Y to it instead, much easier and quicker instead of doing things the hard way.

    otherwise get the handle when you create the accelerator table (it returns it in long format) and convert it into a high-level dword

  4. #4

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252
    1. I use a "qwertz" not an us "qwerty" keyboard so it's very useful for me.
    2. I just want to know the principle how to do it
    3.I am talking of the SystemMenu or also called ControlMenu and not a normal menu!!! I'm not a newbie that I wouldn't know that

    Perhaps someone else has got something more useful

  5. #5
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Sorry, was trying to help.

    for the first option:

    does app.hInstance work?

    while the second, its asking for the tablename, and createacceleratortable returns a table handle (in long format)

    so to convert that to a H-word, Cstr(hanle * &h10000)

    theres proberley a function to do that neater.

  6. #6
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Dim vAccel As ACCEL
    Dim HAccel as long

    vAccel.cmd = GetMenuItemID(GetSystemMenu(frmMain.hwnd, 0&), 8)
    vAccel.fVirt = FSHIFT
    vAccel.key = Asc("Y")
    HAccel = CreateAcceleratorTable( vAccel, 1 )
    'and now that odd part:

    LoadAccelerators app.hinstance, (HAccel converted into low-order word, not sure how to do this in VB)

  7. #7

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252
    thank you very much, now I got at least something to continue with,
    I just got a bit stuck with it what made me a bit angry
    Will try to convert it

    Hey, I think it's something to do with the GetAtomName Api
    Last edited by Olly; May 1st, 2001 at 11:20 AM.

  8. #8

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

    Exclamation Help please!

    I want to convert the integer that I got from the CreateAcceleratorTable into a low-order word using GetAtomName,
    but this always gives me an overflow error because the integer seems to be too long. I think I'll give it up then, but it's unbelievable that it is so hard to add a keyboardaccelerator to a menu during runtime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width