Re: CButton and CEdit control's size is different between 96 DPI and 120 DPI for the same number of pixels
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 01 Feb 2007 22:47:54 -0500
I should add that I hope your display driver doesn't lie to you (many do).
joe
On Thu, 01 Feb 2007 22:02:37 -0500, Joseph M. Newcomer <newcomer@xxxxxxxxxxxx> wrote:
WM_DISPLAYCHANGE is sent when properties of the display; change. If you want to resizeJoseph M. Newcomer [MVP]
the buttons to be the "same" size, you have to know what size they were before. So, you
subclass the buttons, in the PreSubclassWindow you get a DC to the screen, use
GetDeviceCaps to get the number of pixels per inch, and compute a nominal physical width
and height, represented by the button width and the LOGPIXELS[X|Y] value. Then, on a
change, you would have to broadcast this down from your top-level window and each control
would get the new LOGPIXELS[X|Y] value, and apply the appropriate arithmetic to compute
the new size. Of course, you have to make sure that the controls all fit on the dialog,
and you have to resize the dialog, to the limits of the screen size. Lots of tedious
geometry going on. Look on codeproject for layout management libraries.
Note that for some settings, such as font change, you will have to deal with the fact that
text in the new font may not fit, particularly vertically. So you will have to resize the
dialog to handle this case as well.
joe
On Thu, 01 Feb 2007 09:05:17 -0500, "Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp>
wrote:
Charlie Hoo wrote:Joseph M. Newcomer [MVP]
Hello, Scott,
Thank you for your reply. When DPI is changed from 96 to 120, the size of
buttons in IE is not changed, could you tell me how to do it?
Actually I am using MoveWindow at runtime to change the size (in pixels) of
any control when resized, but it seems not working for changing DPI.
Thanks again for your help.
Charlie
The buttons in IE are not the standard button control. They are simply
images on the toolbar window. The size does not change when DPI is
changed because they use images, not the system font. To use this kind
of toolbar yourself lookup "ToolbarWindow32" or CToolbar.
For resizing your standard buttons, I would suppose that a message is
sent to your application when DPI is changed. I don't know what
message, but you could investigate this with the Spy++ tool to discover
the message and where it is received, then you could resize when you
receive the message.
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Re: CButton and CEdit control's size is different between 96 DPI and 120 DPI for the same number of pixels
- From: Charlie Hoo
- Re: CButton and CEdit control's size is different between 96 DPI and 120 DPI for the same number of pixels
- From: Scott McPhillips [MVP]
- Re: CButton and CEdit control's size is different between 96 DPI and 120 DPI for the same number of pixels
- From: Joseph M . Newcomer
- Re: CButton and CEdit control's size is different between 96 DPI and 120 DPI for the same number of pixels
- Prev by Date: Re: mfc pitfalls
- Next by Date: Re: Substring of Unicode Characters
- Previous by thread: Re: CButton and CEdit control's size is different between 96 DPI and 120 DPI for the same number of pixels
- Next by thread: MFC Dialog Based COM Server Falling Over
- Index(es):