首先填充DLGTEMPLATE结构体:
DLGTEMPLATE* CreateDlgData()
{
const int SIZE = 1024;
WORD* pTempl = new WORD[SIZE];
memset(pTempl, 0, sizeof(WORD)*SIZE);
DLGTEMPLATE& dt = *((DLGTEMPLATE*)pTempl);
dt.style = WS_OVERLAPPEDWINDOW |DS_MODALFRAME|WS_DLGFRAME;//dialog style
dt.dwExtendedStyle = WS_EX_DLGMODALFRAME;//dialog extention style
dt.cdit = 0;//控件数量,这里设为0
pTempl += sizeof(DLGTEMPLATE);
*pTempl++ = 0; /// menu
*pTempl++ = 0; /// class name
return &dt;
}
然后申明dialog窗口过程:
INT_PTR CALLBACK dialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
// 这里处理类似于MFC中OnInitialDialog的方法
}
break;
}