PDA

View Full Version : Assigning WndProc gives error....


AlpineMan
02-17-2005, 04:25 PM
[Visual Studio .NET 2002]
[VC 7.0]
[Max 7 SDK]

This question is actually purely windows related.

I am writing a new rolloutcontrol, and attempting to point a window procedure to the .lpfnWndProc member of the WNDCLASS(EX) struct. My class contains a WinProc member function is like so:

class ChrisButton
{
public:
LRESULT CALLBACK myWinProc(....);
};

LRESULT CALLBACK ChrisButton::WndProc(.... bla bla)
{
//...more stuff
}

I then attempt to assign that WndProc to my windowclass like so:

WNDCLASSEX wc;
...
wc.lpfnWndProc = ChrisButton::WndProc;
...
...
if(!RegisterClassEx(&wc))
...

Whereupon I get a compile error at this line:

wc.lpfnWndProc = ChrisButton::WndProc;

saying:
error C2440: '=' : cannot convert from 'LRESULT (__stdcall ChrisButton::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'
There is no context in which this conversion is possible

What is going on? Anyone have any idea why I cannot assign that function to the windows class? Cannot convert an LRESULT to a WNDPROC? Petzold does this in his book everywhere? Am I missing a settings somewhere?

I have tried looking everywhere on MSDN, and tried looking everywhere on microsoft as well. I've checked Petzold, and his function prototypes are exactly the same as mine, so what gives?

Chris J.

Vertizor
02-17-2005, 04:57 PM
http://www.winterdom.com/dev/cpp/class.html

http://www.rpi.edu/~pudeyo/articles/wndproc/

AlpineMan
02-17-2005, 05:04 PM
Apparently it's as simple as 'you can't do that'

According to this article:
http://www.rpi.edu/~pudeyo/articles/wndproc/ (http://www.rpi.edu/%7Epudeyo/articles/wndproc/)



Thanks for the response. I posted this but didn't see your reponse until it showed up in my email..

Vertizor
02-17-2005, 09:41 PM
I skimmed the 2 links I posted and it's seems like it IS possible. Examples in those links too.

AlpineMan
02-17-2005, 09:56 PM
Your right, I meant "It can't be done using just that method"

Chris J.

CGTalk Moderation
02-17-2006, 10:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.