delphi 在运行时改变控件的大小


本文整理自网络,侵删。

 

 

//光标在控件不同位置时的样式

// 由于拐角这点手动精确实在困难 所以用范围 范围+3 这样很容易就找到这一点了


procedure CtrlMouseMove(Ctrl: TWinControl; Shift: TShiftState;X, Y: Integer);

begin

   with Ctrl do

   begin

      if (X >= 0) and (X <= 3) then

      begin

        if (Y >= 0) and (Y <= 3)                then  Cursor := crSizeNWSE;

        if (Y > 3) and (Y < Height - 3)         then  Cursor := cRsizewe;

        if (Y >= Height - 3) and (Y <= Height)  then  Cursor := crSizeNESW;

      end

      else if (X > 3) and (X < Width - 3) then

      begin

        if (Y >= 0) and (Y <= 3)                then  Cursor := crSizeNS;

        if (Y > 3) and (Y < Height - 3)         then  Cursor := cRarrow;

        if (Y >= Height - 3) and (Y <= Width)   then  Cursor := crSizeNS;

      end

      else if (X >= Width - 3) and (X <= Width) then

      begin

        if (Y >= 0) and (Y <= 3)                then  Cursor := crSizeNESW;

        if (Y > 3) and (Y < Height - 3)         then  Cursor := cRsizewe;

        if (Y >= Height - 3) and (Y <= Width)   then  Cursor := crSizeNWSE;

      end;

   end;

end;


//改变控件的大小

procedure CtrlMouseDown(Ctrl: TWinControl; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);

var

  WParam: Integer;

begin

  with Ctrl do

  begin

    if (X >= 0) and (X <= 3) then

    begin

      if (Y >= 0) and (Y <= 3)                 then  WParam:=$F004;

      if (Y > 3)  and (Y < Height - 3)         then  WParam:=$F001;

      if (Y >= Height - 3) and (Y <= Height)   then  WParam:=$F007;

    end

    else if (X > 3) and (X < Width - 3) then

    begin

      if (Y >= 0) and (Y <= 3)                 then  WParam:=$F003;

      if (Y > 3) and (Y < Height - 3)          then  WParam:=$F012;

      if (Y >= Height - 3) and (Y <= Width)    then  WParam:=$F006;

    end

    else if (X >= Width - 3) and (X <= Width)  then

    begin

      if (Y >= 0) and (Y <= 3)                 then  WParam:=$F005;

      if (Y > 3) and (Y < Height - 3)          then  WParam:=$F002;

      if (Y >= Height - 3) and (Y <= Width)    then  WParam:=$F008;

    end;

    ReleaseCapture;

    SendMessage(Handle,WM_SYSCOMMAND,WParam,0);

  end;

end;

使用

procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;

  Shift: TShiftState; X, Y: Integer);

begin

  CtrlMouseDown(Panel1, Button, Shift, X, Y);

end;


procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState;

  X, Y: Integer);

begin

  CtrlMouseMove(Panel1, Shift, X, Y);

end;

相关阅读 >>

Delphi 2009 之 tedit 加强的功能

Delphi for xx in xx do 语法的使用示例

Delphi tserversocket 发送消息之前检查客户端是否仍处于连接状态

Delphi edit只能输入数字或小数点

Delphi什么是thttpclient?

Delphi assignfile 与指定的文件建立连接

Delphi 如何把类中的方法做参数

Delphi adoconnection1 连接excel 读取数据

Delphi 取出一个字符在字符串出现的次数

Delphi 新增功能之: ioutils 单元(7): tfile 结构的功能

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...