While debugging scrolling bugs in LCL i found that ClientToScreen acts differently according to the widget set.

These are the behaviors:

1) The returned value is related to the actual position, i.e., it does not consider the scroll offset. If you pass Point(0,0) the value will be the same regardless of the scroll position. (Gtk1)

2) The returned value is related to the virtual position, i.e, it takes into account the scroll offset. If you pass Point(0, 0) the value changes inversely to scrollbar position. (Gtk2) 3) The returned value is related to the virtual position, i.e, it takes into account the scroll offset. If you pass Point(0, 0) the value changes the same amount of scrollbar position. (Win32)

4) Nothing. Qt has no visible scrollbars so...

Notes:

Delphi does the same as (1)/Gtk1

(3) is clearly buggy.

Between (1) and (2) is a design decision.


Attached is a patch that makes win32 acts like (2)/gtk2. It changes the offset signal when calculating the LCL bounds. With the change it becomes consistent with the TCustomGroupBox signal convention (LCL bounds at Right/Down of win32 +, at Left/Up -).
It also fixes the scrolling paint and setcursor of non TWincontrol.

Luiz



Index: lcl/interfaces/win32/win32callback.inc
===================================================================
--- lcl/interfaces/win32/win32callback.inc      (revision 14008)
+++ lcl/interfaces/win32/win32callback.inc      (working copy)
@@ -471,12 +471,10 @@
       end;
       if ParentPaintWindow <> 0 then
         GetWin32ControlPos(Window, ParentPaintWindow, parLeft, parTop);
-      if not GetLCLClientBoundsOffset(lWinControl, ORect) then
-      begin
-        ORect.Left := 0;
-        ORect.Top := 0;
-        { we don't use ORect.Right and ORect.Bottom, initialize here if needed 
}
-      end;
+      //Is not necessary to check the result of GetLCLClientBoundsOffset since
+      //the false condition (lWincontrol = nil or lWincontrol <> TWinControl) 
is never met
+      //The rect is always initialized with 0
+      GetLCLClientBoundsOffset(lWinControl, ORect);
       PaintMsg.Msg := LM_PAINT;
       PaintMsg.PaintStruct := @PS;
       if not useDoubleBuffer then
Index: lcl/interfaces/win32/win32proc.pp
===================================================================
--- lcl/interfaces/win32/win32proc.pp   (revision 14008)
+++ lcl/interfaces/win32/win32proc.pp   (working copy)
@@ -852,8 +852,8 @@
       if HorzScrollBar <> nil then
       begin
         // left and right bounds are shifted by scroll position
-        ORect.Left := HorzScrollBar.Position;
-        ORect.Right := HorzScrollBar.Position;
+        ORect.Left := -HorzScrollBar.Position;
+        ORect.Right := -HorzScrollBar.Position;
       end;
       if VertScrollBar <> nil then
       begin
@@ -858,8 +858,8 @@
       if VertScrollBar <> nil then
       begin
         // top and bottom bounds are shifted by scroll position
-        ORect.Top := VertScrollBar.Position;
-        ORect.Bottom := VertScrollBar.Position;
+        ORect.Top := -VertScrollBar.Position;
+        ORect.Bottom := -VertScrollBar.Position;
       end;
     end;
   If (TheWinControl is TCustomGroupBox) Then

Reply via email to