|
-
March 31st, 1999, 06:44 AM
#1
PreTranslateMessage never called
Hi,
I'm writing a dialog control as an ActiveX control, that is planed to run in another ActiveX control. For the class derived from COleControl I need a functions that distributes the messages to other classes of the control.
I tried PreTranslateMessage, but this function is never called. The (undocumented) MFC-function OnActivateInPlace (called in OnCreate) returns S_OK, but PreTranslateMessage still is not called at all.
Any suggestions are appreciated, Rudolf
-
March 31st, 1999, 09:45 AM
#2
Re: PreTranslateMessage never called
This is the way I do it when I want the dialog to handle all the messages and not the activex control. In the controls PreTranslateMessage handler do the following:
CYourControl::PreTranslateMessage(MSG* pMsg)
{
return pYourDialog->PreTranslateMessage(pMsg);
}
You can modify this to allow you dialog to handle certain messages and your control to handle certain messages.
Hope this helps,
Gary Kirkham
-
April 1st, 1999, 12:08 AM
#3
Re: PreTranslateMessage never called
Thank You for the suggestion, Gary.
But my problem is that all of the messages coming to my control find a way to avoid the PreTranslateMessage function. At the moment the first thing it does is a TRACE, but I cannot see anything of it in the results. Instead the messages that have a handler (OnLBtnDown for example) work properly.
So the question is: Is there anything (besides adding the function) to do to get PreTranslateMessage to work at all (in an ActiveX control)?
Thanks.
Rudolf
-
April 1st, 1999, 10:06 AM
#4
Re: PreTranslateMessage never called
I am really not sure what you mean by the messages avoiding the PreTranslateMessage function of the activex control. It is my understanding that all messages for the control come through there. Also, what exactly do you mean by "besides adding the function"? I have written several dialog based activex controls, you can view them at my company website at
http://www.sdac.com/applets.htm
You need Internet Explorer to view them or a plugin for netscape
I programmed them the same way I showed you. All messages that I wanted the dialog to handle I passed to the dialog thru the activex controls PreTranslateMessage function.
-
April 7th, 1999, 01:35 AM
#5
Re: PreTranslateMessage never called
Here is the PreTranslateMessage I use at the moment to see, whether it works.
BOOL CLTR_Ctrl::PreTranslateMessage(MSG* pMsg)
{
CString l_csTrace;
l_csTrace.Format("\n PTM called, message = %d \n \n", pMsg->message);
TRACE(l_csTrace);
switch(pMsg->message)
{
case WM_KEYDOWN:
{
TRACE("\n PTM-KeyDown \n \n");
break;
}
case WM_MOUSEMOVE:
{
TRACE("\n PTM-MouseMove \n \n");
break;
}
case WM_LBUTTONDOWN:
{
TRACE("\n PTM-LBtnDown \n \n");
break;
}
case WM_RBUTTONDOWN:
{
TRACE("\n PTM-RBtnDown \n \n");
break;
}
default:
{
break;
}
}
return FALSE;
//return COleControl::PreTranslateMessage(pMsg);
}
Normally, if I run the programm, none of the TRACE makros shows any effect on the output window (I use it extensively and never had problems with it) though I click on the mouse buttons (left and right), make lots of mouse moves, keyups and downs, and use two scrollbars.
At the moment (I changed PreTranslateMessage to return TRUE) the Keyup and Keydown messages are caught, but the rest not. Instead the "On" handler-functions of the rest still work properly (for some I have one - for example LBtnDown, Scroll - for others not - RBtnDown).
It is my understanding as well, that ALL messages for the control come through there, but the function doesn't mind.
So there remains the questions why it behaves this way and how I can change the behavior. Is there something I must do to let this function work the way it's written for (like overwrite another function or change some settings of the project)?
Thanks for Your help.
Rudolf
-
April 8th, 1999, 02:40 AM
#6
Problem circumvented
Thanks for the help. I still don't understand the problem exactly, but I think, a call to PreTranslateMessage of the container is the problem. Now I use WindowProc instead and it seems to work fine.
Rudolf
-
March 7th, 2001, 02:38 AM
#7
Re: Problem circumvented
I have the same proble you have solved. Can you explain me how you salved it?.
Thank you for your help.
Best Regards
-
March 7th, 2001, 03:00 AM
#8
Re: Problem circumvented
Hi,
as I said, I never solved this problem. I simply wanted a function that distributes the messages coming to my ActiveX and usually one would use PreTranslateMessage for this kind of job.
But since this function wasn't called, I used the function WindowProc that is a method of CWnd. It is called when the message arrives at the CWnd-object (in this case the COlecontrol derived class) and sends the messages to the handlers. So I could do what I wanted.
HTH,
Rudolf
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
|