MSDN是这样表述的:
If the function succeeds, the return value is the value of the nResult parameter specified in the call to the EndDialog function used to terminate the dialog box.If the function fails because the hWndParent parameter is invalid, the return value is zero. The function returns zero in this case for compatibility with previous versions of Windows. If the function fails for any other reason, the return value is –1. To get extended error information, call GetLastError.最好把Code贴出来

解决方案 »

  1.   

    是怎么不对?
    hInstance是否正确?
      

  2.   

    用DialogBox(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,DialogProc);
      

  3.   

    原码是这样的,返回值总是为-1.
    LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
    HINSTANCE hInstance;
    char *stra="test";
    switch(uMsg)
    {
    case WM_PAINT:
    DrawHello(hwnd,stra);
    break;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    case WM_COMMAND:
    // if(DialogBoxParam(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),hwnd,DialogProc,NULL)==-1)
    // MessageBox(hwnd,"aa","aa",MB_OK);
    ……
    ……
            }
    }
      

  4.   

    谢谢大家的关心,我已经搞定了。
    原因是错误把这个设成了局部变量:HINSTANCE hInstance;
    改成全局变量后搞定!更详细的原因我也解释不上来,哪位更清楚的朋友一起给大家讲解一下吧!