自己写一个窗口类, 从CWnd派生.
最好再写一个Create方法,代替CWnd的方法.
BOOL RegisterWndClass( LPCTSTR name )
{
WNDCLASSEX wndcls;
HINSTANCE hInst = AfxGetInstanceHandle();
if (!(::GetClassInfo(hInst, name, &wndcls)))
{
wndcls.cbSize = sizeof( wndcls );
wndcls.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW ;
wndcls.lpfnWndProc = AfxWndProc;
wndcls.hCursor = LoadCursor(NULL,IDC_ARROW);
wndcls.hInstance = hInst;
wndcls.hIconSm = NULL;
wndcls.hIcon = NULL;
wndcls.hbrBackground = NULL;
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = name;
wndcls.cbWndExtra = 0;
wndcls.cbClsExtra = 0;
if ( RegisterClassEx( &wndcls ) == 0 )
{
return FALSE;
}
}
return TRUE;
}
BOOL Create( DWORD dwStyle , const RECT& rect , CWnd* parent , UINT nID )
{
LPCTSTR class_name = _T("wfc_statlist") ;
if ( !RegisterWndClass( class_name ) )
return FALSE ;
return CWnd::Create( class_name , NULL , dwStyle , rect , parent , nID );
}