Subscribe:

Ads 468x60px

Loading

Senin, 04 Juli 2011

Disabling close button of a window

Question:

Is it possible to disable the close button of any given Window?
Answer:

Yes, the following example disables the close button (and close option from the system menu) of the given Window.



procedure TForm1.Button1Click(Sender: TObject);

var

hwndHandle : THANDLE;

hMenuHandle : HMENU;

begin

hwndHandle := FindWindow(nil, 'Untitled - Notepad');

if (hwndHandle <> 0) then begin

hMenuHandle := GetSystemMenu(hwndHandle, FALSE);

if (hMenuHandle <> 0) then

DeleteMenu(hMenuHandle, SC_CLOSE, MF_BYCOMMAND);

end;

end;

0 komentar:

Posting Komentar