实现移动和改变控件大小的代码
2006-03-14 13:02
423 查看
(Demo只演示了在四个角进行拖放控制大小和移动控件的操作)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
procedure CheckBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure ChangeSize(Control: TWinControl; Shift: TShiftState; X, Y: Integer);
const
conPrec = 6;
var
SC_MANIPULATE: Word;
begin
if (X < conPrec) and (Y < conPrec) then
begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
else if (X + conPrec > Control.Width) and (Y < conPrec) then
begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW;
end
else if (X < conPrec) and (Y + conPrec > Control.Height) then
begin
SC_MANIPULATE := $F007;
Control.Cursor := crSizeNS;
end
else if (X + conPrec > Control.Width) and (Y + conPrec > Control.Height) then
begin
SC_MANIPULATE := $F008;
Control.Cursor := crSizeWE;
end
else begin
SC_MANIPULATE := $F009;
Control.Cursor := crDefault;
end;
if Shift=[ssLeft] then
begin
ReleaseCapture;
Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;
procedure TForm1.CheckBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ChangeSize(Sender as TWinControl, Shift, X, Y);
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
procedure CheckBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure ChangeSize(Control: TWinControl; Shift: TShiftState; X, Y: Integer);
const
conPrec = 6;
var
SC_MANIPULATE: Word;
begin
if (X < conPrec) and (Y < conPrec) then
begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
else if (X + conPrec > Control.Width) and (Y < conPrec) then
begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW;
end
else if (X < conPrec) and (Y + conPrec > Control.Height) then
begin
SC_MANIPULATE := $F007;
Control.Cursor := crSizeNS;
end
else if (X + conPrec > Control.Width) and (Y + conPrec > Control.Height) then
begin
SC_MANIPULATE := $F008;
Control.Cursor := crSizeWE;
end
else begin
SC_MANIPULATE := $F009;
Control.Cursor := crDefault;
end;
if Shift=[ssLeft] then
begin
ReleaseCapture;
Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;
procedure TForm1.CheckBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ChangeSize(Sender as TWinControl, Shift, X, Y);
end;
end.
相关文章推荐
- 控件的移动、改变大小(DELPHI实现)
- java实现控件的移动及使用鼠标改变控件大小
- 实现控件的移动,改变大小(DELPHI实现)
- Delphi实现控件的移动、改变大小
- 在.Net的WinForm开发中如何实现控件随窗体大小的改变而自动适应其改变<收藏>
- 控件的鼠标拖动和改变大小实现的思考
- 使用JavaScript实现动态改变控件大小
- WPF:从WPF Diagram Designer Part 1学习控件模板、移动、改变大小和旋转
- 怎样实现控件随窗体大小而改变!!
- C#里WinForm开发中如何实现控件随窗体大小的改变而自动适应其改变
- Winform中代码Dialog控件实现(打开,保存,改变字体,颜色,打印功能)
- VC隐藏、显示、移动、改变大小控件
- WM_SIZE实现窗口改变时,改变控件的位置和大小
- 如何实现一个无边框Form的移动和改变大小(二)
- [Android_Develop]在代码中实时改变控件的大小
- C#实现窗体控件随窗体大小改变(包括字体大小)
- C++创建控件并响应三部曲、设置窗口全屏、OnSize实现控件大小改变、跟踪调试顺序
- js实现键盘操作实现div的移动或改变的原理及代码
- JQuery拖拽元素改变大小尺寸实现代码
- C#实现控件随窗体大小自动改变