Link to home
Start Free TrialLog in
Avatar of marisademeglio
marisademeglio

asked on

control focus events

Hi experts,

I need to know what event gets triggered when a dialog control gets focus.

For example, my property page has several static labels, checkboxes, combo boxes, text entry fields.  As the user tabs to each one I need to announce what they should do.

Can you help me?

Thanks
marisa
SOLUTION
Avatar of rcarlan
rcarlan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nonubik
nonubik

You can try to trap WM_KEYDOWN with VK_TAB in PreTranslateMessage method of your CDialog derived class and then ask where's teh focus and act accordingly.
Focus can be gain/lost through mouse actions as well as through accelerator keys (i.e. keyboard shortcuts), in addition to Tab and Shift+Tab. Handling VK_TAB alone will only get you so far.

Radu
Avatar of marisademeglio

ASKER

Tab/shift-tab might work for me, since i will be playing an audio prompt as part of a self-voicing interface.  which would get annoying if it were triggered by any action.  but I understand Radu's point.

anyway, how would I ask "where's the focus?"
HWND GetFocus();
CWnd* CWnd::GetFocus();  // static
How do I catch keyboard events in a dialog?  WM_KEYUP and KEYDOWN aren't responsive..

nonubik, you mentioned PreTranslateMessage... How do I use it?

thanks
marisa
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial