include "MyPanle.h"
LRESULT CALLBACK WindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam )
{
PAINTSTRUCT ps;
HDC hdc;
switch(uMsg)
{
case WM_CREATE:
{

}break;
case WM_PAINT:
{
hdc=BeginPaint(hwnd,&ps);
EndPaint(hwnd,&ps);
}break;
case WM_DESTROY:
{
             PostQuitMessage(0);
}break;
default: return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
Panle::Panle()
{
x=10;
y=10;
width=10;
height=10;
}
Panle::Panle(HWND hParentWnd)
{
x=10;
y=10;
width=10;
height=10; hInstance=GetModuleHandle(0); wc.cbSize=sizeof(WNDCLASSEX);
wc.style=CS_VREDRAW;
wc.lpfnWndProc=WindowProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon= NULL;              ;
wc.hIconSm=NULL;
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_BACKGROUND;
wc.lpszMenuName=NULL;
wc.lpszClassName="panle"; if(!RegisterClassEx(&wc))
{
for(int i=0;i<100;i++)
{ }
MessageBox(NULL,"Fail to register!","error",MB_OK);
return;
}
hWnd=CreateWindowEx(NULL,"panle","",WS_CHILD|WS_BORDER,x,y,width,height,hParentWnd,NULL,hInstance,NULL);
if(hWnd==NULL)
{
MessageBox(NULL,"Fail to create window!","error",MB_OK);
return;
}
ShowWindow(hWnd,SW_SHOWNORMAL);
UpdateWindow(hWnd); 
}
在调试代码的时候怎么会先执行hWnd=CreateWindowEx(NULL,"panle","",WS_CHILD|WS_BORDER,x,y,width,height,hParentWnd,NULL,hInstance,NULL);
后执行if(!RegisterClassEx(&wc))
{
for(int i=0;i<100;i++)
{ }
MessageBox(NULL,"Fail to register!","error",MB_OK);
return;
}
呢 郁闷 环境vc6.0

解决方案 »

  1.   

    是不是提醒你注册失败了?MessageBox(NULL,"Fail to register!","error",MB_OK); 弹出来了?
      

  2.   

    对啊 刚调试的时候怎么先跳到hWnd=CreateWindowEx(NULL,"panle","",WS_CHILD|WS_BORDER,x,y,width,height,hParentWnd,NULL,hInstance,NULL); 
    这个断点处 又跳回去到(!RegisterClassEx(&wc)) 

    for(int i=0;i <100;i++) 
    { } 
    MessageBox(NULL,"Fail to register!","error",MB_OK); 
    return; 

    执行呢