PDA

Click to See Complete Forum and Search --> : LoadAccelerators


Olly
May 1st, 2001, 09:16 AM
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 :confused:

Olly
May 1st, 2001, 09:40 AM
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?

Nirces
May 1st, 2001, 09:56 AM
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

Olly
May 1st, 2001, 10:03 AM
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 :mad:

Perhaps someone else has got something more useful :rolleyes:

Nirces
May 1st, 2001, 10:39 AM
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.

Nirces
May 1st, 2001, 10:46 AM
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)

Olly
May 1st, 2001, 10:52 AM
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 :D
Will try to convert it

Hey, I think it's something to do with the GetAtomName Api

Olly
May 1st, 2001, 12:09 PM
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.