hi all,
I wonder...

I am able to create a working Message Pump loop in my main Dialog, but unable to create another on a different dialog, it loops in an endles loop.

i want to process another accelerator in my second dialog (not the parent one).

what would cause the problem?

thanks.
Posted on 2004-10-14 01:59:43 by wizzra
Afternoon, wizzra.

Please supply a small example proggy displaying the problem.

According to docs: you shouldn't require more than the one Message Pump for a single-threaded proggy as the window/dialog handle the message is for is inside the MSG structure and is dispatched to that particular window/dialogs's "message-handling" proc automatically.

Also worth noting:
If you don't handle WM_CHAR messages for keyboard input (i.e. you only handle WM_KEYUP/WM_KEYDOWN messages when the user hits the keyboard), then you don't need to have the TranslateMessage call inside your Message Pump.

Cheers,
Scronty
Posted on 2004-10-14 05:14:14 by Scronty
You can set different hotkeys in the same message loop by tracking the handle. There is no need to create a second message loop for the dialog.

I personally use GetAsynchKeyState for testing keystrokes in a message loop and its as easy as an .IF block which starts by testing which handle is in the message structure.
Posted on 2004-10-14 06:23:45 by hutch--
Afternoon, wizzra.
Please supply a small example proggy displaying the problem.

my project is too big to supply as an example :)
but..
creating a single thread window with message pump which works fine with the accelerators, than open with a button a new dialog window (resource) and it has a menu as well, and i want to handle the accelerator for this one.

so how i will be able to process the accelerator for the second dialog?
cuz thats what message pump usually process.


According to docs: you shouldn't require more than the one Message Pump for a single-threaded proggy as the window/dialog handle the message is for is inside the MSG structure and is dispatched to that particular window/dialogs's "message-handling" proc automatically.


yeah, thats why i guess it (the second window) doesn't work.


Also worth noting:
If you don't handle WM_CHAR messages for keyboard input (i.e. you only handle WM_KEYUP/WM_KEYDOWN messages when the user hits the keyboard), then you don't need to have the TranslateMessage call inside your Message Pump.

naa, i don't process them.
i only want to process the accelerator,
i.e: shurtcut keys for menus.

thanks again!
Posted on 2004-10-14 06:35:10 by wizzra
Afternoon, wizzra.

All of the accelerated keys are sent as WM_COMMAND messages to the main "message-handling" proc.

Inside that WM_COMMAND is the source of the command (i.e. whether main dialog or secondary dialog).

When processing the menu commands inside WM_COMMAND, just check which dialog the message is coming from.

Cheers,
Scronty
Posted on 2004-10-14 20:22:50 by Scronty