抱歉实在不知道只用文字要怎么描述所要的效果,所以下面附图说明:
想要实现的就是如上图所示,通过点击面板上的按钮能够实现面板缩退到界面边缘的效果。
(delphi控件面板的那样,点击控件面板上的按钮,控件面板自动缩到边缘,鼠标移动上去又能自动显示出来,再点一次又能固定住,不再缩进去的那样子)1,请问delphi里是否自带有这样的控件。如有,请教该控件名称。
2,如果delphi里没有提供,请问是否有免费的能实现上述效果的控件?如有,请教该控件名称。谢谢。
想要实现的就是如上图所示,通过点击面板上的按钮能够实现面板缩退到界面边缘的效果。
(delphi控件面板的那样,点击控件面板上的按钮,控件面板自动缩到边缘,鼠标移动上去又能自动显示出来,再点一次又能固定住,不再缩进去的那样子)1,请问delphi里是否自带有这样的控件。如有,请教该控件名称。
2,如果delphi里没有提供,请问是否有免费的能实现上述效果的控件?如有,请教该控件名称。谢谢。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,math;type
TForm1 = class(TForm)
timer1: TTimer;
procedure timer1Timer(Sender: TObject);
private
{ Private declarations }
FAnchors: TAnchors;
procedure WMMOVING(var Msg: TMessage); message WM_MOVING;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.WMMOVING(var Msg: TMessage);
begin
with PRect(Msg.LParam)^ do begin
Left := Min(Max(0, Left), Screen.Width - Width);
Top := Min(Max(0, Top), Screen.Height - Height);
Right := Min(Max(Width, Right), Screen.Width);
Bottom := Min(Max(Height, Bottom), Screen.Height);
FAnchors := [];
if (left=0) and (top=0) then
Include(FAnchors, akLeft)
else if (top=0) and (Right = Screen.Width) then
Include(FAnchors, aktop)
else
begin
if Left = 0 then Include(FAnchors, akLeft);
if Right = Screen.Width then Include(FAnchors, akRight);
if Top = 0 then Include(FAnchors, akTop);
if Bottom = Screen.Height then Include(FAnchors, akBottom);
end;
timer1.Enabled := FAnchors<>[];
setwindowpos(application.handle,HWND_TOPMOST,0,0,0,0,swp_hidewindow);
end;
end;procedure TForm1.timer1Timer(Sender: TObject);
const
cOffset = 2;
var
vHandle: THandle;
begin
vHandle := WindowFromPoint(Mouse.CursorPos);
while (vHandle<>0) and (vHandle<>Handle) do
vHandle := GetParent(vHandle);
if (vHandle = Handle) then
begin
if akLeft in FAnchors then Left := 0;
if akTop in FAnchors then Top := 0;
if akRight in FAnchors then Left := Screen.Width - Width;
if akBottom in FAnchors then Top := Screen.Height - Height;
end
else
begin
if akLeft in FAnchors then Left := -Width + cOffset;
if akTop in FAnchors then Top := -Height + cOffset;
if akRight in FAnchors then Left := Screen.Width - cOffset;
if akBottom in FAnchors then Top := Screen.Height - cOffset;
end;
end;end.
看来我果然没有表达清楚我要的效果。要的效果是这样子的:
如图,我有一个form1,然后form1上有另外两个控件,一个memo1,一个treeview1。
我想要的是右边的treeview1在我不需要的时候,能让它缩到form1的最右边边里去,让memo1占据form1上的更多的区域。而在需要的时候treeview1又要能恢复回来。就是在问题中的贴出来的那张delphi2009的图中的的"structure"面板的效果。