Solved

DPI Change in Dialogs

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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