|
-
December 12th, 2004, 08:17 AM
#1
How can i use shortcut keys?
good day to all!i try to check some thread regarding shortcut keys but i cant find a good one.
the scenario here is that i want to impliment actions using keyboard inputs. I may press f1-f8 and also alt combinations and ctrl combinations.
how can i do this?
-
December 12th, 2004, 09:13 AM
#2
Re: How can i use shortcut keys?
You can use accelerators to combine keys with modifier to menues. Or you can use "RegisterHotkey" to register a global hotkey your pogramm can handle.
Just use MSDN and search for these two phrases.
-
December 12th, 2004, 10:41 AM
#3
Re: How can i use shortcut keys?
can you give me a code snipet so i can have a good pattern... thats all..
-
December 12th, 2004, 10:47 AM
#4
Re: How can i use shortcut keys?
For me I cannot explain this all as good as here.
-
December 12th, 2004, 10:53 AM
#5
Re: How can i use shortcut keys?
i forgot to add... im using sdi application and all modules are in modal state....
so every dialog that pops-up will have different shortcut approaches...
i need some code samples to be my pattern code
-
December 12th, 2004, 10:55 AM
#6
Re: How can i use shortcut keys?
 Originally Posted by DjChris14
i forgot to add... im using sdi application and all modules are in modal state....
so every dialog that pops-up will have different shortcut approaches...
i need some code samples to be my pattern code
If you post your code, I will know what you are doing and how to add this functionality to your code. Otherwise it's hard to help you.
-
December 12th, 2004, 11:20 AM
#7
Re: How can i use shortcut keys?
i cant post the code because i havent started to put short cuts... anyway ill give you the logical flow what i wanted to do...
in my dialog, i have several controls like radio button(3), check boxes(2), command buttons (command buttons can have its shortcut keys right?).
if i press let say f1, one of the radio buttons will be true and the last 2 will be false.., if i press f2, check button1 will be active (and be deactivate) same with check button2...
have you figure it out? can the accelerators handle it? i notice about the accelerators is that they pertains to controls on every commands being issued...
-
December 12th, 2004, 11:22 AM
#8
Re: How can i use shortcut keys?
in additional to it... if i dont register the control shortcuts of command button, is there an effect to it?
-
December 12th, 2004, 11:26 AM
#9
Re: How can i use shortcut keys?
Just create an appropiate accelerate resource - You can assign key strokes to ID's, so if this key is pressed within your application a WM_COMMAND message for the specified ID will occur - and change your 'InitInstance' as follows:
Code:
// Some code before
// Load your accelerator table here
HACCEL haccel = LoadAccelerators(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_ACCEL));
// Possible check if haccel is NULL ...
while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
if (!TranslateAccelerator(
hwndMain, // handle to receiving window, use the hwnd of your main window here
haccel,
&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return FALSE
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|