I think you need to fix this
typedef long (* tyMessageHandler)(TWindow &,HWND, long, long);
to match the signature of a class method rather than a _cdecl function.
typedef long (TWindow::* tyMessageHandler)(HWND, long, long);
Typedefed names sometimes append _t or T rather than prepend. For example
typedef long (TWindow::* MessageHandlerT)(HWND, long, long);
and if you're going to use HWND, you might as well use WPARAM, LPARAM and LRESULT too.
typedef LRESULT (TWindow::* MessageHandlerT)(HWND, WPARAM, LPARAM);
but nothing says you have to.
Window Wrapper - CreateWindow Fails
Changing that, I needed to un-static the 2 member functions OnClose and OnDestroy. Doing this, this line
generates this error:
Which is kinda whack.
Thinking this through, I don't think that I want to use member function signature, but rather use the _cdecl as then one doesn't have to modify the class to add other routines. So I think that I'll just have ptr to functions.
So given this, any other suggestions? Or is my logic flawed?
return (it->second)((hwnd, wparam, lparam);
generates this error:
1>c:\documents and settings\chris\my documents\programming\c++\tempest\working source\twindow.cpp(188) : error C2064: term does not evaluate to a function taking 3 arguments
Which is kinda whack.
Thinking this through, I don't think that I want to use member function signature, but rather use the _cdecl as then one doesn't have to modify the class to add other routines. So I think that I'll just have ptr to functions.
So given this, any other suggestions? Or is my logic flawed?
I'd have to think it all through as well, but isn't part of the point of wrapping a window in a class to be able to extend that class? So wouldn't you want to stay away from static methods?
Well I think the way Oluseyi did it with the map was so that you didn't have to inherit off a base class like the 2nd link in my OP.
One just creates the base class and then one can do as many OnClose, OnPain, etc events as one wanted by just creating a small function that is called on that message, and registering it.
So yes, I think in this case we want to stay away from static functions. As well I don't think that
Is what I want to do, as I don't want to be tied down by having to have an event handler in the class.
edit
tracing, and setting a bp on if(it != NULL), first trace through all is fine, seccond time through, it comes back null, as expected, but then the test on it (it != NULL) is what causes the big STL error.
tyMessageIterator it;
it = pWnd->GetMessageHandler(message);
if(it != NULL) <- HERE
return (it->second)((*pWnd), hwnd, wparam, lparam);
[Edited by - _Sigma on March 8, 2007 9:02:25 AM]
One just creates the base class and then one can do as many OnClose, OnPain, etc events as one wanted by just creating a small function that is called on that message, and registering it.
So yes, I think in this case we want to stay away from static functions. As well I don't think that
Quote:
I think you need to fix this
typedef long (* tyMessageHandler)(TWindow &,HWND, long, long);
to match the signature of a class method rather than a _cdecl function.
typedef long (TWindow::* tyMessageHandler)(HWND, long, long);
Typedefed names sometimes append _t or T rather than prepend. For example
typedef long (TWindow::* MessageHandlerT)(HWND, long, long);
and if you're going to use HWND, you might as well use WPARAM, LPARAM and LRESULT too.
typedef LRESULT (TWindow::* MessageHandlerT)(HWND, WPARAM, LPARAM);
but nothing says you have to.
Is what I want to do, as I don't want to be tied down by having to have an event handler in the class.
edit
tracing, and setting a bp on if(it != NULL), first trace through all is fine, seccond time through, it comes back null, as expected, but then the test on it (it != NULL) is what causes the big STL error.
tyMessageIterator it;
it = pWnd->GetMessageHandler(message);
if(it != NULL) <- HERE
return (it->second)((*pWnd), hwnd, wparam, lparam);
[Edited by - _Sigma on March 8, 2007 9:02:25 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement