?
Solved

How to resize Dlgboxes runtime?

Posted on 1998-10-19
6
Medium Priority
?
341 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
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 

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 210 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

764 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