怎样设计一个form,上面的控件运行时就象利用delphi设计的一样,form上面的各个可视控件可以拖动(300分)

  • 主题发起人 主题发起人 dcsdcs
  • 开始时间 开始时间
D

dcsdcs

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样设计一个form,上面的控件运行时就象利用delphi设计的一样,form上面的各个可视控件可以拖动!
给个方向都算!
 
一个提示:
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
Button1.Perform(wm_syscommand,$F012,0);
end;
 
找相关控件
 
到http://vcl.vclxx.org/里找,很多此类控件,呵呵!!![:D]
 
你可以采用两种方法:
一、利用控件的拖放功能来实现
二、在程序运行过程中,通过鼠标单击表选中,再动态改变其位置大小属性
 
利用mouse里的MouseDown,MouseUp,MouseMove 3个函数就可以写出来
 
我 copy 来的,或许对你有用
:::运行中拖动一个元件:::
在一个新的Form中放入一个Panel,加入如下代码:
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);const
SC_DragMove = $F012; { a magic number }begin ReleaseCapture;
panel1.perform(WM_SysCommand, SC_DragMove, 0);end;
运行,你当然知道这时应该拖动它。怎么样?Delphi真是神奇。

 
我 copy 来的,或许对你有用
:::运行中拖动一个元件:::
在一个新的Form中放入一个Panel,加入如下代码:
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
const
SC_DragMove = $F012; { a magic number }
begin
ReleaseCapture;
panel1.perform(WM_SysCommand, SC_DragMove, 0);
end;
运行,你当然知道这时应该拖动它。怎么样?Delphi真是神奇。
 
给我你的Mail,我给你控件!
 
谢谢大家,哦,明天来发分
to 雪逸:
利用控件的拖放功能来实现,能否稍微详细一点。谢谢
 
用过一个Resize控件,可以在运行时拖放和调整可视控件的大小,忘了在哪下的了。
 
to grays:
你的好意我领了,大家共同探讨原理,特别是控件的实现过程!
 
终于解决了,试验了好久:
------------------------------------------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Menus, ExtCtrls;

type TMyControl = Class(TControl);

type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
procedure MyMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
{ Private declarations }
public
{ Public declarations }
end;



var
Form1: TForm1;


implementation

{$R *.DFM}

procedure TForm1.MyMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
(Sender as TControl).Perform(WM_SYSCOMMAND,$F012,0);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
I:Integer;
begin
for I:=0 to Form1.ComponentCount-1 do
begin
if (Form1.Components is TControl) then
begin
TMyControl(Form1.Components).OnMouseDown:=MyMouseDown;
end;
end;
end;

end.
 
[blue]
喂 ,楼上的方法,不错嘛。不过去找相关控件可能会更好。呵呵~
http://www.51delphi.com
http://vcl.vclxx.org
[/blue]
 
使用现成的控件吧! Dream Designer:

Dream Designer is a pack of powerful components that allow you modify forms,
reports and data modules at run-time. No recompilation or extra coding is
required - all you have to do is to put a TDreamDesigner component on the
form and run the application. Then you will be able to switch to design time
by pressing a hot key and make changes to a form or report and to the
components, placed there. The changes can be saved so that the next time you
run the application, designed form will look the same as you left it at the
previous time.

Dream Designer does not require any additional tools or applications to switch
between run and design time and to modify forms, reports and data modules.
End users do not need Delphi or C++ Builder installed on their computers,
or any extra DLLs to use Dream Designer. It means that Dream Designer has
its own design mode that has all designing features of standard Delphi
Designer. Moreover, Dream Designer is capable of working with ActiveX
controls - as easy as with usual ones!

Dream Designer is written entirely with Delphi. You don't need any extra
DLLs or OCXs. Source is compatible and tested with Delphi 3, Delphi 4,
Delphi 5, C++ Builder 3, C++ Builder 4, and C++ Builder 5.
 
http://www.consist.it/_DreamCom/designer.html
 
http://grays.yeah.net
在控件下载里面,要看原理,打开源码就好了呀,能同时移动多个控件,cool
 
coolbar上的所有东西都可以拖动,用coolbar覆盖你的form
 
谢谢大家,拖动完全解决,能否象delphi设计时控件周围有8个点!可以拖动!
分不够,再加280分。(全部家当)
 
DevExpress里有部分控件就是来做这个功能的
 
后退
顶部