Handling ALT Key on Controls
-
Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.
-
Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.
You could override the control classes, or you could use CreateGraphics to draw your keys direct to the screen, then call Invalidate in the key up, so the form gets repainted.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
You could override the control classes, or you could use CreateGraphics to draw your keys direct to the screen, then call Invalidate in the key up, so the form gets repainted.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Chris, Yes I want to paint them on control but how to handle pressing of ALT+KEY ? I dont want to use KeyPress, KeyDown events?
Vertyg0 wrote:
I dont want to use KeyPress, KeyDown events?
Why on earth not ? You can use a WndProc to catch these events earlier, but you really have no option but to use them, you want to catch when a key is down, and when it's raised again.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.
Hello You can set a property called
KeyPreview
totrue
in your form itself. Then handleKeyDown
event in the Form level. It will catch any KeyDown events in any control in that form before it is sent to that control.Regards:rose:
-
Hello, I want to create control(s) that would act like MS office 2007, so that when you press ALT key all controls that have hotkey will be repainted with hotkey drawn on itself. I dont want to use KeyDown, KeyPress, KeyUp events. Could it be all done trought some kind of extending of controls or so ? overriding WndProc or so ? Thanks.
Try adding & in front of the letter that will be the hot key
Do your best to be the best