Not Able to Get Message
-
I am working on a project, where i have to catch event on Update of the particular control , message is already defined for it. Between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP i am putting ON_MESSAGE (Messagename,UpdateFunction) statement with message and function name as a parameter. i have written definition of UpdateFunction in the same class. Problem :( is while running and updating control UpdateFunction is not getting executed. :wtf: is there anything i am missing for handling this ?
-
I am working on a project, where i have to catch event on Update of the particular control , message is already defined for it. Between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP i am putting ON_MESSAGE (Messagename,UpdateFunction) statement with message and function name as a parameter. i have written definition of UpdateFunction in the same class. Problem :( is while running and updating control UpdateFunction is not getting executed. :wtf: is there anything i am missing for handling this ?
Do you
SendMessage
orPostMessage
to the class that you defined message in it or the framework should do that for you? Did you define a custom message or just redirect the same message? Which message is it? What type of control? Is it a custom control for example? Would you please provide some of your codes or at least more details.// "In the end it's a little boy expressing himself." Yanni
while (I'm_alive)
{
cout<<"I love programming.";
} -
Do you
SendMessage
orPostMessage
to the class that you defined message in it or the framework should do that for you? Did you define a custom message or just redirect the same message? Which message is it? What type of control? Is it a custom control for example? Would you please provide some of your codes or at least more details.// "In the end it's a little boy expressing himself." Yanni
while (I'm_alive)
{
cout<<"I love programming.";
}yah its a custom control and message is also a custom one , redirecting to other message ... , i mean to say that its a custom table control when i update a cell value it should get to that method which i have specified in On_Message ... I just wanted to ask that is there anything that we have to do while handling messages 1)Define entry in message map 2)provide declaration and definition of Method (which you want to execute on event of message) Tahnx
-
yah its a custom control and message is also a custom one , redirecting to other message ... , i mean to say that its a custom table control when i update a cell value it should get to that method which i have specified in On_Message ... I just wanted to ask that is there anything that we have to do while handling messages 1)Define entry in message map 2)provide declaration and definition of Method (which you want to execute on event of message) Tahnx
paresh_joe wrote:
anything that we have to do while handling messages
If it's a CUSTOM message, then we shall follow the instruction: 1. Event handler MUST return
LRESULT
2. Message variable should be defined in a right way, easiest: #define MyTestMessage WM_USER+1 3. Function declaration in the header file should should be written beforeDECLARE_MESSAGE_MAP()
(e.g LRESULT OnSomething(WPARAM wParam, LPARAM lParam); ) 4. In .cpp it should be declared in a MESSAGE_MAP block: (e.g.ON_MESSAGE(MyTestMessage, OnSomthing)) 5. ALWAYS return 0 in the message handler function. 6. Only a window can accept messages, unless you create a custom message mapping, sending, dispatching, ... mechanism. So a CWnd object or derived classes can handle a message.// In .h file
...
//}}AFX_MSG
LRESULT OnSomething(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()// In .Cpp file
...
BEGIN_MESSAGE_MAP(CMyClass, CDialog)
...
ON_MESSAGE(MyTestMessage, OnSomething)
END_MESSAGE_MAP().
.
.LRESULT CMyClass::OnSometing(WPARAM wParam, LPARAM lParam)
{
// Do Something
return 0;
}// "In the end it's a little boy expressing himself." Yanni
while (I'm_alive)
{
cout<<"I love programming.";
}modified on Friday, December 07, 2007 9:29:01 AM
-
paresh_joe wrote:
anything that we have to do while handling messages
If it's a CUSTOM message, then we shall follow the instruction: 1. Event handler MUST return
LRESULT
2. Message variable should be defined in a right way, easiest: #define MyTestMessage WM_USER+1 3. Function declaration in the header file should should be written beforeDECLARE_MESSAGE_MAP()
(e.g LRESULT OnSomething(WPARAM wParam, LPARAM lParam); ) 4. In .cpp it should be declared in a MESSAGE_MAP block: (e.g.ON_MESSAGE(MyTestMessage, OnSomthing)) 5. ALWAYS return 0 in the message handler function. 6. Only a window can accept messages, unless you create a custom message mapping, sending, dispatching, ... mechanism. So a CWnd object or derived classes can handle a message.// In .h file
...
//}}AFX_MSG
LRESULT OnSomething(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()// In .Cpp file
...
BEGIN_MESSAGE_MAP(CMyClass, CDialog)
...
ON_MESSAGE(MyTestMessage, OnSomething)
END_MESSAGE_MAP().
.
.LRESULT CMyClass::OnSometing(WPARAM wParam, LPARAM lParam)
{
// Do Something
return 0;
}// "In the end it's a little boy expressing himself." Yanni
while (I'm_alive)
{
cout<<"I love programming.";
}modified on Friday, December 07, 2007 9:29:01 AM
Thanx