我写了这个了 default:
return DefWindowProc(hWnd,message,wParam,lParam);
下面是全部代码 
#include<windows.h>
#include"resource.h"
LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam);int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
{
MSG msg;
DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),NULL,(DLGPROC)WndProc,NULL);

while(GetMessage(&msg,(HWND)NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
MessageBox(hWnd,TEXT("OK"),TEXT("OK"),NULL);
break;
}
break;
default:return DefWindowProc(hWnd,message,wParam,lParam);
}
return FALSE;
}

解决方案 »

  1.   

    这么修改LRESULT CALLBACK WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
    {
    switch(message)
    {
    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case IDOK:
    MessageBox(hWnd,TEXT("OK"),TEXT("OK"),NULL);
    break;
    }
    break;
    case WM_CLOSE:                     //新增关闭消息
    PostQuitMessage(0);
    break;
    //default:return DefWindowProc(hWnd,message,wParam,lParam); 删除
    }
    return FALSE;
    }
      

  2.   

    You should use the dialog box procedure only if you use the dialog box class for the dialog box. This is the default class and is used when no explicit class is specified in the dialog box template. Although the dialog box procedure is similar to a window procedure, it must not call the DefWindowProc function to process unwanted messages. Unwanted messages are processed internally by the dialog box window procedure.  上面是MSDN的解释,对话框的窗口过程跟普通窗口过程不太一样,不能调用DefWindowProc,你也可以看看MFC和ATL中的源代码,对话框过程中对不需要的消息都是直接返回0,即使对话框类也提供了DefWindowProc实现,它也是直接return 0;
      

  3.   

    靠 我看了答案就完了结贴了 sorry啊