Windows class

Started by
1 comment, last by egwenejs 18 years, 10 months ago
I'm trying to make a class that makes a window. So far I have:

#include <windows.h>

class EGWin {
public:
	EGWin(void);
	virtual ~EGWin(void);
	
	int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
};

int PASCAL EGWin::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
return 0;
}
Even with it this simple I get a link error because it can't find _WinMain@16 referenced in function _WinMainCRTStartup Any ideas to get this going would be great. Thanks.
Advertisement
You have to specify the WinMain function outside of a class. You could do for example:

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ EGWin MyWinClass; return MyWinClass.WinMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow );}


Another possibility would to make the WinMain function static and call it like

return EGWin::WinMain( hInstance, hPrevInstance, lpCmdLine, nCmdShow );


You also might want to have a look at this article.
Thanks a bunch for the quick reply and that link will be very useful.

This topic is closed to new replies.

Advertisement