哪位大哥能教教小弟如何制作自制的可以拖动的组件???急!!!万分感谢!!!
解决方案 »
- dbgrideh 的一个小问题,超难很有用(自动计算) 我想这个问题很有用?对大家也有很帮助
- 调用DLL中函数产生Invalid pointer Opreation 问题(不是返回string)
- 请问如何把编好的delphi程序编译成EXE文件
- 如果我在网上下来一个控件,我应该怎么安装并用这个按件呢?
- ■我打算用delphi开发一个数据库,请大家帮帮忙,谢谢!(分数不够,再加!)
- 我想然函数返回一个数组,当这样声明却不能编译,请问该怎么办!!详细请进!
- 两上个小问题,请帮忙,谢了!
- 为什么会出错呢?
- 有关第三方组件安装的问题(出现本人暂无法解决的错误信息)对你可能是很简单的!
- 怎样建立一个虚拟盘!
- 动态数组大小问题
- 一个关于treeview的问题,大家帮忙解释一下:)
var
SC_MANIPULATE: Word;
begin
//光标在控件的最左侧
if (X<=Precision) and (Y>Precision) and (Y<WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F001;
WinControl.Cursor := crSizeWE;
end
else
//光标在控件的最右侧
if (X>=WinControl.Width-Precision) and (Y>Precision) and (Y<WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F002;
WinControl.Cursor := crSizeWE;
end
else
//光标在控件的最上侧
if (X>Precision) and (X<WinControl.Width-Precision) and (Y<=Precision) then
begin
SC_MANIPULATE := $F003;
WinControl.Cursor := crSizeNS;
end
else
//光标在控件的最下侧
if (X>Precision) and (X<WinControl.Width-Precision) and (Y>=WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F006;
WinControl.Cursor := crSizeNS;
end
else
//光标在控件的左上角
if (X<=Precision) and (Y<=Precision) then
begin
SC_MANIPULATE := $F004;
WinControl.Cursor := crSizeNWSE;
end
else
//光标在控件的右上角
if (X>=WinControl.Width-Precision) and (Y<=Precision) then
begin
SC_MANIPULATE := $F005;
WinControl.Cursor := crSizeNESW ;
end
else
//光标在控件的左下角
if (X<=Precision) and (Y>=WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F007;
WinControl.Cursor := crSizeNESW;
end
else
//光标在控件的右下角
if (X>=WinControl.Width-Precision) and (Y>=WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F008;
WinControl.Cursor := crSizeNWSE;
end
else
//光标在控件的客户区(移动整个控件)
if (X>5) and (Y>5) and (X<WinControl.Width-5) and
(Y<WinControl.Height-5) then
begin
SC_MANIPULATE := $F009;
WinControl.Cursor := crSizeAll;
end
else
begin
SC_MANIPULATE := $F000;
WinControl.Cursor := crDefault;
end;
if Shift=[ssLeft] then
begin
ReleaseCapture;
WinControl.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;
我不太明白Precision什么意思
谢谢了!!!
procedure TLine.MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
begin
ManipulateControl(TLine(Sender),Shift,X,Y,2); //这是我自已在控件里引用的
end;
能不能把你这一部分的完整程序还有演示程序给我看看???
我是个菜鸟,完整些看得明白,多谢了
谢谢了!!!
我完整的就在上面了,你编译不过去,不会吧!
出现什么错误?1.先在Public中申明该过程:
procedure ManipulateControl(WinControl: TControl; Shift: TShiftState;X, Y, ecision: integer);
2.写这个过程,就是上面粘贴的:
procedure TForm1.ManipulateControl(WinControl: TControl; Shift: TShiftState;X, Y, ecision: integer); (TForm1是窗体的名称)
begin
.....
end;
3.然后在你所要拖拉的控件的onmousemove引用该过程:
procedure TForm1.MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
begin
ManipulateControl(Button1,Shift,X,Y,2); //这里面2就表示精度!
end;再试试吧!
procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
ManipulateControl(Button1,Shift,X,Y,2);
end;
只能这样称呼了,你不介意吧,没别的意思,只是出于尊敬!!!
我想能不能像别的事件一样通过声明类似于ondblclick事件声明ondragdrop然后在其中加入需要的东西完成自制拖动事件的添加???
你这个不是自制的组件吧???
能安装吗???
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls,Graphics,Menus,StdCtrls,Dialogs,Forms,
Buttons;type
TLine = class(TPanel)
private
{ Private declarations }
protected
{ Protected declarations }
procedure MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
public
{ Public declarations }
constructor Create(Aowner:TComponent);override;
destructor destroy;override;
published
{ Published declarations }
property Height default 5;
property Width default 100;
property Color default clBlack;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Standard', [TLine]);
end;{TLine}procedure ManipulateControl(WinControl: TControl; Shift: TShiftState;X, Y, Precision: integer);
//Precision:精度,该方法可以在onmousemove中调用
var
SC_MANIPULATE: Word;
begin
//光标在控件的最左侧
if (X<=Precision) and (Y>Precision) and (Y<WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F001;
WinControl.Cursor := crSizeWE;
end
else
//光标在控件的最右侧
if (X>=WinControl.Width-Precision) and (Y>Precision) and (Y<WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F002;
WinControl.Cursor := crSizeWE;
end
else
//光标在控件的最上侧
if (X>Precision) and (X<WinControl.Width-Precision) and (Y<=Precision) then
begin
SC_MANIPULATE := $F003;
WinControl.Cursor := crSizeNS;
end
else
//光标在控件的最下侧
if (X>Precision) and (X<WinControl.Width-Precision) and (Y>=WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F006;
WinControl.Cursor := crSizeNS;
end
else
//光标在控件的左上角
if (X<=Precision) and (Y<=Precision) then
begin
SC_MANIPULATE := $F004;
WinControl.Cursor := crSizeNWSE;
end
else
//光标在控件的右上角
if (X>=WinControl.Width-Precision) and (Y<=Precision) then
begin
SC_MANIPULATE := $F005;
WinControl.Cursor := crSizeNESW ;
end
else
//光标在控件的左下角
if (X<=Precision) and (Y>=WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F007;
WinControl.Cursor := crSizeNESW;
end
else
//光标在控件的右下角
if (X>=WinControl.Width-Precision) and (Y>=WinControl.Height-Precision) then
begin
SC_MANIPULATE := $F008;
WinControl.Cursor := crSizeNWSE;
end
else
//光标在控件的客户区(移动整个控件)
if (X>5) and (Y>5) and (X<WinControl.Width-5) and
(Y<WinControl.Height-5) then
begin
SC_MANIPULATE := $F009;
WinControl.Cursor := crSizeAll;
end
else
begin
SC_MANIPULATE := $F000;
WinControl.Cursor := crDefault;
end;
if Shift=[ssLeft] then
begin
ReleaseCapture;
WinControl.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;constructor TLine.Create(Aowner:TComponent);
begin
inherited Create(AOwner);
Height :=20;
Width :=200;
Color :=clBlack; OnMouseMove :=MouseMove;
end;
end;destructor TLine.destroy;
begin
inherited;
end;procedure TLine.MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
begin
ManipulateControl(TLine(Sender),Shift,X,Y,2)
end;end.
我刚学习delphi三个月,能不能把你的联系方式给我?我以后有问题可以向你请教!!!
我的qq:57490953邮箱:[email protected]