olilarkin
olilarkin

Reputation: 460

How can I set the size of a Win32 dialog in pixels?

I am trying to get a Win32 dialog that is 500x520 px, but in my .rc file, these settings get me a bigger 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 scaling factor somewhere?

Upvotes: 3

Views: 5369

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

The units in a dialog resource are dialog units which are normalized by the dimensions of the dialog font by a rather convoluted process. You can convert from dialog units to screen pixels with MapDialogRect().

There are lots more details in the documentation for GetDialogBaseUnits() but the recommended approach is to call MapDialogRect() and let it do the hard work for you.

Upvotes: 7

Related Questions