如何使用Delphi保留桌面的一个边缘?像Vista Sidebar那样的东西。
答案 0 :(得分:16)
您想要的是application desktop toolbar
您必须使用ShellAPI单元和SHAppBarMessage 函数中声明的TAppBarData对象。
见这个简单的例子。
type
TApplicationTaskBar = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
end;
var
ApplicationTaskBar: TApplicationTaskBar;
implementation
{$R *.dfm}
Uses
ShellAPI;
procedure TApplicationTaskBar.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;
Params.Style := (Params.Style OR WS_POPUP) AND (NOT WS_DLGFRAME); //Remove title Bar
end;
procedure TApplicationTaskBar.FormCreate(Sender: TObject);
var
MyTaskBar : TAppBarData;
begin
GlassFrame.Enabled :=True;//Activate Glass , optional
GlassFrame.SheetOfGlass :=True;//optional
Left:=0;
Top :=0;
Width := 300;
Height:= Screen.Height;
FillChar(MyTaskBar, SizeOf(TAppBarData), 0);
MyTaskBar.cbSize := SizeOf(TAppBarData);
MyTaskBar.hWnd := Handle;
MyTaskBar.uCallbackMessage := WM_USER+777; //Define my own Mesaage
MyTaskBar.uEdge := ABE_LEFT;
MyTaskBar.rc := Rect(0, 0, Width, Height);
SHAppBarMessage(ABM_NEW, MyTaskBar);
SHAppBarMessage(ABM_ACTIVATE, MyTaskBar);
SHAppBarMessage(ABM_SETPOS, MyTaskBar);
Application.ProcessMessages;
end;
procedure TApplicationTaskBar.FormDestroy(Sender: TObject);
var
MyTaskBar : TAppBarData;
begin
FillChar(MyTaskBar, SizeOf(TAppBarData), 0);
MyTaskBar.cbSize := SizeOf(TAppBarData);
MyTaskBar.hWnd := Self.Handle;
SHAppBarMessage(ABM_Remove, MyTaskBar);
end;
检查此链接
再见。