Original Post
Hey, I've been trying to write a set of wrapper classes for the win32 API to make my programs easier to write (I know there are things like MFC but I don't want to learn it right now). Im not too good at OOP so im having a bit of trouble wrapping my head around it. What I have so far is:
class wccwindow
{
private:
WNDCLASSEX wnd; //the actual window class
LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
public:
//constructors/destructors
wccwindow(); //constructor
virtual ~wccwindow(); //destructor
//vars
DWORD exstyle; //extended styles
int x,y; //coords of the window
HWND parent; //parent window
HWND menu; //menu
HWND window; //handle to this window;
//functions
void init(LPCTSTR windowname,LPCTSTR windowtitle,DWORD windowstyle,int xlen,int ylen,HINSTANCE instance); //initialize window
};
///////////////////////////////////////////////////////////////////
wccwindow::wccwindow()
{
wnd.cbSize = sizeof(WNDCLASSEX);
wnd.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
wnd.cbClsExtra = 0;
wnd.cbWndExtra = 0;
wnd.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wnd.hCursor = LoadCursor(NULL,IDC_ARROW);
wnd.hbrBackground = (HBRUSH)GRAY_BRUSH;
wnd.lpszMenuName = NULL;
wnd.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
wnd.lpfnWndProc = WinProc;
x = CW_USEDEFAULT;
y = CW_USEDEFAULT;
exstyle = NULL;
parent = NULL;
menu = NULL;
}
wccwindow::~wccwindow()
{
}
///////////////////////////////////////////////////
// Functions
///////////////////////////////////////////////////
void wccwindow::init(LPCTSTR windowname,LPCTSTR windowtitle,DWORD windowstyle,int xlen,int ylen,HINSTANCE instance)
{
wnd.hInstance = instance;
wnd.lpszClassName = windowname;
RegisterClassEx(&wnd);
window = CreateWindowEx(exstyle,windowname,windowtitle,windowstyle,x,y,xlen,ylen,parent,(HMENU)menu,instance,NULL);
}
//LRESULT CALLBACK wccwindow::WinProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
//{
//return(0);
//}
The problem I get is with this line: wnd.lpfnWndProc = WinProc; My compiler (VC++ 6) gives me an error: error C2440: '=' : cannot convert from 'long (__stdcall wccwindow::*)(struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)' There is no context in which this conversion is possible Can anybody offer some advice? [Edited by - santonel on October 26, 2005 5:32:01 PM]