Link to home
Start Free TrialLog in
Avatar of rakok
rakok

asked on

How to resize Dlgboxes runtime?

I make an application for an embedded device with Windows CE. This device can have several displays, big and little. However, the ratio between the dialog and the screen must be fixed always. So, the dialog must be bigger when the display is bigger.
On the fly (at starting up the application) I determine with GetSystemMetrics() what the size of the screen is. Then I want to change the size of the dialog. (When I change the size of the dialog font in the resource editor, a good result is given; however this is a fixed size for all screens.)
I thought, maybe I can change the size of the dialogfont when the object is constructed, or in OnInitDialog.
I want to resize all components of the dialog box, the fontsize (for all controls) and the metrics of the controls.

My question is: can I do this in combination with the dialog made in the resource editor (and how!), or do I have to make it in a template in memory, to change DS_SETFONT?
I can use FindResource and LoadResource to load the resource, but I need a HMODULE in FindResource, and in Windows CE it can't be NULL.
When I change the size of the font in the resource editor, the controls are resized automaticcaly. Is this really not possible when changing the fontsize in run-time?
Can you me give a piece of code where I load a resource of IDD_DIALOG in a Template and then change the size of the Font fo that template, create the dialog and display it? Or any other manner to reach the same result.

rakok
Avatar of rakok
rakok

ASKER

Adjusted points to 50
Avatar of rakok

ASKER

Adjusted points to 75
1. If you want to change the font, including the dialog base units (the dlg is measured in terms of the font) you need to construct you own resource template

2. If you want to simply resize the dialog, and/or controls you can cheat
i. Use MoveWindow (or any other sizing API) on the dialog itself
ii. Use MoveWindow (or any other sizing API) on the dialog controls
iii. Modify the font of each control by sending WM_SETFONT message to each control
When using (i) and (ii) - with GetWindowRect etc.  watch out for screen/client rect coordinates, and use ScreenToClient (etc.) to convert em.  All this sizing stuff can be done when the dialog is active, e.g. OnInitDialog

Avatar of rakok

ASKER

I have tried your comment. Most of it works, but the comboboxes and checkboxes remain the same size (the spinbutton and the box of the checkbox). I think because of the DBU fo the default font.

ASKER CERTIFIED SOLUTION
Avatar of SileNcer
SileNcer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rakok

ASKER

It's a good answer. But when I resize Comboboxes, the spinbutton remains the same width. Also checkboxes are not goot scaled, so I think it's not good usable for all controls. I don't understand why it can't be good! So I can't use it for my dialog-boxes.

Roeland