在 CMainFrame::PreCreateWindow 添加如下代码:WNDCLASS wndcls;
wndcls.cbClsExtra =0;
wndcls.cbWndExtra =0;
wndcls.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_HELP);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=::AfxGetInstanceHandle (); wndcls.lpfnWndProc=::DefWindowProc ;
wndcls.lpszClassName=TEXT("unhappyless");
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls); cs.lpszName=TEXT("unhappyless");
在 view 类的PreCreateWindow 中加如下代码:cs.lpszName=TEXT("unhappyless");
wndcls.cbClsExtra =0;
wndcls.cbWndExtra =0;
wndcls.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_HELP);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=::AfxGetInstanceHandle (); wndcls.lpfnWndProc=::DefWindowProc ;
wndcls.lpszClassName=TEXT("unhappyless");
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls); cs.lpszName=TEXT("unhappyless");
在 view 类的PreCreateWindow 中加如下代码:cs.lpszName=TEXT("unhappyless");
This note describes the MFC routines that register the special WNDCLASSes needed by Microsoft Windows. Specific WNDCLASS attributes used by MFC and Windows are discussed.The ProblemThe attributes of a CWnd object, like an HWND in Windows, are stored in two places: the window object and the WNDCLASS. A WNDCLASS is different than a C++ class. The name of the WNDCLASS is passed to general window creation functions such as CWnd::Create and CFrameWnd::Create in the lpszClassName parameter.This WNDCLASS must be registered via one of four means: Implicitly by MFC provided WNDCLASSes
Implicitly by subclassing a Windows control (or some other control)
Explicitly by calling the MFC AfxRegisterWndClass or AfxRegisterClass
Explicitly by calling the Windows routine RegisterClass
嘿嘿,你是注册了一个你自己的窗口类,可是呢,你没有用上啊,
cs.lpszName=TEXT("unhappyless");//这不是类名!是下面:
cs.lpszClass=TEXT("unhappyless");//lpszClass这个才是类的名字啊,不要看走眼啦,呵呵