现在的位置: 首页 > 综合 > 正文

CreateDialog Function

2018年03月15日 ⁄ 综合 ⁄ 共 1771字 ⁄ 字号 评论关闭
文章目录
CreateDialog Function

语法

HWND CreateDialog(
  __in  HINSTANCE hInstance,
  __in  LPCTSTR lpTemplate,
  __in  HWND hWndParent,
  __in  DLGPROC lpDialogFunc
);

 

参数

hInstance [in]
HINSTANCE

包含对话框模板资源的可执行文件句柄.

lpTemplate [in]
LPCTSTR

指定对话框模板. 这个参数不是一个指向表示对话框模板资源的NULL结尾的字符串就是一个表示对话框模板标识符的整数。如果是一个整数,它的高字节必须是0,低字节必须是资源标识符。你可以用MAKEINTRESOURCE宏来创建这个值。

hWndParent [in]

 

HWND

拥有这个对话框的窗口句柄

lpDialogFunc [in]

DLGPROC

指向一个对话框过程. For more information about the dialog box procedure, see DialogProc.

Return Value

HWND

If the function succeeds, the return value is the handle to the dialog box.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

This function typically fails for one of the following reasons:

  • an invalid parameter value
  • the system class was registered by a different module
  • The WH_CBT hook is installed and returns a failure code
  • if one of the controls in the dialog template is not registered, or its window window procedure fails WM_CREATE or WM_NCCREATE

Remarks

The CreateDialog function uses the CreateWindowEx function to create the dialog box. CreateDialog then sends a WM_INITDIALOG message (and a WM_SETFONT message if the template specifies the DS_SETFONT or DS_SHELLFONT style) to the dialog box procedure. The function displays the dialog box if the template specifies the WS_VISIBLE style. Finally, CreateDialog returns the window handle to the dialog box.

After CreateDialog returns, the application displays the dialog box (if it is not already displayed) by using the ShowWindow function. The application destroys the dialog box by using the DestroyWindow function. To support keyboard navigation and other dialog box functionality, the message loop for the dialog box must call the IsDialogMessage function.

Examples

For an example, see Creating a Modeless Dialog Box.

 

抱歉!评论已关闭.