delphi 在程序运行时改变控件大小


本文整理自网络,侵删。

 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.

相关阅读 >>

Delphi xe新语法/新功能

Delphi firedac数据库引擎连接mysql

Delphi int64:是Delphi中最大的整数,64位有符号整数

Delphi dbgrideh 的分组统计 datagrouping

Delphi rest 服务器返回utf16编码转换成正常string

Delphi ipnumberipv4

Delphi post登陆Delphi盒子论坛源码

Delphi 中使长循环有响应

Delphi 数字分隔

Delphi 10进制数与33进制数的转换

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



打赏

取消

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

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

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

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

评论

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