设计复杂的界面或者要求特别精确细致的效果,除了以下我说到的achors属性之外,还有在onResize事件中,对自己面板上的控件进行处理,例如调整控件的height或者width属性等请看下面的代码,拷贝到你的新工程文件中,看是不是你想要的这种效果。注意 文本格式的DFM文件中,关于BUTTON属性的设置 --.pas----------------------------------------------------
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}end.--.dfm---------------------------------------------------------object Form1: TForm1
  Left = 192
  Top = 133
  Width = 196
  Height = 154
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  DesignSize = (
    188
    127)
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 56
    Top = 40
    Width = 75
    Height = 25
    Anchors = [akLeft, akTop, akRight, akBottom]
    Caption = 'Button1'
    TabOrder = 0
  end
end

解决方案 »

  1.   

    一点想法:
    建议在ButtonMouseMove中写事件procedure TForm_Main.Button1MouseMove(Sender: TObject; Shift: TShiftState;Value MeaningssShift The Shift key is held down.
    ssAlt The Alt key is held down.
    ssCtrl The Ctrl key is held down.
    ssLeft The left mouse button is held down.
    ssRight The right mouse button is held down.
    ssMiddle The middle mouse button is held down.
    ssDouble The mouse was double-clicked.
      

  2.   

    比较麻烦,但还是有办法:procedure TForm1.OleContainer1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    begin
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //********************************\*******************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      if ((X=0) and (Y=0)) or ((X=(Sender as TControl).Width) and (Y=(Sender as TControl).Height))
      then (Sender as TControl).Cursor := crSizeNWSE
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //********************************/*******************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if ((X=0) and (Y=(Sender as TControl).Height)) or ((X=(Sender as TControl).Width) and (Y=0))
      then (Sender as TControl).Cursor := crSizeNESW
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //********************************|*******************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (Y=0) or (Y=(Sender as TControl).Height)
      then (Sender as TControl).Cursor := crSizeNS
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //********************************--******************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X=0) or (X=(Sender as TControl).Width)
      then (Sender as TControl).Cursor := crSizeWE
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else (Sender as TControl).Cursor := crDefault;  if ssLeft in Shift then
      case (Sender as TControl).Cursor of
        crSizeNWSE: ;
        crSizeNESW: ;
        crSizeNS:   ;
        crSizeWE:   ;
      end;
    end;
      

  3.   

    //==============================================================================
    //任意摆布一个控件(拖动、放大、缩小)******************************************
    //==============================================================================
    procedure ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer);
    var SC_MANIPULATE: Word;
    begin
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最左侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           if (X<=Precision) and (Y>Precision) and (Y<Control.Height-Precision)
      then begin
             SC_MANIPULATE  := $F001;
             Control.Cursor := crSizeWE;
           end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最右侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X>=Control.Width-Precision) and (Y>Precision) and (Y<Control.Height-Precision)
      then begin
             SC_MANIPULATE  := $F002;
             Control.Cursor := crSizeWE;
           end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最上侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X>Precision) and (X<Control.Width-Precision) and (Y<=Precision)
      then begin
             SC_MANIPULATE  := $F003;
             Control.Cursor := crSizeNS;
           end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的左上角**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X<=Precision) and (Y<=Precision)
      then begin
             SC_MANIPULATE  := $F004;
             Control.Cursor := crSizeNWSE;
           end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的右上角**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X>=Control.Width-Precision) and (Y<=Precision)
      then begin
             SC_MANIPULATE  := $F005;
             Control.Cursor := crSizeNESW    ;
           end
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      //光标在控件的最下侧**********************************************************
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      else if (X>Precision) and (X<Control.Width-Precision) and (Y>=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 := crSizeAll;
           end
      else begin
             SC_MANIPULATE := $F000;
             Control.Cursor := crDefault;
           end;
      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      if Shift=[ssLeft] then
      begin
        ReleaseCapture;
        Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
      end;  
    end;example://~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    procedure TForm_Main.Button1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    begin
      Caption := IntToStr(X) + '/' + IntToStr(Y);
      ManipulateControl((Sender as TControl), Shift, X, Y, 10);
    end;
    10为精度