请问用什么方法可以实现控件大小的随意调整?
就像Delphi编辑窗体那样,可以左上拉,上拉,下拉......而不是只能右下拉。
请以Button为例。

解决方案 »

  1.   

    在他Dragover 和  dragEnd 事件中处理,拖动。
      

  2.   

    这里很全了:
    http://expert.csdn.net/Expert/topic/1456/1456413.xml?temp=.6957971
      

  3.   

    在http://expert.csdn.net/Expert/topic/1456/1456413.xml?temp=.6957971还是没有解决大小调整问题。
      

  4.   

    试试这个,我用过,可以的unit Unit1; interface uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls; type 
        TForm1 = class(TForm) 
        Button1: TButton; 
        Label1: TLabel; 
        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
        procedure Button1Click(Sender: TObject); 
      private 
        procedure ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer); 
      { Private declarations } 
      public 
      { Public declarations } 
    end; var 
      Form1: TForm1; implementation {$R *.dfm} procedure Tform1.ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer); 
    var 
      SC_MANIPULATE: 
      Word; 
    begin 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //光标在控件的最左侧********************************************************** 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
      if (X<=Precision) and (Y>Precision) 
         and (Y=Control.Width-Precision) and (Y>Precision) 
         and (YPrecision) and (X=Control.Width-Precision) and (Y<=Precision) then 
      begin 
        SC_MANIPULATE := $F005; 
        Control.Cursor := crSizeNESW ; 
      end 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    //光标在控件的最下侧********************************************************** 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
      else if (X>Precision) and (X=Control.Height-Precision) then 
      begin 
        SC_MANIPULATE := $F006; 
        Control.Cursor := crSizeNS; 
      end 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    //光标在控件的左下角********************************************************** 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
      else if (X<=Precision) and (Y>=Control.Height-Precision) then 
      begin 
        SC_MANIPULATE := $F007; 
        Control.Cursor := crSizeNESW; 
      end 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    //光标在控件的右下角********************************************************** 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
      else if (X>=Control.Width-Precision) and (Y>=Control.Height-Precision) then 
      begin 
        SC_MANIPULATE := $F008; 
        Control.Cursor := crSizeNWSE; 
      end 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    //光标在控件的客户区(移动整个控件)****************************************** 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
      else 
      //if (X>5) and (Y>5) and (X<Control.Width-5) and (Y<Control.Height-5) then 
      begin 
        SC_MANIPULATE := $F009; 
        Control.Cursor := crDefault;
        //SizeAll;
    { end 
      else 
      begin 
        SC_MANIPULATE := $F000; 
        Control.Cursor := crSizeAll;
      //Default; } 
      end; 
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    if Shift=[ssLeft] then 
    begin 
      ReleaseCapture; 
      Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
     end;
    end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); 
    begin 
      label1.Caption := IntToStr(X) + '/' + IntToStr(Y); 
      ManipulateControl((Sender as Tform), Shift, X, Y, 10); 
    end; procedure TForm1.Button1Click(Sender: TObject); 
    begin 
      close; 
    end; 
    end.