网上文摘 小说 Flash游戏 最近更新 下载排行 资源分类 下载指南
经典编程资源 精彩不容错过
设为首页
加入收藏
联系我们
当前位置:Delphi园地技巧文章图像媒体 → 在程序运行时改变控件大小
在程序运行时改变控件大小
日期:2005年4月1日 作者: 人气: 查看:[大字体 中字体 小字体]
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园地)

相关文章:
·原来的控件delphi7里何处寻?
·第三方控件安装方法
·第三方控件安装(RxLib)
·第三方控件安装(Ehlib)
·在程序运行时自动注册ActiveX控件
·delphi透明组件(控件)开发
·在TDBGrid控件中实现拖放的另外一个思路
·Delphi中定制DBGrid控件
·在DBGrid控件中显示图形
·DbGrid控件隐藏或显示标题栏
 → 特别推荐
 → 热点TOP10
关于我们 | 广告服务 | 发布资源 | 联系站长 Copyright © 2002-2006 Delphi园地 All Rights Reserved