Hello everyone,
I have little problem. I’m trying to create very simple class that will be able to create a window and holds messages for it. Code follows :
MyClass.h
class MyClass
{
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
BOOL CreateWindow();
…
};
MyClass.cpp
#include “MyClass.h”
LRESULT CALLBACK MyClass::WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(…
…
}
BOOL MyClass::CreateWindow()
{
WNDCLASS wc;
hInstance=GetModuleHandle(NULL);
wc.style=CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
wc.lpfnWndProc=(WNDPROC)WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor=LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground=NULL;
wc.lpszMenuName=NULL;
wc.lpszClassName=“Test”;
RegisterClass…
…
}
My problem is on line “wc.lpfnWndProc=(WNDPROC)WndProc;”. When I tried to compile it, this error occurs
“error C2440: ‘=’ : cannot convert from ‘long (stdcall MyClass::*)(struct HWND *,unsigned int,unsigned int,long)’ to ‘long (stdcall *)(struct HWND *,unsigned int,unsigned int,lo
ng)’ There is no context in which this conversion is possible”
Do you have any ideas, what’s wrong in my code. I’m just a beginner, so I’m sorry for my stupidity. Also sorry for my English, I’m working on it.
Thank you very much.
Boda.