《windows程序设计》声音与音乐那章的一个例子TESTMIC.C,里面有这么一段,用于弹出一个对话框,
我在rc文件中创建一个对话框后运行该程序,却总看不到对话框,而是得到MessageBox里的内容,
试了好久,不知道为什么,请各位指教一下.#include <windows.h>
#include "resource.h"#define ID_TIMER    1BOOL CALLBACK DlgProc (HWND, UINT, WPARAM, LPARAM) ;TCHAR szAppName [] = TEXT ("TestMci") ;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,                    PSTR szCmdLine, int iCmdShow){
     if (-1 == DialogBox (hInstance, TEXT("TESTMCI"), NULL, DlgProc))
     {
          MessageBox (NULL, TEXT ("This program requires Windows NT!"),
                      szAppName, MB_ICONERROR) ;
     }
     return 0 ;
}

解决方案 »

  1.   

    DialogBox 第二个参数不对
      

  2.   

    int DialogBox( 
    HINSTANCE hInstance, 
    LPCTSTR lpTemplate, 
    HWND hWndParent, 
    DLGPROC lpDialogFunc); lpTemplate 
    [in] Long pointer to the dialog box template. This parameter is either the pointer to a null-terminated character string that specifies the name of the dialog box template or an integer value that specifies the resource identifier of the dialog box template. If the parameter specifies a resource identifier, its high-order word must be zero and its low-order word must contain the identifier. You can use the MAKEINTRESOURCE macro to create this value. 
      

  3.   

    不是,这个是我在试的时候写的,他原文是szAppName,
    然后我在rc文件里把对话框命名为"TestMci" 或者"TESTMCI"都不对
      

  4.   

    在资源视图中看看你的对话框资源ID是怎么设置的,一般是用常量形式表示,例如IDD_DIALOG1,如果是这样,把程序中DialogBox的第2参数改成(LPCTSTR)IDD_DIALOG1这样的形式。
      

  5.   

    如果对话框资源ID是TESTMCI,那就写(LPCTSTR)TESTMCI,注意区分大小写。
      

  6.   

    可以看看这个:
    http://blog.csdn.net/hityct1/archive/2008/12/28/3624857.aspx对话框资源要存在。
      

  7.   

    对话框资源ID是怎么设置的?如果确定资源ID没有给错,可以在DlgProc函数上设置一个断点来调试看看能否执行到。
      

  8.   

    设了几个断点,然后调试运行,到了第一个断点,然后按下一步就直接到了DlgProc函数的末尾......
      

  9.   

    DialogBox(hInstance, MAKEINTRESOURCE(IDD_VMSTAT), NULL, Dlg_Proc);
      

  10.   

    DialogBox( hInstance, ( LPCTSTR ) IDD_DIALOG1, NULL, ( DLGPROC ) WndProc );
    DialogBox (hInstance, TEXT("TESTMCI"), NULL, DlgProc);你用TEXT做什么?
      

  11.   

    刚又设了几个断点,但都没有执行到,直接就弹出个MessageBox,
    返回值是:has exited with code 0 (0x0).
      

  12.   

    在DlgProc函数入口上设一个断点就够了。