Bug 21655 – win32 dialog app, main dialog box is not centered

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
tools
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2021-02-22T09:16:27Z
Last change time
2021-03-03T12:15:27Z
Keywords
Optlink
Assigned to
No Owner
Creator
Tao

Comments

Comment #0 by top398 — 2021-02-22T09:16:27Z
A simple win32 dialog app, compiled by DMD 2.095.1, the dialog box is showed at upper-left of desktop when startup, but compiled by LDC 1.24.0 one centered. import core.sys.windows.windows; import core.runtime; enum { IDD_DIALOG1 = 100, } HINSTANCE hiApp; HWND hwDlg; extern (Windows) nothrow @system INT_PTR DlgProc(HWND hw, UINT wm, WPARAM wp, LPARAM lp) { switch(wm) { case WM_INITDIALOG: hwDlg = hw; return TRUE; case WM_CLOSE: EndDialog(hw, 0); return TRUE; default: break; } return FALSE; } extern (Windows) INT_PTR WinMain(HINSTANCE hiThis, HINSTANCE hiPrev, LPSTR psArg, int iShow) { Runtime.initialize(); hiApp = hiThis; INT_PTR res = DialogBox(hiApp, MAKEINTRESOURCE(IDD_DIALOG1), NULL, &DlgProc); Runtime.terminate(); return res; }
Comment #1 by destructionator — 2021-02-22T13:50:14Z
Do you have a resource file to go with the code btw?
Comment #2 by top398 — 2021-03-01T04:38:15Z
Of course I have. dlg.rc: #include <windows.h> #include <commctrl.h> #include <richedit.h> #include "resource.h" LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED IDD_DIALOG1 DIALOG 0, 0, 186, 95 STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU CAPTION "Dialog" FONT 8, "Ms Shell Dlg" { PUSHBUTTON "Cancel", IDCANCEL, 129, 24, 50, 14, 0, WS_EX_LEFT DEFPUSHBUTTON "OK", IDOK, 129, 7, 50, 14, 0, WS_EX_LEFT } ---------- resource.h: #ifndef IDC_STATIC #define IDC_STATIC (-1) #endif #define IDD_DIALOG1 100 ---------- Resource is compiled with vc2010's rc.exe. dlg.d is compiled with "dmd dlg.d dlg.res"
Comment #3 by dfj1esp02 — 2021-03-02T06:17:50Z
Probably duplicate of issue 2035, try solution there.
Comment #4 by top398 — 2021-03-03T12:02:51Z
Thank you, it works: dmd dlg.d dlg.res -L/subsystem:windows:5
Comment #5 by dfj1esp02 — 2021-03-03T12:15:27Z
*** This issue has been marked as a duplicate of issue 2035 ***