
There are three main things to check and possibly change. First you need to load your resource script (.rc file) into your favourite text editor. Notepad works fine. Find the dialog resources. They should read something like this:
IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 186, 90
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
The first things you need to do is change the dialog font from MS Sans Serif to MS Shell Dlg. MS Shell Dlg isn't a font, it's a mapping to the system font which is probably Tahoma. Now this value will actually be ignored unless two other conditions are met. Firstly, the dialog template must be DIALOGEX instead of DIALOG. Secondly, the dialog must have two additional styles, so you should add DS_FIXEDSYS which will include them both. So you should end up with:
IDD_DIALOG1 DIALOGEX DISCARDABLE 0, 0, 186, 90
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_FIXEDSYS
CAPTION "Dialog"
FONT 8, "MS Shell Dlg"
Note that if you edit a dialog in the IDE it might lose the DIALOGEX template. It will keep the font and the styles, but you may need to re-edit the resources by hand then have the IDE reload them if you want to move controls about. Also the IDE won't render the font correctly so sometimes you have to "guess" how big a control needs to be to contain the text you need.

There are still sometimes that dialogs will look wrong, especially related to property sheets. Some types of MFC property sheets (and other MFC dialogs) use DIALOG templates so property pages may not always display correctly. And by using DIALOGEX you are effectively preventing your software from running on Win32s on Windows 3.x. But I think the benefits outweigh those limitations.
No comments:
Post a Comment