然怪我的电脑老卡着,

解决方案 »

  1.   

    贴出你的onpaint或者ondraw内代码
      

  2.   

    #include<windows.h>LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
    int WINAPI WinMain(
      HINSTANCE hInstance,  // handle to current instance
      HINSTANCE hPrevInstance,  // handle to previous instance
      LPSTR lpCmdLine,      // pointer to command line
      int nCmdShow          // show state of window
    )
    {
    static TCHAR szAppName[]=TEXT("linedemo");
    WNDCLASS wndclass;
    HWND hwnd;
    MSG msg;
    wndclass.style=CS_HREDRAW|CS_VREDRAW;
    wndclass.lpszMenuName=NULL;
    wndclass.lpszClassName=szAppName;
    wndclass.lpfnWndProc=WndProc;
    wndclass.hInstance=hInstance;
    wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
    wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.cbWndExtra=0;
    wndclass.cbClsExtra=0;
    if(!RegisterClass(&wndclass))
    {
    MessageBox(NULL,TEXT("Oh,No!"),szAppName,MB_ICONERROR);
    return 0;
    }
    hwnd=CreateWindow(szAppName,
    TEXT("LINEDEMO"),
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    NULL,
    NULL,
    hInstance,
    NULL);
    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);
    while(GetMessage(&msg,hwnd,0,0) )
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return msg.wParam;
    }LRESULT CALLBACK WndProc(
      HWND hwnd,      // handle to window
      UINT message,      // message identifier
      WPARAM wParam,  // first message parameter
      LPARAM lParam   // second message parameter
    )
    {
    HDC hdc;
    PAINTSTRUCT ps;
    static int cxClient,cyClient;

    switch(message)
    {
    case WM_SIZE:
    cxClient=LOWORD(lParam);
    cyClient=HIWORD(lParam);
    return 0;
    case WM_PAINT:
    hdc=BeginPaint(hwnd,&ps);
    MoveToEx(hdc,0,0,NULL);
    LineTo(hdc,cxClient,cyClient);
    MoveToEx(hdc,cxClient,0,NULL);
    LineTo(hdc,0,cyClient);
    Rectangle(hdc,cxClient/8,cyClient/8,7*cxClient/8,7*cyClient/8);
    Ellipse(hdc,cxClient/8,cyClient/8,7*cxClient/8,7*cyClient/8);
    RoundRect(hdc,cxClient/4,cyClient/4,3*cxClient/4,3*cyClient/4,cxClient/4,cyClient/4);
    EndPaint(hwnd,&ps);
    return 0;
    case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
    }
    return  DefWindowProc(
       hwnd,      // handle to window
       message,       // message identifier
      wParam,  // first message parameter
      lParam   // second message parameter
    );
    }
      

  3.   

    还有,使用了BeginPaint需要使用EndPaint
      

  4.   

    我写了
    EndPaint(hwnd,&ps);
      

  5.   


    while(GetMessage(&msg,hwnd,0,0))
    改成
    while(GetMessage(&msg,NULL,0,0))
      

  6.   

    to happyboy086(红尘有爱) 
    为何

    while(GetMessage(&msg,hwnd,0,0))
    改成
    while(GetMessage(&msg,NULL,0,0))就不会出现这样的问题
      

  7.   

    只有WM_QUIT才能使GetMessage返回FALSE,这样while循环才能结束。
    而WM_QUIT不是发送给hwnd的,你的程序永远都不能接收到WM_QUIT消息,当然驻留在内存里面了