View Issue Details

IDProjectCategoryView StatusLast Update
0017249LazarusLCLpublic2013-04-13 16:57
ReporterZaher DirkeyAssigned ToFelipe Monteiro de Carvalho 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformWINCEOSWINCEOS Version
Product VersionProduct Build 
Target VersionFixed in Version0.9.29 (SVN) 
Summary0017249: ClipRect, ExcludeClipRect not work after SetWindowOrgExt
DescriptionPaintControls move the window org (MoveWindowOrg) to make the TGraphicControl can draw started from 0,0 of it self.
ClipRect, ExcludeClipRect not work with this offset, it still return value with original coordinates.
With the patch attachment, it correct the Rect of (ClipRect, ExcludeClipRect) in WinCE widgets, tested in WM5 and WM6.1 and WM6.5

This patch effect only to who use TGraphicControl with ClipRect, ExcludeClipRect

Related to
http://lazarus.freepascal.org/index.php/topic,10237.0.html

http://bugs.freepascal.org/view.php?id=0014857
http://bugs.freepascal.org/view.php?id=15654
Tagscliprect, paint, wince
Fixed in Revision27173, 27244
LazTarget-
WidgetsetWinCE
Attached Files
  • ClipRect.patch (1,134 bytes)
    Index: interfaces/wince/wincewinapi.inc
    ===================================================================
    --- interfaces/wince/wincewinapi.inc	(revision 27167)
    +++ interfaces/wince/wincewinapi.inc	(working copy)
    @@ -1181,7 +1181,16 @@
     
      ------------------------------------------------------------------------------}
     function TWinCEWidgetSet.ExcludeClipRect(dc: hdc;  Left, Top, Right, Bottom: Integer): Integer;
    +var
    +  P: TPoint;
     begin
    +  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
    +  begin
    +    Left := Left + P.x;
    +    Top := Top + P.y;
    +    Right := Right + P.x;
    +    Bottom := Bottom + P.y;
    +  end;
       Result := Windows.ExcludeClipRect(dc, Left, Top, Right, Bottom);
     end;
     
    @@ -1432,8 +1441,12 @@
     
      ------------------------------------------------------------------------------}
     function TWinCEWidgetSet.GetClipBox(DC : hDC; lpRect : PRect) : Longint;
    +var
    +  P: TPoint;
     begin
       Result := Windows.GetClipBox(DC, Windows.LPRECT(lpRect));
    +  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
    +    OffsetRect(lpRect^, -P.x, -P.y);
     end;
     
     {------------------------------------------------------------------------------
    
    ClipRect.patch (1,134 bytes)
  • UseSetViewPortEx.patch (2,437 bytes)
    Index: wincewinapi.inc
    ===================================================================
    --- wincewinapi.inc	(revision 27173)
    +++ wincewinapi.inc	(working copy)
    @@ -1181,17 +1181,7 @@
     
      ------------------------------------------------------------------------------}
     function TWinCEWidgetSet.ExcludeClipRect(dc: hdc;  Left, Top, Right, Bottom: Integer): Integer;
    -var
    -  P: TPoint;
     begin
    -  // Fixes the following bug: http://bugs.freepascal.org/view.php?id=17249
    -  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
    -  begin
    -    Left := Left + P.x;
    -    Top := Top + P.y;
    -    Right := Right + P.x;
    -    Bottom := Bottom + P.y;
    -  end;
       Result := Windows.ExcludeClipRect(dc, Left, Top, Right, Bottom);
     end;
     
    @@ -1442,13 +1432,8 @@
     
      ------------------------------------------------------------------------------}
     function TWinCEWidgetSet.GetClipBox(DC : hDC; lpRect : PRect) : Longint;
    -var
    -  P: TPoint;
     begin
       Result := Windows.GetClipBox(DC, Windows.LPRECT(lpRect));
    -  // Fixes the following bug: http://bugs.freepascal.org/view.php?id=17249
    -  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
    -    OffsetRect(lpRect^, -P.x, -P.y);
     end;
     
     {------------------------------------------------------------------------------
    @@ -2025,6 +2010,18 @@
       {$endif}
     end;
     
    +function TWinCEWidgetSet.MoveWindowOrgEx(dc : hdc; dX,dY : Integer): boolean;
    +var
    +  P: TPoint;
    +  lResult: Integer;
    +Begin
    +  lResult := GetViewPortOrgEx(dc, @P);
    +  if lResult <> 0 then
    +    Result := SetViewPortOrgEx(dc, P.x+dX, P.y+dY, @P)
    +  else
    +    Result := False;
    +end;
    +
     { This routine isn't used directly by the LCL
       We implent it with SetViewPortOrgEx because GetViewPortOrgEx is
       only available in Windows Mobile 5.0 +
    Index: wincewinapih.inc
    ===================================================================
    --- wincewinapih.inc	(revision 27173)
    +++ wincewinapih.inc	(working copy)
    @@ -142,6 +142,7 @@
     function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; override;
     function GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;  override;
     function GetViewPortExtEx(DC: HDC; Size: PSize): Integer; override;
    +function MoveWindowOrgEx(dc : hdc; dX,dY : Integer): boolean; override;
     function GetViewPortOrgEx(DC: HDC; P: PPoint): Integer; override;
     function GetWindowExtEx(DC: HDC; Size: PSize): Integer; override;
     function GetWindowLong(Handle : hwnd; int: Integer): PtrInt; override;
    
    UseSetViewPortEx.patch (2,437 bytes)

Relationships

related to 0024107 assignedStephano WinCE: ClipRect of controls not working correctly 

Activities

2010-08-23 20:31

 

ClipRect.patch (1,134 bytes)
Index: interfaces/wince/wincewinapi.inc
===================================================================
--- interfaces/wince/wincewinapi.inc	(revision 27167)
+++ interfaces/wince/wincewinapi.inc	(working copy)
@@ -1181,7 +1181,16 @@
 
  ------------------------------------------------------------------------------}
 function TWinCEWidgetSet.ExcludeClipRect(dc: hdc;  Left, Top, Right, Bottom: Integer): Integer;
+var
+  P: TPoint;
 begin
+  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
+  begin
+    Left := Left + P.x;
+    Top := Top + P.y;
+    Right := Right + P.x;
+    Bottom := Bottom + P.y;
+  end;
   Result := Windows.ExcludeClipRect(dc, Left, Top, Right, Bottom);
 end;
 
@@ -1432,8 +1441,12 @@
 
  ------------------------------------------------------------------------------}
 function TWinCEWidgetSet.GetClipBox(DC : hDC; lpRect : PRect) : Longint;
+var
+  P: TPoint;
 begin
   Result := Windows.GetClipBox(DC, Windows.LPRECT(lpRect));
+  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
+    OffsetRect(lpRect^, -P.x, -P.y);
 end;
 
 {------------------------------------------------------------------------------
ClipRect.patch (1,134 bytes)

Felipe Monteiro de Carvalho

2010-08-23 21:01

developer   ~0040423

Thanks, applied

Zaher Dirkey

2010-08-23 21:54

reporter   ~0040425

Tested in I-Mate WM5, Sony X1 WM6.1 with hires and worked, Thanks

Zaher Dirkey

2010-08-31 13:12

reporter   ~0040676

Last edited: 2010-08-31 13:17

Hi again, this patch worked on WinCE 5.1 + not WinCE 5.0 and less.

I worked on old WinCE that have missed some function like SetWindowOrgEx, it is not work at all, but i found the problem
In old Lazarus with WinCE it use SetViewPortOrg instead of SetWindowOrg, so i test the API of it and replace MoveWindowOrgEx (In wince wedgetset) to use SetViewPortOrgEx, after test on WinCE 5.0 not 5.1 it work, and with WM5 and WM6 and it is work even when i use HI_RES_AWARE.

The patch is attached UseSetViewPortEx.patch

2010-08-31 13:13

 

UseSetViewPortEx.patch (2,437 bytes)
Index: wincewinapi.inc
===================================================================
--- wincewinapi.inc	(revision 27173)
+++ wincewinapi.inc	(working copy)
@@ -1181,17 +1181,7 @@
 
  ------------------------------------------------------------------------------}
 function TWinCEWidgetSet.ExcludeClipRect(dc: hdc;  Left, Top, Right, Bottom: Integer): Integer;
-var
-  P: TPoint;
 begin
-  // Fixes the following bug: http://bugs.freepascal.org/view.php?id=17249
-  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
-  begin
-    Left := Left + P.x;
-    Top := Top + P.y;
-    Right := Right + P.x;
-    Bottom := Bottom + P.y;
-  end;
   Result := Windows.ExcludeClipRect(dc, Left, Top, Right, Bottom);
 end;
 
@@ -1442,13 +1432,8 @@
 
  ------------------------------------------------------------------------------}
 function TWinCEWidgetSet.GetClipBox(DC : hDC; lpRect : PRect) : Longint;
-var
-  P: TPoint;
 begin
   Result := Windows.GetClipBox(DC, Windows.LPRECT(lpRect));
-  // Fixes the following bug: http://bugs.freepascal.org/view.php?id=17249
-  if LCLIntf.GetWindowOrgEx(DC, @P) > 0 then
-    OffsetRect(lpRect^, -P.x, -P.y);
 end;
 
 {------------------------------------------------------------------------------
@@ -2025,6 +2010,18 @@
   {$endif}
 end;
 
+function TWinCEWidgetSet.MoveWindowOrgEx(dc : hdc; dX,dY : Integer): boolean;
+var
+  P: TPoint;
+  lResult: Integer;
+Begin
+  lResult := GetViewPortOrgEx(dc, @P);
+  if lResult <> 0 then
+    Result := SetViewPortOrgEx(dc, P.x+dX, P.y+dY, @P)
+  else
+    Result := False;
+end;
+
 { This routine isn't used directly by the LCL
   We implent it with SetViewPortOrgEx because GetViewPortOrgEx is
   only available in Windows Mobile 5.0 +
Index: wincewinapih.inc
===================================================================
--- wincewinapih.inc	(revision 27173)
+++ wincewinapih.inc	(working copy)
@@ -142,6 +142,7 @@
 function GetTextExtentPoint(DC: HDC; Str: PChar; Count: Integer; var Size: TSize): Boolean; override;
 function GetTextMetrics(DC: HDC; var TM: TTextMetric): Boolean;  override;
 function GetViewPortExtEx(DC: HDC; Size: PSize): Integer; override;
+function MoveWindowOrgEx(dc : hdc; dX,dY : Integer): boolean; override;
 function GetViewPortOrgEx(DC: HDC; P: PPoint): Integer; override;
 function GetWindowExtEx(DC: HDC; Size: PSize): Integer; override;
 function GetWindowLong(Handle : hwnd; int: Integer): PtrInt; override;
UseSetViewPortEx.patch (2,437 bytes)

Felipe Monteiro de Carvalho

2010-08-31 13:22

developer   ~0040677

The correct solution isn't reverting the patch, but rather activating it only for newer WinCE versions.

Search for GetWinCEVersion in lazarus/lcl and all subdirectories

Zaher Dirkey

2010-08-31 16:37

reporter   ~0040684

Last edited: 2010-08-31 17:32

In WM 6.1 there is an emulation for old Screen resolution, Labels and other controls not moved correctly because SetWindowOrgEx use the Hi res not the emulated one, but when use SetViewPortOrgEx it use it correctly.
This problem not solved with old patch, but sloved with the new one.

http://msdn.microsoft.com/en-us/library/ms838191.aspx#dpi_awareness_topic3

Felipe Monteiro de Carvalho

2010-09-01 14:33

developer   ~0040707

Thanks, applied

Zaher Dirkey

2010-09-07 12:54

reporter   ~0040880

Until now every thing is OK, thanks.

Issue History

Date Modified Username Field Change
2010-08-23 20:31 Zaher Dirkey New Issue
2010-08-23 20:31 Zaher Dirkey File Added: ClipRect.patch
2010-08-23 20:31 Zaher Dirkey Widgetset => WinCE
2010-08-23 20:44 Zaher Dirkey Tag Attached: wince
2010-08-23 20:44 Zaher Dirkey Tag Attached: paint
2010-08-23 20:54 Felipe Monteiro de Carvalho Status new => assigned
2010-08-23 20:54 Felipe Monteiro de Carvalho Assigned To => Felipe Monteiro de Carvalho
2010-08-23 21:01 Felipe Monteiro de Carvalho Fixed in Revision => 27173
2010-08-23 21:01 Felipe Monteiro de Carvalho LazTarget => -
2010-08-23 21:01 Felipe Monteiro de Carvalho Status assigned => resolved
2010-08-23 21:01 Felipe Monteiro de Carvalho Fixed in Version => 0.9.29 (SVN)
2010-08-23 21:01 Felipe Monteiro de Carvalho Resolution open => fixed
2010-08-23 21:01 Felipe Monteiro de Carvalho Note Added: 0040423
2010-08-23 21:54 Zaher Dirkey Status resolved => closed
2010-08-23 21:54 Zaher Dirkey Note Added: 0040425
2010-08-31 13:12 Zaher Dirkey Status closed => assigned
2010-08-31 13:12 Zaher Dirkey Resolution fixed => reopened
2010-08-31 13:12 Zaher Dirkey Note Added: 0040676
2010-08-31 13:13 Zaher Dirkey File Added: UseSetViewPortEx.patch
2010-08-31 13:17 Zaher Dirkey Note Edited: 0040676
2010-08-31 13:22 Felipe Monteiro de Carvalho Note Added: 0040677
2010-08-31 13:23 Felipe Monteiro de Carvalho Status assigned => feedback
2010-08-31 16:37 Zaher Dirkey Note Added: 0040684
2010-08-31 17:32 Zaher Dirkey Note Edited: 0040684
2010-09-01 14:33 Felipe Monteiro de Carvalho Fixed in Revision 27173 => 27173, 27244
2010-09-01 14:33 Felipe Monteiro de Carvalho Status feedback => resolved
2010-09-01 14:33 Felipe Monteiro de Carvalho Resolution reopened => fixed
2010-09-01 14:33 Felipe Monteiro de Carvalho Note Added: 0040707
2010-09-07 12:54 Zaher Dirkey Status resolved => closed
2010-09-07 12:54 Zaher Dirkey Note Added: 0040880
2013-03-31 14:01 Zaher Dirkey Tag Attached: cliprect
2013-04-13 16:57 Felipe Monteiro de Carvalho Relationship added related to 0024107