• Advertisement
Sign in to follow this  

System Core class

This topic is 3459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I trying to write a System Core class but i've got a error. My class is somthing like this: //Header
class CoreSys
{
//here some definitios

protected:
  WNDCLASSEX	m_wcex;

public:
//
  BOOL Run();

  virtual FAR PASCAL MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
   return (int)DefWindowProc(hWnd,uMsg,wParam,lParam);
}

};
//Cpp file
BOOL CoreSys::Run()
{
	ZeroMemory(&m_wcex,sizeof(m_wcex));

	m_wcex.cbSize = sizeof(WNDCLASSEX);
	m_wcex.style = m_style;
	m_wcex.lpfnWndProc = (WNDPROC)MsgProc;
	m_wcex.cbClsExtra = 0;
	m_wcex.cbWndExtra = 0;
	m_wcex.hInstance = m_hInstance;
	m_wcex.hIcon = NULL;
	m_wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	m_wcex.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	m_wcex.lpszMenuName = NULL;
	m_wcex.lpszClassName = m_Class;
	m_wcex.hIconSm = NULL;

	if(!RegisterClassEx(&m_wcex))
		Error(TRUE,"Error");
  //
}
I have error at this line:
m_wcex.lpfnWndProc = (WNDPROC)MsgProc;
error C2440: 'convertion type' : cannot do the convertion 'overloaded-function' a 'WNDPROC' any idea? Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
It will have to be static, then you will want to put a pointer to your class inside of the GWLP_USERDATA memory of your window with SetWindowPtrLong function, then get it back out with GetWindowPtrLong.

Share this post


Link to post
Share on other sites
hmm but can I overload a static function?

@Portmanteau: Whats a GWLP_USERDATA? I dont understand what u mean.

Will I have to do this:


class CApp: public CoreSys {
};



FAR PASCAL MyWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR CmdLine,int nShow){
{
CApp app;
//
app.SetWindowPtrLong(MyWndProc);

}


FAR PASCAL MyWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){

return (int)DefWindowProc(hWnd,uMsg,wParam,lParam);

}


Share this post


Link to post
Share on other sites
Quote:
Original post by MaxDemian
hmm but can I overload a static function?


Read the link I posted.

Share this post


Link to post
Share on other sites
Ok, now I have an error here:


wnd = reinterpret_cast<Window *>((LPCREATESTRUCT)lparam)->lpCreateParams;




Compiler said that lpCreateParams is not a member of Window. I don't know how to define this var.:/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement