?
Solved

DPI Change in Dialogs

Posted on 2006-06-13
8
Medium Priority
?
1,221 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
[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
  • 3
8 Comments
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

762 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