Solved

DPI Change in Dialogs

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maven archtype selection in eclipse 1 51
Fibonacci challenge 11 82
Path of Workbook 3 45
Change to event 1 73
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 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

19 Experts available now in Live!

Get 1:1 Help Now