delphi 控制组件位置上下左右


本文整理自网络,侵删。

 

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    VersLeHaut: TButton;
    VersLaDroite: TButton;
    VersLaGauche: TButton;
    VersLeBas: TButton;
    Panel1: TPanel;
    Label1: TLabel;
    procedure VersLeHautClick(Sender: TObject);
    procedure VersLeBasClick(Sender: TObject);
    procedure VersLaGaucheClick(Sender: TObject);
    procedure VersLaDroiteClick(Sender: TObject);
  private
    { }
  public
    { }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.VersLeHautClick(Sender: TObject);
begin
  if Label1.Top >= 10 then
    Label1.Top := Label1.Top - 10;
end;

procedure TForm1.VersLaDroiteClick(Sender: TObject);
begin
  if Label1.Left + Label1.Width < Panel1.ClientWidth-10 then
    Label1.Left := Label1.Left + 10;
end;

procedure TForm1.VersLaGaucheClick(Sender: TObject);
begin
  if Label1.Left >= 10 then
    Label1.Left := Label1.Left - 10;
end;

procedure TForm1.VersLeBasClick(Sender: TObject);
begin
  if Label1.Top + Label1.Height < Panel1.ClientHeight-10 then
    Label1.Top := Label1.Top + 10;
end;

end.

相关阅读 >>

tidtcpclient控件中文指南

Delphi 校验文件大小

Delphi中显示gif动画

Delphi unigui中如何监听session的开始与结束

Delphi unix时间转换成Delphi时间

Delphi unknown picture file extension (.jpg) 错误提示

Delphi idhttp post json 上传 php 接收

Delphi 自定�x分割字符串

Delphi colorbox不需要系统那么多颜色,只想自定义显示其中几个,怎么做?

Delphi 写变速齿轮外挂

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



打赏

取消

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

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

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

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

评论

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