Original Post
🔒 Locked
Problems with WndProc
Advertisement
You could try search the archives... :-)
I use this kind of approach:
class MyWindowClass
{
...
ATOM m_aAtom;
static LRESULT CALLBACK sWndProc(....);
LRESULT MsgProc(UINT msg,WPARAM,LPARAM);
};
in .cpp
MyWindowClass::MyWindowClass()
{
m_aAtom = ::GlobalAddAtom("myWndProc");
}
MyWindowClass::~MyWindowClass()
{
::RemoveProp(m_hWnd,"myWndProc");
}
and after you created your window call
::SetProp(m_hWnd,"myWndProc",(HANDLE)this);
LRESULT CALLBACK MyWindowClass::sWndProc(...)
{
MyWindowClass *pThis;
pThis = (MyWindowClass *)GetProp(hWnd,"myWndProc");
if(pThis != NULL)
{
return MsgProc(msg,wParam,lParam);
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
LRESULT MyWindowWindowClass::MsgProc(...)
{
// Handle messages here
}
hope this helps...
I use this kind of approach:
class MyWindowClass
{
...
ATOM m_aAtom;
static LRESULT CALLBACK sWndProc(....);
LRESULT MsgProc(UINT msg,WPARAM,LPARAM);
};
in .cpp
MyWindowClass::MyWindowClass()
{
m_aAtom = ::GlobalAddAtom("myWndProc");
}
MyWindowClass::~MyWindowClass()
{
::RemoveProp(m_hWnd,"myWndProc");
}
and after you created your window call
::SetProp(m_hWnd,"myWndProc",(HANDLE)this);
LRESULT CALLBACK MyWindowClass::sWndProc(...)
{
MyWindowClass *pThis;
pThis = (MyWindowClass *)GetProp(hWnd,"myWndProc");
if(pThis != NULL)
{
return MsgProc(msg,wParam,lParam);
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
LRESULT MyWindowWindowClass::MsgProc(...)
{
// Handle messages here
}
hope this helps...
I will take an example from threads, because they''re a little easier (ThreadProcs take a void* directly; WndProcs take it via a struct pointed at by lParam, and I don''t have any code lying around that examines that), but the technique can be used to work with WndProcs if you read up on the WndProc''s parameters.
This is uncompiled and untested, but the principle is sound.
To use this, we fill out a ThreadInfo and pass it to runThreadFunction:
This is uncompiled and untested, but the principle is sound.
|
To use this, we fill out a ThreadInfo and pass it to runThreadFunction:
|
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement