• 全部
  • 语言基础/算法/系统设计
  • 数据库相关
  • 图形处理/多媒体
  • 网络通信/分布式开发
  • VCL组件开发及应用
  • Windows SDK/API
  • 问答

请问怎样让一个treeview 或者edit控件在运行的时候可以调整大小?

comecsdn 2002-11-11 11:39:40
如果您能解我心之疑惑,我心存感激.
如果您嫌我我太过愚笨,我惜您激励.
如果您亦不解,希望此一问,让你我共同在思考中前进
无论如何,谢谢您浏览这个帖子.
...全文
53 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
yang6130 2002-11-22
老达摩的代码果然好用,但如果你只是想实现象资源管理器窗口的TREEVIEW和LISTVIEW 之间通过拖动改变大小的话还有更简单的办法:在窗口上放一个TREEVIW
,设置ALIGN为alLeft,再放一个 Splitter, 设置ALIGN为alLeft ,再放一个LISTVIEW,设置ALIGN为alClient,适应调整各控件的位置,确保Splitter在TreeView,ListView之间,这样你不用编一行代码就可动态改TreeView,ListView的大小。
回复
stanely 2002-11-21
好像对于tlabel无效。。。

回复
xzgyb 2002-11-21
是,只对TWinControl的后代好使
回复
stanely 2002-11-20
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP UPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP UPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP UPUPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUP UPUPUPUP UPUPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUP UPUPUP UPUPUPUPUPUPUPUPUPUPUPU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PUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
UPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUPUP
回复
xzgyb 2002-11-12
回复人: quark(夸克) ( ) 信誉:100 2002-4-12 17:03:16 得分:0



//==============================================================================
//任意摆布一个控件(拖动、放大、缩小)******************************************
//==============================================================================
procedure ManipulateControl(Control: TControl; Shift: TShiftState; X, Y, Precision: integer);
var SC_MANIPULATE: Word;
begin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最左侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (X<=Precision) and (Y>Precision) and (Y<Control.Height-Precision)
then begin
SC_MANIPULATE := $F001;
Control.Cursor := crSizeWE;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最右侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else if (X>=Control.Width-Precision) and (Y>Precision) and (Y<Control.Height-Precision)
then begin
SC_MANIPULATE := $F002;
Control.Cursor := crSizeWE;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最上侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else if (X>Precision) and (X<Control.Width-Precision) and (Y<=Precision)
then begin
SC_MANIPULATE := $F003;
Control.Cursor := crSizeNS;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的左上角**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else if (X<=Precision) and (Y<=Precision)
then begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的右上角**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else if (X>=Control.Width-Precision) and (Y<=Precision)
then begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW ;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最下侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else if (X>Precision) and (X<Control.Width-Precision) and (Y>=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 := crSizeAll;
end
else begin
SC_MANIPULATE := $F000;
Control.Cursor := crDefault;
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if Shift=[ssLeft] then
begin
ReleaseCapture;
Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;



example:

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure TForm_Main.Button1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
Caption := IntToStr(X) + '/' + IntToStr(Y);
ManipulateControl((Sender as TControl), Shift, X, Y, 10);
end;




回复
huyalin 2002-11-12
在MouseDown,MouseMove,MouseUp事件中处理
首先对每个控件的Width和Height的增量分别定义一个私有变量保存
var xStep,yStep:Integer;

在MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
中判断X,Y是否是边框,即Width与Height
如果是则设置xStep := 0 ;yStep := 0;
在MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
事件中对当前的X,Y与原有的进行比较,将变化量保存在xStep与yStep中
在MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);中结束拖放处理过程,将控件的Width与Height的值与xStep与yStep的值进行运算(xStep与yStep也可以为负的)
这种处理直观,但不好控制,
简单的方法也可以自己输入一个Width与Height的值来实现
回复
blueshu 2002-11-12
直接写它的height,width行不行?
回复
CloneCenter 2002-11-12
怎么个调整大小???
你用代码可以调整它的大小,用户用鼠标来调整它的大小???
回复
发帖
Delphi
创建于2007-08-02

4868

社区成员

Delphi 开发及应用
申请成为版主
帖子事件
创建了帖子
2002-11-11 11:39
社区公告
暂无公告