INT_PTR DialogBox(HINSTANCE hInstance,
    LPCTSTR lpTemplate,
    HWND hWndParent,
    DLGPROC lpDialogFunc
);
如何将lpTemplate这个参数传入lpDialogFunc回调函数中去呢?不使用全局变量

解决方案 »

  1.   

        恩,lpTemplate参数指定了模板资源。
        一般的用法是使用资源编辑器编辑一个窗口。
        然后在调用DialogBox的Cpp文件中,添加“resource.h”头文件,然后lpTemplate参数使用MAKEINTRESOURCE(IDD_DIALOG/*这个是资源的ID*/)。
      

  2.   

    你需要lpTemplate干什么
    DialogBoxParam可以传一个自定义参数
      

  3.   

    lpTemplate
    [in] Specifies 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. 
    MAKEINTRESOURCE(IDD_DIALOG1)就可以了,不看MSDN吗?
      

  4.   

    剧情需要啊,呵呵
    因为有好几个Dialog都是调用同一个lpDialogFunc,
    所以我才想再lpDialogFunc内部进行判断是哪个ID的Dialog
      

  5.   

    这个看了,我是想知道能不能将MAKEINTRESOURCE(IDD_DIALOG1)传入回调函数
      

  6.   

    [in] Specifies the value to pass to the dialog box in the lParam parameter of the WM_INITDIALOG message.
    这个传入的值只有在WM_INITDIALOG消息中才可用吗?
      

  7.   

    好几个dialog中都要用,那你在dialog内部整个变量 不就行了?变量值不一样
      

  8.   

    可以用SetWindowLong GWL_USERDATA为窗口设置一个自定义数据