Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

I can't trap Shift-Delete, Escape, or Enter with a keydown event handler.

Whats up with that?
0 Kudos
Message 1 of 8
(4,050 Views)
Which control are you using and what version is it? I tested this with version 6.0 of the graph control and it worked for all three examples that you listed. Thanks.

- Elton
0 Kudos
Message 2 of 8
(4,051 Views)
Yes it is version 6 of the graph control.
Do you just create a OnKeyDown handler?
How about some code that I can try?
0 Kudos
Message 3 of 8
(4,051 Views)
An easy test is to drop the graph on a form in VB6 and add the following code:

Private Sub CWGraph1_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox "CWGraph1_KeyDown"
End Sub

In VC++, are you seeing that the event handler doesn't get called at all, or are you having having problems with ESC dismissing the dialog since it's a shortcut for cancel or ENTER dismissing the dialog since it's a shortcut for OK?

- Elton
0 Kudos
Message 4 of 8
(4,051 Views)
The graph is not seeing the event at all. I put a break point inside the KeyDown handler and it is not called for escape or enter. I am useing it in a dialog, so you may have something there.
0 Kudos
Message 5 of 8
(4,051 Views)
It is possible that the messages you are missing are being intercepted as dialog messages. In a MFC dialog, before messages are passed to the primary message loop, they are filtered through PreTranslateMessage and PreTranslateMessage calls IsDialogMessage which then handles or translates some messages outside of the normal message loop. You can control this process by using the ClassWizard to add a PreTranslateMessage implementation to your dialog class and making it something like the following:

BOOL CMyDlg::PreTranslateMessage( MSG msg )

{

// Return FALSE for messages you want to

// prevent from being processed as dialog

// messages

if (msg.message == WM_KEYDOWN && ...)

return FALSE;

else if( IsDi
alogMessage( msg ) )

return TRUE;

else

return CDialog::PreTranslateMessage( msg );

}



Let me know if this is not the problem.

Thanks,

Tony
NI - Measurement Studio

0 Kudos
Message 6 of 8
(4,051 Views)
Thats It!

Still No Shift-Delete, further up the message chain?

Thanks Tony.
0 Kudos
Message 7 of 8
(4,051 Views)
I don't think there is anything further up the message chain for a window, unless it is getting trapped by a different window for some reason. Do you have a textbox or something on the dialog that could be responding to Shift-Delete (Shift-Delete is a keyboard shortcut for "Cut", so any control that supports cut/copy/paste may be getting that one).

Tony
NI - Measurement Studio
0 Kudos
Message 8 of 8
(4,051 Views)