Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to add keyboard processing functinality in DrawCLI sample code ?? Collapse All
Subject Author Date
Saroj Acharya Nov 22, 2004 - 3:54 PM

Hi Tech Support,


It sounds silly to ask this question but I am struggling with this. I wanted to add key board functionality in my code (which is derived from DrwaCLI sample code) so that when F1 or F2 is pressed, I could do certain things within my code.


I had tried processing OnChar() or WM_CHAR messahge in my MainFrame.cpp or in any other view, I never get this message ? ANy idea why such a simple thing is not working with my application ?? Same thing happened when I tried to add keyboard processing in your DrawCLI sample code. Looks like the problem exists in both.


Your help is highly appreciated.


Saroj

Technical Support Nov 23, 2004 - 9:11 AM

Only one window at a time can have focus. This window receives all keyboard messages. This is true for any Windows OS. When the main frame window gets focus, it automatically sets focus to the active view window. This is true both for your application and for our version of DrawCli. So, in most cases the focused window in your application is a view window. If you have resizable control bars with some child windows inside, then the user may set focus to these windows (for instance, with the mouse).

To handle keyboard events in the main frame, you may assign key combinations to the required commands in the accelerator table and then add the command handlers to the main frame window. You may also override the PreTranslateMessage virtual method in the main frame and return TRUE when the WM_KEYDOWN message is received and wParam is equal to an appropriate key constant (for example, the VK_F1). So, you may use either method.