본문 바로가기

카테고리 없음

[윈도우즈 API] 윈도우즈"시작" 버튼 Disable/Enable

unit Unit1;

interface

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

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 DlsableStartButton(Force: Boolean);
begin
  if Force then
    EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil), False)
  else
    EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil), True);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  // "시작" 버튼 Disable
  DlsableStartButton(True);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  // "시작" 버튼 Enable
  DlsableStartButton(False);
end;

end.