Win32 Default Height of Edit Control
Asked Answered
E

1

5

I'm using CreateWindowEx to create an Edit control (a textbox), but saying CW_DEFAULT doesn't help with getting the default height of the textbox -- it just makes a window with a height of zero.

How do I get the system-default size of a textbox, so I can turn Edit control into a normal-looking textbox?

Extrabold answered 5/3, 2011 at 3:30 Comment(1)
That is the documented behavior: "if CW_USEDEFAULT is specified for a pop-up or child window, the nWidth and nHeight parameters are set to zero.". So CW_USEDEFAULT is definitely the wrong approach.Omasum
O
11

The recommended size is 14 dialog units. Here is the reference

You can use MapDialogRect to convert dialog units into pixels.

Omasum answered 5/3, 2011 at 5:4 Comment(2)
Is there any way to get this programmatically? Or do I need to hard-code it into my program?Extrabold
You mean the 14 dialog units, or the number of pixels. Dialog units are defined in terms of the height of a line of text, so that number should be hard-coded. As I said, you then use MapDialogRect to convert to pixels, taking into account the user settings for font size and monitor DPI.Omasum

© 2022 - 2024 — McMap. All rights reserved.