How can I reserve one edge of the desktop with Delphi? Something like 开发者_JAVA百科the Vista Sidebar does.
What you want is called an application desktop toolbar
You must use the TAppBarData Object declared in the ShellAPI unit and the SHAppBarMessage function.
See this simple example.
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;
Check this links
- SHAppBarMessage
- ABM_ACTIVATE
- ABM_SETPOS
- ABM_NEW
Bye.
精彩评论