tags:

views:

12

answers:

0

I have an edit control class and a up-down control class, which derive from CEdit and CSpinButtonCtrl respectively. The up-down control has the UDS_ARROWKEYS style, and has the edit control set as buddy. This means that pressing the Up/Down arrow keys in the edit box is equivalent to clicking the Up/Down buttons. The buttons are even animated to press and release.

I would like to do some special handling if the user holds down CTRL while pressing the Up/Down arrow keys. This should happen in stead of the default behavior of emulating button presses, and herein lies the problem: I cannot get rid of the default behavior.

I have studied what happens, and this is what I have found: The message pump sends WM_KEYDOWN message for e.g. VK_UP to pretranslation. WalkPretranslateTree ends up calling PreTranslateMessage on the controls' parent dialog, which calls IsDialogMessage. IsDialogMessage sends a WM_GETDLGCODE message to the edit control, which I intercept in a override of OnWndMsg. Here, I do my special handling, and set the result value to exclude DLGC_WANTMESSAGE and DLGC_WANTARROWS, to indicate that I don't want further processing of this message. IsDialogMessage then proceeds to animate and increment anyway.

I have tried setting and not setting the DLGC_ flags, and I have tried returning TRUE and FALSE from OnWndMsg to no avail. I know that I could override IsDialogMessage on the parent dialog class and filter out the call to ::IsDialogMessage, but I would like my edit control not to be dependent on being placed in a particular type of dialog.

Does anybody have a suggestion on how to prevent the default behavior?