/*********************************************************************** * AtlAxCreateDialogW [atl100.@] * * See AtlAxCreateDialogA * */ HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPROC dlgProc ,LPARAM param) { HRSRC hrsrc; HGLOBAL hgl; LPCDLGTEMPLATEW ptr; LPDLGTEMPLATEW newptr; HWND res; TRACE("(%p %s %p %p %lx)\n", hInst, debugstr_w(name), owner, dlgProc, param); hrsrc = FindResourceW( hInst, name, (LPWSTR)RT_DIALOG ); if ( !hrsrc ) return NULL; hgl = LoadResource (hInst, hrsrc); if ( !hgl ) return NULL; ptr = LockResource ( hgl ); if (!ptr) { FreeResource( hgl ); return NULL; } newptr = AX_ConvertDialogTemplate( ptr ); if ( newptr ) { res = CreateDialogIndirectParamW( hInst, newptr, owner, dlgProc, param ); HeapFree( GetProcessHeap(), 0, newptr ); } else res = NULL; FreeResource ( hrsrc ); return res; }
static void hugsprim_CreateDialogIndirectParamW_7(HugsStackPtr hugs_root) { HsPtr arg1; HsPtr arg2; HsPtr arg3; HsFunPtr arg4; HsInt32 arg5; HsPtr res1; arg1 = hugs->getPtr(); arg2 = hugs->getPtr(); arg3 = hugs->getPtr(); arg4 = hugs->getFunPtr(); arg5 = hugs->getInt32(); res1 = CreateDialogIndirectParamW(arg1, arg2, arg3, arg4, arg5); hugs->putPtr(res1); hugs->returnIO(hugs_root,1); }
static void test_MessageBoxFontTest(void) { /* This dialog template defines a dialog template which got 0x7fff as its * font size and omits the other font members. On WinNT, passing such a * dialog template to CreateDialogIndirectParamW will result in a dialog * being created which uses the message box font. We test that here. */ static unsigned char dlgTemplate[] = { /* Dialog header */ 0x01,0x00, /* Version */ 0xff,0xff, /* Extended template marker */ 0x00,0x00,0x00,0x00, /* Context Help ID */ 0x00,0x00,0x00,0x00, /* Extended style */ 0xc0,0x00,0xc8,0x80, /* Style (WS_SYSMENU|WS_CAPTION|WS_POPUP|DS_SETFONT|DS_MODALFRAME) */ 0x01,0x00, /* Control count */ 0x00,0x00, /* X */ 0x00,0x00, /* Y */ 0x80,0x00, /* Width */ 0x80,0x00, /* Height */ 0x00,0x00, /* Menu name */ 0x00,0x00, /* Class name */ 'T',0x00,'e',0x00, /* Caption (unicode) */ 's',0x00,'t',0x00, 0x00,0x00, 0xff,0x7f, /* Font height (0x7fff = message box font) */ /* Control #1 */ 0x00,0x00, /* Align to DWORD (header is 42 bytes) */ 0x00,0x00,0x00,0x00, /* Context Help ID */ 0x00,0x00,0x00,0x00, /* Extended style */ 0x00,0x00,0x00,0x50, /* Style (WS_CHILD|WS_VISIBLE) */ 0x00,0x00, /* X */ 0x00,0x00, /* Y */ 0x80,0x00, /* Width */ 0x80,0x00, /* Height */ 0x00,0x01,0x00,0x00, /* Control ID (256) */ 0xff,0xff,0x82,0x00, /* Class (Static) */ 'W',0x00,'I',0x00, /* Caption (unicode) */ 'N',0x00,'E',0x00, ' ',0x00,'d',0x00, 'i',0x00,'a',0x00, 'l',0x00,'o',0x00, 'g',0x00,' ',0x00, 't',0x00,'e',0x00, 's',0x00,'t',0x00, '.',0x00,0x00,0x00, 0x00,0x00, /* Size of extended data */ 0x00,0x00 /* Align to DWORD */ }; HWND hDlg; HFONT hFont; LOGFONTW lfStaticFont; NONCLIENTMETRICSW ncMetrics; /* Check if the dialog can be created from the template. On Win9x, this should fail * because we are calling the W function which is not implemented, but that's what * we want, because passing such a template to CreateDialogIndirectParamA would crash * anyway. */ hDlg = CreateDialogIndirectParamW(g_hinst, (LPCDLGTEMPLATE)dlgTemplate, NULL, messageBoxFontDlgWinProc, 0); if (!hDlg) { win_skip("dialog wasn't created\n"); return; } hFont = (HFONT) SendDlgItemMessageW(hDlg, 256, WM_GETFONT, 0, 0); if (!hFont) { skip("dialog uses system font\n"); DestroyWindow(hDlg); return; } GetObjectW(hFont, sizeof(LOGFONTW), &lfStaticFont); ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW); SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &ncMetrics, 0); ok( !memcmp(&lfStaticFont, &ncMetrics.lfMessageFont, FIELD_OFFSET(LOGFONTW, lfFaceName)) && !lstrcmpW(lfStaticFont.lfFaceName, ncMetrics.lfMessageFont.lfFaceName), "dialog doesn't use message box font\n"); DestroyWindow(hDlg); }
intptr_t Dialog::showModal(const ERDelegateWrapper<intptr_t (HWND, unsigned, uintptr_t, longptr_t)> &procMessage, int showCommand) { // From CDialog::DoModal in MFC. ShellPtr<> lparent = parent().lock(); HWND parentWin = nullptr; if(lparent) parentWin = lparent->hwnd(); const DLGTEMPLATE *tpl = static_cast<const DLGTEMPLATE *>(dialogTemplateWithSystemFont()); bool parentEnabled = false; if(parentWin != nullptr && IsWindowEnabled(parentWin)) { EnableWindow(parentWin, FALSE); parentEnabled = true; } intptr_t res = -1; isDialogEnd_ = false; endDialogResult_ = -1; setProcMessageFn(procMessage); HWND window = CreateDialogIndirectParamW(Batang::Win32Environment::instance().getInstance(), tpl, parentWin, callProcMessageFn, 0); if(window != nullptr) { hwnd(window); MSG msg; while(GetMessageW(&msg, nullptr, 0, 0)) { if(isDialogEnd_) { res = endDialogResult_; break; } if(showCommand) { ShowWindow(window, showCommand); UpdateWindow(window); showCommand = 0; } if(msg.message == WM_KEYDOWN && ShortcutKey::instance().processKey(this, GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_MENU) < 0, GetKeyState(VK_SHIFT) < 0, static_cast<uint32_t>(msg.wParam), ((msg.lParam & 0x01000000) == 0x01000000), static_cast<uint32_t>(msg.lParam & 0x0000FFFF))) { continue; } if(!IsDialogMessage(window, &msg)) { TranslateMessage(&msg); DispatchMessageW(&msg); } } if(!isDialogEnd_) // WM_QUIT { PostQuitMessage(0); return -1; } SetWindowPos(window, nullptr, 0, 0, 0, 0, SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER); } if(parentEnabled) EnableWindow(parentWin, TRUE); if(parentWin != nullptr && GetActiveWindow() == window) SetActiveWindow(parentWin); DestroyWindow(window); clearProcMessageFn(); hwnd(nullptr); return res; // return DialogBoxIndirectParamW(MainController::instance().getInstance(), tpl, parentWin, procMessage, 0); }
BOOL AP_Win32Dialog_Paragraph::_onInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) { const XAP_StringSet * pSS = m_pApp->getStringSet(); setDialogTitle (pSS->getValue(AP_STRING_ID_DLG_Para_ParaTitle)); // localize controls _DSX(PARA_BTN_OK, DLG_OK); _DSX(PARA_BTN_CANCEL, DLG_Cancel); _DS(PARA_BTN_TABS, DLG_Para_ButtonTabs); // setup the tabs { TabParam tp; TCITEMW tie; XAP_Win32App * pWin32App = static_cast<XAP_Win32App *>(m_pApp); HINSTANCE hinst = pWin32App->getInstance(); DLGTEMPLATE * pTemplate = NULL; HWND w = NULL; tp.pThis = this; // remember the windows we're using m_hwndDlg = hWnd; m_hwndTab = GetDlgItem(hWnd, AP_RID_DIALOG_PARA_TAB); // add a tab for each of the child dialog boxes UT_Win32LocaleString str; tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; tie.iImage = -1; str.fromUTF8(_GV(DLG_Para_TabLabelIndentsAndSpacing)); tie.pszText = (LPWSTR)str.c_str(); tie.lParam = AP_RID_DIALOG_PARA_TAB1; SendMessageW(m_hwndTab, TCM_INSERTITEMW, 0, (LPARAM)&tie); str.fromUTF8(_GV(DLG_Para_TabLabelLineAndPageBreaks)); tie.pszText = (LPWSTR)str.c_str(); tie.lParam = AP_RID_DIALOG_PARA_TAB2; SendMessageW(m_hwndTab, TCM_INSERTITEMW, 1, (LPARAM)&tie); // finally, create the (modeless) child dialogs tp.which = AP_RID_DIALOG_PARA_TAB1; pTemplate = UT_LockDlgRes(hinst, MAKEINTRESOURCEW(tp.which)); w = CreateDialogIndirectParamW(hinst, pTemplate, m_hwndTab, (DLGPROC)s_tabProc, (LPARAM)&tp); UT_ASSERT_HARMLESS((w && (w == m_hwndSpacing))); tp.which = AP_RID_DIALOG_PARA_TAB2; pTemplate = UT_LockDlgRes(hinst, MAKEINTRESOURCEW(tp.which)); w = CreateDialogIndirectParamW(hinst, pTemplate, m_hwndTab, (DLGPROC)s_tabProc, (LPARAM)&tp); UT_ASSERT_HARMLESS((w && (w == m_hwndBreaks))); } // HACK: make sure the first tab is visible // TODO: trigger selchange logic instead ShowWindow(m_hwndSpacing, SW_SHOW); // sync all controls once to get started // HACK: the first arg gets ignored _syncControls(id_MENU_ALIGNMENT, true); centerDialog(); return 1; // 1 == we did not call SetFocus() }