-
December 14th, 2005, 07:47 PM
#1
onChar
Hi,
within a dialog, which has several edit boxes and buttons, I have defined a message handler for WM_CHAR using the class wizard. This creates
void CKeyFromSource::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
int i;
i = 1; // break here
CDialog::OnChar(nChar, nRepCnt, nFlags);
}
I have a break on the i=1 line;
This break is never hit...
Do I have to do something to cause these messages to be passed along?
Is there something which inhibits these messages?
I am using Visual C++ 6.0
Thanks for all help.
Last edited by phild; December 14th, 2005 at 07:53 PM.
-
December 14th, 2005, 07:59 PM
#2
Re: onChar
My guess is the dialog box procedure doesn't translate WM_KEYDOWN for simple character key strokes and it may be eating those.
I suspect you want to handle typing inside the edit box ? If so, please subclass the edit to your own CEdit derived class and handle WM_CHAR in that class and not the dialog class.
-
December 14th, 2005, 08:15 PM
#3
Re: onChar
Kirants,
thanks for the reply.
Actually no, I want to be able to catch 'return key', 'numerical pad return key', 'tab' keys etc, from anywhere. For example, if a button is focused and return id pressed, i want to be able to catch it.
Any ideas?
-
December 14th, 2005, 08:18 PM
#4
Re: onChar
In that case you are looking at WM_KEYDOWN. BTW, just curious, is the default dialog box behavior with keys not good for you ? Reason being, typical windows users would not like anything which goes against the normal. You may be having a reason though..
-
December 14th, 2005, 08:29 PM
#5
Re: onChar
Kirants,
Thanks again. I have tried the WM_KEYDOWN message with a similar result to WM_CHAR.... ie nothing.
No, I need to do more than the default dialog box behavior.
Do you think there is a way to get at these messages in a dialog?
-
December 14th, 2005, 08:40 PM
#6
Re: onChar
Hm.. I know why. It is because all those messages are targeted to the window which has focus ( in your case probably a button or edit or such ).
Please read this article:
http://www.codeguru.com/Cpp/W-D/disl...cle.php/c4965/
-
December 14th, 2005, 11:31 PM
#7
Re: onChar
Hi,
Not sure if you have already solved this..
Certain Windows messages are difficult to trap in a dialog box because they are either processed by the Windows internal dialog procedure or sent to the control instead of the dialog box. There are several ways to do this, but they usually involve subclassing all the controls in the dialog box or using a Windows hook function. The idea is to override the MFC preinstalled hook function, ProcessMessageFilter(), to trap the messages before they get to the dialog box.
In case you need an example, do let me know.
Cheers
Sun
-
December 15th, 2005, 07:35 AM
#8
Re: onChar
Yes, please, an example would be really helpful :-)
I will PM you with my email address.
Thanks Sun_raman
Phil
-
December 15th, 2005, 07:40 AM
#9
Re: onChar
Sun_raman, I don't seem to be able to PM you, if you can, email me or post the example on line.
Kirants, thank you, I read in detail the link you sent and the sublinks... so it can be done, but if I can get an example that would be really helpful
Thanks again
Phil
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|