많이들 쓰는 듯...
class MyClass;
LRESULT CALLBACK WndProc( HWND hHwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
LRESULT result;
static MyClass *pthis = (MyClass*) GetWindowLong( hWnd, GWL_USERDATA );
if ( pthis == NULL && msg == WM_NCCREATE )
{
void *userdata = (void*)( ((CREATESTRUCT*) lParam)->lpCreateParam );
SetWindowLong( hWnd, GWL_USERDATA, userdata );
result = DefWindowProc( hWnd, msg, wParam, lParam );
}
else
{
if ( this )
result = pthis->MyWndProc( hWnd, msg, wParam, lParam );
else
result = DefWindowProc( hWnd, msg, wParam, lParam );
}
return result;
}
class MyClass
{
public:
CreateWindow( ... )
{
wc.lpfnWndProc = WndProc;
RegiserWindow( &wc );
m_hWnd = CreateWindowEx( /* */, this );
}
LRESULT MyWndProc( hWnd, msg, wParam, lParam );
protected:
m_hWnd;
}
'프로그래밍 > 기법' 카테고리의 다른 글
[윈도] 윈도우 프로시져의 멤버 함수화 II (0) | 2014.04.20 |
---|---|
[책] C로 배우는 알고리즘 - 예제 (0) | 2010.11.08 |
배열을 이용한 linked list 구현 (0) | 2010.03.01 |