Einzelnen Beitrag anzeigen

Benutzerbild von ULIK
ULIK

Registriert seit: 25. Sep 2006
Ort: Regensburg
416 Beiträge
 
Delphi 11 Alexandria
 
#14

AW: Delphi 11 -GetSystemMetrics( SM_CXSIZEFRAME ) ermittelt andere Werte

  Alt 25. Okt 2021, 10:44
[QUOTE=venice2;1496562]
Zitat:
...
Code:
long dpi(IN long nPix) {
    static float ratio;
    if (ratio == 0) {
        HDC hDC = GetDC(0); ratio = (GetDeviceCaps(hDC, LOGPIXELSX) / 96.0f); ReleaseDC(0, hDC);
    }
    return (long)(nPix * ratio);
}
//...
SetRect(&rc, 0, 0, dpi(XXX), dpi(YYY));
Dafür benötige ich keine extra VS High DPI Programmierumgebung das macht man von Hand. Kann das niemand mehr?
Nur mal so bemerkt: Dir ist aber schon bewußt, daß auf einem Multimonitorsystem und DPI Awareness V2, GetDeviceCaps ebenfalls mit Vorsicht zu genießen ist? Hier einmal ein Auszug aus der MS-Doku:
Zitat:
On a multiple monitor system, if hdc is the desktop, GetDeviceCaps returns the capabilities of the primary monitor. If you want info for other monitors, you must use the multi-monitor APIs or CreateDC to get a HDC for the device context (DC) of a specific monitor.
  Mit Zitat antworten Zitat