diff --git a/lcl/interfaces/qt/qtobjects.pas b/lcl/interfaces/qt/qtobjects.pas index 4fcf84b9e8..f8d1ebd641 100644 --- a/lcl/interfaces/qt/qtobjects.pas +++ b/lcl/interfaces/qt/qtobjects.pas @@ -361,6 +361,7 @@ type function setPen(APen: TQtPen): TQtPen; function SetBkColor(Color: TcolorRef): TColorRef; function SetBkMode(BkMode: Integer): Integer; + function getDepth: integer; function getDeviceSize: TPoint; function getRegionType(ARegion: QRegionH): integer; function getClipRegion: TQtRegion; @@ -2683,6 +2684,13 @@ begin end; end; +function TQtDeviceContext.getDepth: integer; +var + device: QPaintDeviceH; +begin + Result := QPaintDevice_depth(Device); +end; + function TQtDeviceContext.getDeviceSize: TPoint; var device: QPaintDeviceH; diff --git a/lcl/interfaces/qt/qtwinapi.inc b/lcl/interfaces/qt/qtwinapi.inc index 59e7668cb5..0b96fee30d 100644 --- a/lcl/interfaces/qt/qtwinapi.inc +++ b/lcl/interfaces/qt/qtwinapi.inc @@ -143,7 +143,7 @@ begin {$ifdef VerboseQtWinAPI_MISSING_IMPLEMENTATION} WriteLn('***** [WinAPI TQtWidgetSet.CallWindowProc] missing implementation '); {$endif} - Result := 0; + Result := -1; end; {------------------------------------------------------------------------------ @@ -272,16 +272,52 @@ end; {------------------------------------------------------------------------------ Method: TQtWidgetSet.CreateCompatibleBitmap - Params: - Returns: + Params: HDC, Width & Height + Returns: HBITMAP ------------------------------------------------------------------------------} function TQtWidgetSet.CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP; +var + QtDC: TQtDeviceContext; + Format: QImageFormat = QImageFormat_ARGB32; + ADevice: QPaintDeviceH = nil; + ADesktop: QDesktopWidgetH = nil; begin - {$ifdef VerboseQtWinAPI_MISSING_IMPLEMENTATION} - WriteLn('***** [WinAPI TQtWidgetSet.CreateCompatibleBitmap] missing implementation '); + {$ifdef VerboseQtWinAPI} + WriteLn('Trace:> [WinAPI CreateCompatibleBitmap]', + ' DC:', dbghex(DC), + ' Width:', dbgs(Width), + ' Height:', dbgs(Height)); {$endif} Result := 0; + if IsValidDC(DC) then + begin + QtDC := TQtDeviceContext(DC); + case QtDC.getDepth of + 1: Format := QImageFormat_Mono; + 15, 16: Format := QImageFormat_RGB16; + 24: Format := QImageFormat_RGB32; + 32: Format := QImageFormat_ARGB32; + end; + end else + begin + ADesktop := QApplication_desktop(); + if ADesktop <> nil then + ADevice := QWidget_to_QPaintDevice(ADesktop); + if ADevice <> nil then + begin + case QPaintDevice_depth(ADevice) of + 1: Format := QImageFormat_Mono; + 15, 16: Format := QImageFormat_RGB16; + 24: Format := QImageFormat_RGB32; + 32: Format := QImageFormat_ARGB32; + end; + end; + end; + Result := HBitmap(TQtImage.Create(nil, Width, Height, Format)); + {$ifdef VerboseQtWinAPI} + WriteLn('Trace:< [WinAPI CreateCompatibleBitmap] Bitmap:', dbghex(Result)); + {$endif} end; {------------------------------------------------------------------------------