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

02 February 2005, 05: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

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

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

wc.lpfnWndProc = ChrisButton::WndProc;

Whereupon I get a compile error at this line:

wc.lpfnWndProc = ChrisButton::WndProc;

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.

02 February 2005, 05:57 PM

02 February 2005, 06:04 PM
Apparently it's as simple as 'you can't do that'

According to this article: (

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

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

02 February 2005, 10:56 PM
Your right, I meant "It can't be done using just that method"

Chris J.

CGTalk Moderation
02 February 2006, 11: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.