본문 바로가기

카테고리 없음

[윈도우즈 API] 윈도우즈 "시작" 메뉴 표시하기/감추기

반응형
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

// 윈도우즈 "시작" 메뉴 표시하기
procedure TForm1.Button1Click(Sender: TObject);
var
  taskbar: HWND;
begin
  taskbar := FindWindow('Shell_TrayWnd', '');
  if (taskbar <> 0) then
  begin
    SetForegroundWindow(hTaskBar);
    PostMessage(taskbar, WM_USER+260, 0, 0);
  end;

  // 또는 아래와 같이
  // Sendmessage(Application.Handle,WM_SYSCOMMAND,SC_TASKLIST,0);
end;

// 윈도우즈 "시작" 메뉴 감추기
procedure TForm1.Button2Click(Sender: TObject);
var
  taskbar: HWND;
begin
  taskbar := FindWindow('Shell_TrayWnd', '');
  if (taskbar <> 0) then
    PostMessage(taskbar, WM_USER+261, 0, 0);
end;

end.
반응형