How to set Win32 window size in pixels?

I am trying to get a Win32 dialog with a size of 500x520 pixels, but in my .rc file these settings allow me to enlarge the window than I expected.

IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 500, 520
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX

Is there a zoom factor somewhere?

+3
source share
1 answer

The units in the dialog resource are dialog blocks that are normalized by the font size of the dialog using a rather complicated process. You can convert from dialogs to screen pixels with MapDialogRect().

The documentation for GetDialogBaseUnits()there is more detailed information, but the recommended approach is to call MapDialogRect()and let it do the hard work for you.

+5
source

All Articles