was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

30 Visitors Online


 
...Steuerelemente zur Laufzeit auf der Form bewegen?
Autor: Peter Morris
Homepage: http://www.sandbrooksoftware.com/DPSC/Tips/PeterMorris/
[ Tip ausdrucken ]  

Tip Bewertung (9):  
     


{Assign the OnMouseDown event for each component you want to move at runtime }


type
  
TForm1 = class(TForm)
    {...}
    
procedure MoveControl(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    
{ Private-Declarations }
  
public
    
{ Public-Declarations }
  
end;
end;



// In the implementation Section:


procedure TForm1.MoveControl(Sender:TObject; Button:TMouseButton;
          Shift:TShiftState; X,Y:Integer);
var
  
TempPanel: TPanel;
  Control: TControl;
begin
  
// Releases the mouse capture from a window
  
ReleaseCapture;
  // If the component is a TWinControl, move it directly
  
if Sender is TWinControl then
    
TWinControl(Sender).Perform(WM_SYSCOMMAND,$F012,0)
  else
  try
    
Control := TControl(Sender);
    TempPanel := TPanel.Create(Self);
    with TempPanel do
    begin
      
//Replace the component with TempPanel
      
Caption := '';
      BevelOuter := bvNone;
      SetBounds(Control.Left, Control.Top, Control.Width, Control.Height);
      Parent := Control.Parent;
      //Put our control in TempPanel
      
Control.Parent := TempPanel;
      //Move TempPanel with control inside it
      
Perform(WM_SYSCOMMAND, $F012, 0);
      //Put the component where the panel was dropped
      
Control.Parent := Parent;
      Control.Left := Left;
      Control.Top := Top;
    end;
  finally
    
TempPanel.Free;
  end;
end;





 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners