Scaling vs Font setting

From: Balboos (balboos_at_masonicbrother.com.No.Spam)
Date: 03/05/04


Date: Fri, 05 Mar 2004 14:53:08 GMT

Hi,

I had a nice scaling routine (code below), used to convert a dialog from
it's design time resolution to the current screen resolution, as full
screen. Then I discovered, quite accidentally, that if I changed the
windows font selection group from 'small fonts' to 'large fonts', it
scaled incorrectly, running off the screen in both directions.

Is there a cure for this?

Balboos

void CScaleDialog::RescaleWindow(CWnd *pDlg, int x0, int y0, int x, int y) {
// This method uses predefined x/y coorordinates for the scaling. The
initial
// values are the design-time resolution (x0, y0), while the new screen
// resolution is put into (x, y). Leaving out x and/or y triggers the
default
// mechanism, which get the current screen resolution. There is a handler
// for the ComboBox, which has two sets of dimension (normal, dropped).
// Steven S. Miller Feb 26,
2004

int xNew, yNew; // new dimensions of the control
// Use values from constructor, if available
   if(x0<=0) x0 = designHres;
   if(y0<=0) y0 = designVres;
// Get current screen resolution 'on the fly'
   if(x<=0 || y<=0) { // handle 'defaults' (or errors?)
                  x = runHres = GetSystemMetrics(SM_CXSCREEN);
                y = runVres = GetSystemMetrics(SM_CYSCREEN);
   } // end: if(x<=0 || y<=0)
// Get scaling factors (ration of current:design resolution).
   xScale = (double)x/(double)x0;
   yScale = (double)y/(double)y0;

// A handle to the child window(s) - each control is a window
CWnd *pDlgItem = pDlg->GetWindow(GW_CHILD);

   while(pDlgItem) {
     if(pDlgItem->GetSafeHwnd() != NULL) { /* resize it */
        tagRECT rCombo;
        CRuntimeClass *rtc = pDlgItem->GetRuntimeClass();
// unsigned di = pDlgItem->GetDlgCtrlID();
        pDlgItem->GetWindowPlacement(&r0); // we are assuming this is
properly scaled!
        if(!stricmp(rtc->m_lpszClassName, "CComboBox")) { // special
handler for combo box
          ((CComboBox *)pDlgItem)->GetDroppedControlRect(&rCombo);
          r0.rcNormalPosition.bottom = rCombo.bottom;
        } // end: if(!stricmp(rtc->m_lpszClassName, "CComboBox"))
        // Get New height, width
        xNew = r0.rcNormalPosition.right - r0.rcNormalPosition.left;
        yNew = r0.rcNormalPosition.bottom - r0.rcNormalPosition.top;
        r.rcNormalPosition.left =
(int)(r0.rcNormalPosition.left*xScale); // x shift
        r.rcNormalPosition.top =
(int)(r0.rcNormalPosition.top*yScale); // y shift
        r.rcNormalPosition.right = r.rcNormalPosition.left +
(int)(xNew*xScale); // x scale
        r.rcNormalPosition.bottom = r.rcNormalPosition.top +
(int)(yNew*yScale); // y scale
        pDlgItem->SetWindowPlacement(&r); // we are assuming this is
properly scaled!
        // Continue looping through controls
        pDlgItem = pDlgItem->GetNextWindow();
     } // end: if(pDlgItem->GetSafeHwnd() != NULL)
   } // end: while(pDlgItem)

return;
} // void RescaleWindow(CWnd *pDlg, int x0, int y0, int x, int y)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * */



Relevant Pages

  • Re: Automatic updates changing screen resolution
    ... And it won't let me reset it. ... 'Dell notebook, Vista, and Screen Resolution | Ask Metafilter' ... The actual culprit is TMM, Vista's process that looks for multiple ... Uncheck the box under Settings at "Run in 640 X 480 screen resolution. ...
    (microsoft.public.windows.vista.general)
  • Re: How to change gdm screen resolution?
    ... My default screen resolution is 1400x1050, and in gdm greeting screen, ... How to change the gdm settings to the LCD native resolution? ... Ubuntu is different from other distributions, ...
    (Ubuntu)
  • Re: Maximizing Resolution
    ... >> Steve Easton ... I do not want to change the viewers resolution on ... >> must want my site to fill the width of their viewing area that they are ... I do not want to change their screen resolution each ...
    (microsoft.public.frontpage.programming)
  • Font size when changing screen resolution
    ... changing the screen resolution in Display Properties. ... In order to draw the text I have converted the font point size specified by ... seems to draw at the correct size in my native resolution of 1280x1024. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Playing a metafile on top of another metafile -> Disappearing lines
    ... screen resolution be "optimized"? ... context you are rendering to. ... top of another metafile. ... my screen resolution to 1280x720 and create the metafile again, ...
    (microsoft.public.win32.programmer.gdi)