delphi – 保留桌面的一部分

前端之家收集整理的这篇文章主要介绍了delphi – 保留桌面的一部分前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用Delphi保留桌面的一个边缘?像Vista Sidebar那样的东西.

解决方法

你想要的是一个 application desktop toolbar

您必须使用ShellAPI单元中声明的TAppBarData对象和SHAppBarMessage 函数.

看这个简单的例子.

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,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,0);
  MyTaskBar.cbSize := SizeOf(TAppBarData);
  MyTaskBar.hWnd   := Self.Handle;
  SHAppBarMessage(ABM_Remove,MyTaskBar);
end;

检查此链接

> SHAppBarMessage
> ABM_ACTIVATE
> ABM_SETPOS
> ABM_NEW

再见.

原文链接:https://www.f2er.com/delphi/102053.html

猜你在找的Delphi相关文章