Designing MFC dialog in real pixels

Started by
3 comments, last by davidcoleman 15 years, 1 month ago
Now my dialog is 800 units wide, but it is in fact around 1200pixel wide How to switch to real units and also make sure on different systems and font sizes that it will look the same?
Advertisement
Quote:Original post by davidcoleman

Now my dialog is 800 units wide, but it is in fact around 1200pixel wide

How to switch to real units and also make sure on different systems and font sizes that it will look the same?


Google's First result shows that:
horz pixels == 2 * horz dialog units * (average char width  of dialog font                        / average char width of system font)vert pixels == 2 * vert dialog units * (average char height of dialog font                        / average char height of system font)

As for making it look the same on different systems and font sizes, you shouldn't have to worry about that - the dialog box is supposed to resize according to the dialog font. And if it doesn't work, then it's the user's fault for using a ridiculous font.
No I meant seeing real values when designing the dialog in dialog editor.
For example I want fixed size dialog 1024x768 on the screen and be able to move around elements also of fixed size...
In your WM_INITDIALOG message handler, you'd have to resize the dialog, and enumerate all child windows and reposition (and scale if you want) them too. Just calling EnumChildWindows() will let you find all the controls, and then you'll need to scale their position based on the difference in size of the dialog.

EDIT: Assuming Win32 / C++ that is.

But why do you want to do this?
Maybe I was not clear enough...

I have a dialog with a lot of buttons, radios, pictureboxes with particular sizes and I need to organize it on the dialog so I am trying to do it in resource editor, but in the bottom of the resource editor is written 800x477 but the dialog is 1206xSomething, and I need it to be 1024x768 in real pixels.
After I run the app and picture of 120x90 is loaded into picturebox I see that it covers some button, and if I had this box with this size in resource editor I would move the button away... so I have to constantly compile to see if elements are not overlapping

I use VS2005 and c++

This topic is closed to new replies.

Advertisement