Solved

How to resize Dlgboxes runtime?

Posted on 1998-10-19
6
331 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
  • 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

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 (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now