Re: Modeless Dialogs and WM_CHAR
From: William DePalo [MVP VC++] (willd.no.spam_at_mvps.org)
Date: 02/01/05
- Next message: Frank Hickman [MVP]: "Re: The IDE always say some files are out of data when I "Go" the program"
- Previous message: Tom Widmer: "Re: What's going on here?!"
- In reply to: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- Next in thread: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- Reply: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 1 Feb 2005 09:33:40 -0500
"Callum Winter" <callum@REMOVE_THISwinter9999.fsnet.co.uk> wrote in message
news:OAO%23C8FCFHA.3588@TK2MSFTNGP11.phx.gbl...
>> if ( !IsDialogMessage(hMyDialog, &msg) )
>> {
>> TranslateMessage(&msg);
>> DIspatchMessage(&msg);
>> }
>>
>> No?
>
> Yup exactly like that but i dont get the keystroke messages, when the
> application window has focus.
Hmm. You don't get them where? Above? If the messages in question are _sent_
to your window then they shouldn't make it to the stretch of code above
either in the modal or the modeless case. If they are _posted_ they should
be available just before the call to IsDialogMessage() in both cases. After
all, a dialog after all is just a window of a class registered by Windows
USER module whose window procedure knows to do quite a lot - in particular
it knows how to do application callbacks. However, the keystroke routing
happens at a lower level.
> So your saying the default behaviour of a modeless dialog created with
> CreateDialog() is not to receive WM_CHAR in fact not to recieve any
> keystroke messages in the callback, and i need to subclass the dialog so I
> can respond to WM_GETDLGCODE to make it generate them.??.
Keystroke (WM_CHAR) messages are destined for the window with the focus.
Usually they are routed there by DispatchMessage() after TranslateMessage
synthesizes them from the WM_KEYxx messages it finds in the queue. And
there's the disconnect - I still don't see why there is a difference between
the modal and modeless cases (could be my problem).
> I own Charles Petzold Fifth Edition but cant find anything on
> WM_GETDLGCODE
> in there (at least its not mentioned in the index), guess Im stuck with
> the
> online docs, for this one. oh well.
It's not the most basic of things so I don't know if he covers it (my copy
is not near me now). If you have a book by Richter he may describe it.
Keyboard handling is surprisingly complex. It's easy to miss the complexity
because Windows often does the right thing but behind your back. For
example, arrow keys scroll multi-line edit controls up and down. Windows
(actually the edit control's window procedure and the dialog manager)
cooperate to do the right thing.
There the dialog manager sends a WM_GETDLGCODE to the edit control, it
responds saying that it wants the arrows. So whenever the edit control has
the focus, the dialog manager sees to it that it gets the arrow keys. I was
suggesting subclassing the control in question and responding to the
WM_GETDLGCODE such that you could process the keystrokes/character messages
that you want in the subclassed window procedure.
> This sounds interesting, ill have a look at that aswell.
> Thanks for the advice, at least I have something to go on now.
Glad to help.
Regards,
Will
- Next message: Frank Hickman [MVP]: "Re: The IDE always say some files are out of data when I "Go" the program"
- Previous message: Tom Widmer: "Re: What's going on here?!"
- In reply to: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- Next in thread: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- Reply: Callum Winter: "Re: Modeless Dialogs and WM_CHAR"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|