Recent

Author Topic: Little glitch in manual Docking a control from a float state.  (Read 427 times)

jamie

  • Hero Member
  • *****
  • Posts: 7402
Little glitch in manual Docking a control from a float state.
« on: October 05, 2024, 10:30:29 pm »
for some reason The Align property of the control being docked back from where it came from gets changed to AlCLient instead of leaving it as was?

Following test code that implements a Button1.Click where the button itself is to float or dock back and forth, etc.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.   private
  18.  
  19.   public
  20.  
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. {$R *.lfm}
  29.  
  30. { TForm1 }
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. Var
  34.   PT:TPoint;
  35.   RT:TRect;
  36. begin
  37.   With Sender as Tbutton Do
  38.    Begin
  39.      If Floating then
  40.       Begin
  41.         PT := HostDockSite.ClientToScreen(Point(0,0));
  42.         RT := Self.ClientRect;
  43.         RT.Offset(Self.ClientToScreen(Point(0,0)));
  44.         IF RT.Contains(PT) Then
  45.         Begin
  46.           PT := Self.ScreenToClient(PT);
  47.           Dock(Self,TRect.Create(PT.X,PT.Y,Width+PT.X,Height+PT.Y));
  48.           Align := alNone; //Why must I do this ?
  49.         End;
  50.       end Else
  51.     Begin
  52.       RT := Self.ClientToScreen(BoundsRect);
  53.       RT.offset(0,-32); //good enought for now.
  54.       ManualFloat(RT);
  55.     end;
  56.  
  57.    end;
  58. end;
  59.  
  60. end.
  61.  

Not sure where at what point the alignment gets changed but there is no way other than what I have shown here to change it before it gets repainted.

 I am not using the Drag Drop system, I am doing manual floats and docks however, I've notice artifacts of full client shadow masking while using the dragging system, it maybe related.


Basically I move the floating control within the form area and then click the button again. Would be nice if I didn't have to do a hack like this? The other method of ManualDock does not fix this issue either.

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018