Link to home
Start Free TrialLog in
Avatar of DougBell
DougBell

asked on

CTreeView tab key beeping problem

I have a class derived from CTreeView, and I want the user to be able to use the tab key and shift-tab to perform actions.  My class has an OnKeyDown function responding to a TVN_KEYDOWN message.  I have two problems:

1.  When the tab key is pressed, the application executes the code in the OnKeyDown switch statement properly, but then it beeps (apparently the default behavior for an undefined key in CTreeCtrl).  Setting *pResult to TRUE has no effect.

2.  I don't see any way to distinguish between the tab key and the shift-tab key.  They both return the same key codes.

I have tried using a function responding to WM_KEYDOWN instead of TVN_KEYDOWN, but the problems are the same.  Any help is appreciated.
ASKER CERTIFIED SOLUTION
Avatar of PIG
PIG

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 PIG
PIG

BTW Chwck All Your exit paths. There can to be a problem with Beep.
Avatar of DougBell

ASKER

You were right about the beep stopping when *pResult = 1.  I must have had something else wrong when I tried it.

For the tab key, I'm aware that the shift key returns a code (it's 16, not 10).  The problem is telling when it's down.  I have implemented a flag variable that is set to TRUE by OnKeyDown and to FALSE by OnKeyUp.  It is also set to FALSE by OnKillFocus, in case the key is still down when the view loses focus.  The results still aren't exactly right, though, since shift-tab is read as tab if the shift key is down when the view gains focus.