1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
dockHeight = 120;
type
TForm1 = class(TForm)
ButtonDock: TButton;
ButtonUnDock: TButton;
procedure ButtonUnDockClick(Sender: TObject);
procedure ButtonDockClick(Sender: TObject);
private
{ Déclarations privées }
isDocked: boolean;
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonDockClick(Sender: TObject);
var
rect: TRect;
begin
If SystemParametersInfo(SPI_GETWORKAREA, 0, @rect, 0)
then begin
rect.Top := rect.Top + dockHeight;
isDocked := true;
if SystemParametersInfo(SPI_SETWORKAREA, 0, @rect, SPIF_SENDCHANGE)
then begin
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
ButtonDock.Enabled := false;
end
else begin
isDocked := false;
showmessage(string(GetLastError()));
end
end
end;
procedure TForm1.ButtonUnDockClick(Sender: TObject);
var
rect: TRect;
begin
if(isDocked) then begin
If SystemParametersInfo(SPI_GETWORKAREA, 0, @rect, 0)
then begin
rect.Top := rect.Top - dockHeight;
if SystemParametersInfo(SPI_SETWORKAREA, 0, @rect, SPIF_SENDCHANGE)
then begin
isDocked := false;
ButtonDock.Enabled := true;
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, 0);
SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
end
else begin
showmessage(string(GetLastError()));
end
end
end
end;
end. |
Partager