Solved

DPI Change in Dialogs

Posted on 2006-06-13
8
1,174 Views
Last Modified: 2013-11-20
When DPI is changed then the dialog size also changed. how could it be possible to keep it size the same even on DPI change.
Please provide a small code snippet if it can be done.
0
Comment
Question by:ashugarg00
  • 3
8 Comments
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 500 total points
ID: 16892395
When the screen DPI resolution changes, afonts change size and dialogs change size. You may try by setting dialog font to fixed DPI.

Use MoveWindow during OnInitDialog to set the size and position of the dialog in pixels. The resource editor measures everything in "dialog units." You can find out
how many pixels are in a dialog unit by using GetDialogBaseUnits or MapDialogRect.

You may resize your dialog accordingly by converting dialog units to screen units using CDialog::MapDialogRect() function. This converts the dialog-box units of a rectangle to screen units and then set size of dialog to fixed screen units using SetWindowPos() or MoveWindow().
http://msdn2.microsoft.com/en-us/1hb7x4ze.aspx <=

The programmer doesn't need to know the dialog base units. MapDialogRect(..) can be used to convert any dialog template units directly to device coordinates (pixels). The function replaces the coordinates in the specified RECT structure with the converted coordinates.

This function assumes that the initial coordinates in the RECT structure represent dialog template units. To convert these coordinates from dialog template units to pixels, the function retrieves the horizontal and vertical dialog base units of the current font in the dialog box and applies the known formulas (See upper).
above function use system font, for how To Calculate Dialog Base Units with Non-System-Based Font refer :
http://support.microsoft.com/default.aspx?scid=kb;en-us;125681

Also have a look at this :
Fight the dialog units, DPI and Large Fonts
http://www.codeproject.com/wtl/wtlsetdpi.asp <=====

-MAHESH
0
 
LVL 14

Expert Comment

by:puranik_p
ID: 16892519
what id DPI?
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16892673
@puranik_p
DPI = DOT PER INCH ( measurement pixel units )
0
 

Author Comment

by:ashugarg00
ID: 16900736
Thanks, I have manged make my dialog DPI independent for a dialog
But i am not able to do it for a property sheet.
Can u please tell me how to make a property sheet DPI independent.
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16902147
you may also use MapDialogRect with CPropertySheet & CPropertyPage.

-MAHESH
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 136
Folder Comparison 12 54
method notes when mouse over in eclipse 5 86
JQuery serialize and unserialize 8 77
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 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

12 Experts available now in Live!

Get 1:1 Help Now