I am working on making my DPI application sensitive using this MSDN guide , where the zoom technique uses the logical pixels X and Y from the device context.
int _dpiX = 96, _pdiY = 96;
HDC hdc = GetDC(NULL);
if (hdc)
{
_dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
_dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
}
Then you can scale the X and Y coordinates using
int ScaleX(int x) { return MulDiv(x, _dpiX, 96); }
int ScaleY(int y) { return MulDiv(y, _dpiY, 96); }
Is there a situation where GetDeviceCaps(hdc, LOGPIXELSX)they GetDeviceCaps(hdc, LOGPIXELSY)will return different numbers for the monitor. The only device I'm really worried about is the monitor, so do I need to have separate functions ScaleX(int x)and ScaleY(int y)? Can I use only one function Scale(int px)? Will there be a flaw in this?
Thanks in advance for your help.
source
share