Главная страница | назад





Article #16585: Disabling close button of a window

 Question and Answer Database
FAQ1585D.txt Disabling close button of a window
Category :Windows API
Platform :All
Product :All 32 bit
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;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99