View Issue Details

IDProjectCategoryView StatusLast Update
0036574PatchesWidgetsetpublic2020-01-14 17:22
ReporterYuriy SydorovAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0036574: [patch] CustomDrawn: Fixed crash on startup
DescriptionThe patch implements basic versions of EnumDisplayMonitors() and GetMonitorInfo(). It prevents crash on startup.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetCustomDrawn
Attached Files
  • customdrawn_monitor.patch (4,105 bytes)
    Index: lcl/interfaces/customdrawn/customdrawnwinapi.inc
    ===================================================================
    --- lcl/interfaces/customdrawn/customdrawnwinapi.inc	(revision 62551)
    +++ lcl/interfaces/customdrawn/customdrawnwinapi.inc	(working copy)
    @@ -1508,22 +1508,13 @@
       System.EnterCriticalsection(ACritSec^);
     end;
     
    -(*function TQtWidgetSet.EnumDisplayMonitors(hdc: HDC; lprcClip: PRect;
    +function TCDWidgetSet.EnumDisplayMonitors(hdc: HDC; lprcClip: PRect;
       lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool;
    -var
    -  i: integer;
    -  Desktop: QDesktopWidgetH;
     begin
    -  Desktop := QApplication_desktop();
    -  Result := True;
    -  for i := 0 to QDesktopWidget_numScreens(Desktop) - 1 do
    -  begin
    -    Result := Result and lpfnEnum(i + 1, 0, nil, dwData);
    -    if not Result then break;
    -  end;
    +  Result := lpfnEnum(1, 0, nil, dwData);
     end;
     
    -
    +(*
     function CharsetToQtCharSet(const ALCLCharset: Byte): QFontDatabaseWritingSystem;
     begin
       Result := QFontDatabaseAny;
    @@ -2909,25 +2900,16 @@
       else
         Result := 0;
     end;
    -
    -function TQtWidgetSet.GetMonitorInfo(Monitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
    -var
    -  Desktop: QDesktopWidgetH;
    +*)
    +function TCDWidgetSet.GetMonitorInfo(Monitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
     begin
    -  Result := (lpmi <> nil) and (lpmi^.cbSize >= SizeOf(TMonitorInfo)) or (Monitor = 0);
    +  Result := (lpmi <> nil) and (lpmi^.cbSize >= SizeOf(TMonitorInfo)) or (Monitor <> 1);
       if not Result then Exit;
    -  Desktop := QApplication_desktop();
    -  Dec(Monitor);
    -  Result := (Monitor >= 0) and (Monitor < PtrUInt(QDesktopWidget_numScreens(Desktop)));
    -  if not Result then Exit;
    -  QDesktopWidget_screenGeometry(Desktop, @lpmi^.rcMonitor, Monitor);
    -  QDesktopWidget_availableGeometry(Desktop, @lpmi^.rcWork, Monitor);
    -  if PtrUInt(QDesktopWidget_primaryScreen(Desktop)) = Monitor then
    -    lpmi^.dwFlags := MONITORINFOF_PRIMARY
    -  else
    -    lpmi^.dwFlags := 0;
    +  lpmi^.rcMonitor:=Types.Rect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
    +  lpmi^.rcWork:=lpmi^.rcMonitor;
    +  lpmi^.dwFlags := MONITORINFOF_PRIMARY
     end;
    -
    +(*
     {------------------------------------------------------------------------------
       Method:  TQtWidgetSet.GetDeviceSize
       Params:  none
    Index: lcl/interfaces/customdrawn/customdrawnwinapih.inc
    ===================================================================
    --- lcl/interfaces/customdrawn/customdrawnwinapih.inc	(revision 62551)
    +++ lcl/interfaces/customdrawn/customdrawnwinapih.inc	(working copy)
    @@ -83,7 +83,7 @@
     function EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; override;
     function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;*)
     procedure EnterCriticalSection(var CritSection: TCriticalSection); override;
    -//function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool; override;
    +function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool; override;
     function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
     //function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
     function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
    @@ -118,9 +118,9 @@
     function GetFocus: HWND; override;
     (*function GetForegroundWindow: HWND; override;*)
     function GetKeyState(nVirtKey: Integer): Smallint; override;
    -(*function GetMapMode(DC: HDC): Integer; override;
    +//function GetMapMode(DC: HDC): Integer; override;
     function GetMonitorInfo(Monitor: HMONITOR; lpmi: PMonitorInfo): Boolean; override;
    -function GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer; override;*)
    +//function GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer; override;
     function GetParent(Handle : HWND): HWND; override;
     function GetProp(Handle : hwnd; Str : PChar): Pointer; override;
     function GetRgnBox(RGN : HRGN; lpRect : PRect) : Longint; override;
    

Activities

Yuriy Sydorov

2020-01-14 17:20

developer  

customdrawn_monitor.patch (4,105 bytes)
Index: lcl/interfaces/customdrawn/customdrawnwinapi.inc
===================================================================
--- lcl/interfaces/customdrawn/customdrawnwinapi.inc	(revision 62551)
+++ lcl/interfaces/customdrawn/customdrawnwinapi.inc	(working copy)
@@ -1508,22 +1508,13 @@
   System.EnterCriticalsection(ACritSec^);
 end;
 
-(*function TQtWidgetSet.EnumDisplayMonitors(hdc: HDC; lprcClip: PRect;
+function TCDWidgetSet.EnumDisplayMonitors(hdc: HDC; lprcClip: PRect;
   lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool;
-var
-  i: integer;
-  Desktop: QDesktopWidgetH;
 begin
-  Desktop := QApplication_desktop();
-  Result := True;
-  for i := 0 to QDesktopWidget_numScreens(Desktop) - 1 do
-  begin
-    Result := Result and lpfnEnum(i + 1, 0, nil, dwData);
-    if not Result then break;
-  end;
+  Result := lpfnEnum(1, 0, nil, dwData);
 end;
 
-
+(*
 function CharsetToQtCharSet(const ALCLCharset: Byte): QFontDatabaseWritingSystem;
 begin
   Result := QFontDatabaseAny;
@@ -2909,25 +2900,16 @@
   else
     Result := 0;
 end;
-
-function TQtWidgetSet.GetMonitorInfo(Monitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
-var
-  Desktop: QDesktopWidgetH;
+*)
+function TCDWidgetSet.GetMonitorInfo(Monitor: HMONITOR; lpmi: PMonitorInfo): Boolean;
 begin
-  Result := (lpmi <> nil) and (lpmi^.cbSize >= SizeOf(TMonitorInfo)) or (Monitor = 0);
+  Result := (lpmi <> nil) and (lpmi^.cbSize >= SizeOf(TMonitorInfo)) or (Monitor <> 1);
   if not Result then Exit;
-  Desktop := QApplication_desktop();
-  Dec(Monitor);
-  Result := (Monitor >= 0) and (Monitor < PtrUInt(QDesktopWidget_numScreens(Desktop)));
-  if not Result then Exit;
-  QDesktopWidget_screenGeometry(Desktop, @lpmi^.rcMonitor, Monitor);
-  QDesktopWidget_availableGeometry(Desktop, @lpmi^.rcWork, Monitor);
-  if PtrUInt(QDesktopWidget_primaryScreen(Desktop)) = Monitor then
-    lpmi^.dwFlags := MONITORINFOF_PRIMARY
-  else
-    lpmi^.dwFlags := 0;
+  lpmi^.rcMonitor:=Types.Rect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
+  lpmi^.rcWork:=lpmi^.rcMonitor;
+  lpmi^.dwFlags := MONITORINFOF_PRIMARY
 end;
-
+(*
 {------------------------------------------------------------------------------
   Method:  TQtWidgetSet.GetDeviceSize
   Params:  none
Index: lcl/interfaces/customdrawn/customdrawnwinapih.inc
===================================================================
--- lcl/interfaces/customdrawn/customdrawnwinapih.inc	(revision 62551)
+++ lcl/interfaces/customdrawn/customdrawnwinapih.inc	(working copy)
@@ -83,7 +83,7 @@
 function EnableWindow(hWnd: HWND; bEnable: Boolean): Boolean; override;
 function EndPaint(Handle: hwnd; var PS: TPaintStruct): Integer; override;*)
 procedure EnterCriticalSection(var CritSection: TCriticalSection); override;
-//function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool; override;
+function EnumDisplayMonitors(hdc: HDC; lprcClip: PRect; lpfnEnum: MonitorEnumProc; dwData: LPARAM): LongBool; override;
 function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
 //function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;
 function ExtCreatePen(dwPenStyle, dwWidth: DWord; const lplb: TLogBrush; dwStyleCount: DWord; lpStyle: PDWord): HPEN; override;
@@ -118,9 +118,9 @@
 function GetFocus: HWND; override;
 (*function GetForegroundWindow: HWND; override;*)
 function GetKeyState(nVirtKey: Integer): Smallint; override;
-(*function GetMapMode(DC: HDC): Integer; override;
+//function GetMapMode(DC: HDC): Integer; override;
 function GetMonitorInfo(Monitor: HMONITOR; lpmi: PMonitorInfo): Boolean; override;
-function GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer; override;*)
+//function GetObject(GDIObj: HGDIOBJ; BufSize: Integer; Buf: Pointer): Integer; override;
 function GetParent(Handle : HWND): HWND; override;
 function GetProp(Handle : hwnd; Str : PChar): Pointer; override;
 function GetRgnBox(RGN : HRGN; lpRect : PRect) : Longint; override;

Issue History

Date Modified Username Field Change
2020-01-14 17:20 Yuriy Sydorov New Issue
2020-01-14 17:20 Yuriy Sydorov File Added: customdrawn_monitor.patch
2020-01-14 17:22 Yuriy Sydorov Product Version => 2.1 (SVN)
2020-01-14 17:22 Yuriy Sydorov LazTarget => -
2020-01-14 17:22 Yuriy Sydorov Widgetset CustomDrawn => CustomDrawn