mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-26 15:53:52 +02:00
Qt5, Qt6: implemented GetDpiForMonitor().
This commit is contained in:
parent
54f0c7e779
commit
ae798b4443
@ -2923,6 +2923,33 @@ begin
|
||||
Result := QApplication_doubleClickInterval;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: GetDpiForMonitor
|
||||
Params: monitor handle, TMonitorDpiType - MDT_EFFECTIVE_DPI only atm
|
||||
Returns: DpiX and DpiY
|
||||
|
||||
DPI per monitor, if returned value ok, result is S_OK.
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.GetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT;
|
||||
var
|
||||
Desktop: QDesktopWidgetH;
|
||||
W: QWidgetH;
|
||||
begin
|
||||
Result := S_FALSE;
|
||||
Desktop := QApplication_desktop();
|
||||
// Note: Monitor is PtrUInt and is always >= 0.
|
||||
if hMonitor > 0 then
|
||||
dec(hMonitor);
|
||||
if hMonitor >= PtrUInt(QDesktopWidget_numScreens(Desktop)) then
|
||||
exit;
|
||||
W := QDesktopWidget_screen(Desktop, hMonitor);
|
||||
if W = nil then
|
||||
W := QDesktopWidget_screen(Desktop, QDesktopWidget_primaryScreen(Desktop));
|
||||
dpiX := QPaintDevice_logicalDpiX(QPaintDeviceH(QWidget_to_QPaintDevice(W)));
|
||||
dpiY := dpiX;
|
||||
Result := S_OK;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: GetFocus
|
||||
Params: None
|
||||
|
@ -105,6 +105,7 @@ function GetDeviceCaps(DC: HDC; Index: Integer): Integer; override;
|
||||
function GetDeviceSize(DC: HDC; var P: TPoint): Boolean; Override;
|
||||
function GetDIBits(DC: HDC; Bitmap: HBitmap; StartScan, NumScans: UINT; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT): Integer; Override;
|
||||
function GetDoubleClickTime: UINT; override;
|
||||
function GetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT; override;
|
||||
function GetFocus: HWND; override;
|
||||
function GetForegroundWindow: HWND; override;
|
||||
function GetKeyState(nVirtKey: Integer): Smallint; override;
|
||||
|
@ -2919,6 +2919,44 @@ begin
|
||||
Result := QApplication_doubleClickInterval;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: GetDpiForMonitor
|
||||
Params: monitor handle, TMonitorDpiType - MDT_EFFECTIVE_DPI only atm.
|
||||
Returns: DpiX and DpiY
|
||||
|
||||
DPI per monitor, if returned value ok, result is S_OK.
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.GetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT;
|
||||
var
|
||||
W: QWidgetH;
|
||||
AScreen: QScreenH;
|
||||
AArray: TPtrIntArray;
|
||||
i: integer;
|
||||
begin
|
||||
Result := S_FALSE;
|
||||
// Note: Monitor is PtrUInt and is always >= 0.
|
||||
if hMonitor > 0 then
|
||||
dec(hMonitor);
|
||||
AScreen := QGuiApplication_primaryScreen();
|
||||
if hMonitor = 0 then
|
||||
begin
|
||||
dpiX := Round(QScreen_logicalDotsPerInch(AScreen));
|
||||
dpiY := dpiX;
|
||||
exit(S_OK);
|
||||
end;
|
||||
QScreen_virtualSiblings(AScreen, @AArray);
|
||||
for i := 0 to High(AArray) do
|
||||
begin
|
||||
if I = hMonitor then
|
||||
begin
|
||||
AScreen := QScreenH(AArray[i]);
|
||||
dpiX := Round(QScreen_logicalDotsPerInch(AScreen));
|
||||
dpiY := dpiX;
|
||||
exit(S_OK);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: GetFocus
|
||||
Params: None
|
||||
|
@ -105,6 +105,7 @@ function GetDeviceCaps(DC: HDC; Index: Integer): Integer; override;
|
||||
function GetDeviceSize(DC: HDC; var P: TPoint): Boolean; Override;
|
||||
function GetDIBits(DC: HDC; Bitmap: HBitmap; StartScan, NumScans: UINT; Bits: Pointer; var BitInfo: BitmapInfo; Usage: UINT): Integer; Override;
|
||||
function GetDoubleClickTime: UINT; override;
|
||||
function GetDpiForMonitor(hmonitor: HMONITOR; dpiType: TMonitorDpiType; out dpiX: UINT; out dpiY: UINT): HRESULT; override;
|
||||
function GetFocus: HWND; override;
|
||||
function GetForegroundWindow: HWND; override;
|
||||
function GetKeyState(nVirtKey: Integer): Smallint; override;
|
||||
|
Loading…
Reference in New Issue
Block a user