|
-
May 23rd, 1999, 07:15 AM
#1
window procedure
Hi,
Is it possible to have a window procedure,that will be a member function of a class.
thanks,
Shai
-
May 23rd, 1999, 10:56 AM
#2
Re: window procedure
A static member function, yes it can be done. A non-static member function, no.
The prototype for a window procedure is not compatible with the prototype for a non-static class member function because of the hidden "this" argument for non-static member functions.
Regards,
Paul McKenzie
-
May 24th, 1999, 01:14 AM
#3
Re: window procedure
How does the message map macros map a message to
a class memeber function in MFC (for instance ON_MESSAGE(...) )?
Shai
-
May 24th, 1999, 02:19 AM
#4
Re: window procedure
ON_MESSAGE(UM_MYMESSAGE, OnMyMessage)
maps to:
LRESULT CSomeWindowClass::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
}
(the routine name OnMyMessage() can be whatever you want).
This mirrors the standard API window procedure where you have the parameters passed with the message and you return a long value.
Don't forget to stick afx_msg in front of the prototype in the header file.
-
May 24th, 1999, 06:21 PM
#5
Re: window procedure
Hi,
In MFC there is a super window proc which is called for all the windows created using MFC .This is not a member of any class.its called AfxWndProcBase(file afxstate.cpp).This function in turn calls AfxWndProc which gets the CWnd pointer from the window handle which comes with the message and calls the member function of CWnd called WindowProc which in turn calls CWnd::OnWndMsg which finally calls the handler for that particular message which will be a member function of ur CWnd derived class.
The point is ur non-static member function is not a direct callback function.Its just been invoked by a real callback function(which is not a member of any class) which has the pointer to ur object.
Just put a breakpoint in a message handler and study the function call stack when it breaks at that point.
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
|