Solved

DPI Change in Dialogs

Posted on 2006-06-13
8
1,163 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumDigits challenge 9 125
notReplace  challenge 53 116
isEverywhere  challenge 19 72
Problem to event 3 78
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

13 Experts available now in Live!

Get 1:1 Help Now