亲们,帮我看一下是怎么回事吧,产生的窗口应该如何关闭呢,我的问题出在了哪?我用的是vc++2010 的win32项目做的。
#include<windows.h>
#include<stdio.h>
#include"resource.h"
LRESULT CALLBACK Winproc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lparam
);int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPreInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
MSG msg;
    DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL,(DLGPROC)Winproc);
return 0;
    while(GetMessage(&msg,NULL,0,0))
    {    
  TranslateMessage(&msg);
  DispatchMessage(&msg);
    };
return 0;
}
LRESULT CALLBACK Winproc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lparam
)
{
switch(uMsg)
{
case IDOK:
EndDialog(hwnd, IDOK); 
break;
}
return 0;
}

解决方案 »

  1.   

    SendMessage(hwnd, WM_CLOSE, NULL, NULL);
      

  2.   

    刚刚改了一下,现在点窗口上的叉可以关闭了,不过还是在任务管理器里才能彻底关闭,还有就是点确定还是关不了
    #include<windows.h>
    #include<stdio.h>
    #include"resource.h"
    LRESULT CALLBACK Winproc(
    HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lparam
    );int WINAPI WinMain(HINSTANCE hInstance,
    HINSTANCE hPreInstance,
    LPSTR lpCmdLine,
    int nCmdShow
    )
    {
    MSG msg;
        DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL,(DLGPROC)Winproc);
        while(GetMessage(&msg,NULL,0,0))
        {    
      TranslateMessage(&msg);
      DispatchMessage(&msg);

        };
     
    return 0;}LRESULT CALLBACK Winproc(
    HWND hwnd,
    UINT uMsg,
    WPARAM wParam,
    LPARAM lparam
    )
    {

    switch(uMsg)
    {
    case IDOK:
    EndDialog(hwnd,IDOK);
    break;
    default:
     return DefWindowProc(hwnd,uMsg,wParam,lparam);
    }
    return 0;
    }