Solved

How to resize Dlgboxes runtime?

Posted on 1998-10-19
6
340 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:rakok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 

Author Comment

by:rakok
ID: 1323512
Adjusted points to 50
0
 

Author Comment

by:rakok
ID: 1323513
Adjusted points to 75
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1323514
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

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rakok
ID: 1323515
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.

0
 

Accepted Solution

by:
SileNcer earned 70 total points
ID: 1323516
Hmmm, It sounds to me like you could use a combination of functions.  If you want to actually change the size of the dialog you could use SetWindowPos(0,0,Xmax,Ymax) and then center it again with CenterWindow(NULL);

To change your actual font sizes, use the CreateFont() function and set your checkboxs to this font.  Remember that the computer that runs it needs the font too.

//Put this in the header
CFont m_fontCheck1;

//put this in the .cpp
m_fontCheck1.CreateFont( 35, 14, 0, 0, 700, 0, 0, 0, 1, 0, 0, 0, 0, _T("MS Sans Serif") );

CEdit *pCheck1 = (CEdit *) GetDlgItem(IDC_YourCheckBox);
pCheck1->SetFont( &m_fontCheck1 );




0
 

Author Comment

by:rakok
ID: 1323517
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question