//实现使窗口的关闭变灰(h: 窗口的句柄) function GrayedCloseItem(h: HWND): Boolean; var hM: HMENU; begin if h <> 0 then //有效句柄 begin hM := GetSystemMenu(h, False); result := EnableMenuItem(hM,SC_CLOSE,MF_BYCOMMAND+MF_DISABLED+MF_GRAYED); end else result := False; end;//实现使窗口的关闭有效(h: 窗口的句柄) function EnableCloseItem(h: HWND): Boolean; var hM: HMENU; begin if h <> 0 then //有效句柄 begin hM := GetSystemMenu(h, False); result := EnableMenuItem(hM,SC_CLOSE,MF_BYCOMMAND+MF_ENABLED); end else result := False; end;
答案在这个贴里
打错,是这个贴
或者你把borderstyle改为bsSingle或者bsDialog就可以了
把bordericons的bmaximize和bminimize改为False!
function GrayedCloseItem(h: HWND): Boolean;
var
hM: HMENU;
begin
if h <> 0 then //有效句柄
begin
hM := GetSystemMenu(h, False);
result := EnableMenuItem(hM,SC_CLOSE,MF_BYCOMMAND+MF_DISABLED+MF_GRAYED);
end
else
result := False;
end;//实现使窗口的关闭有效(h: 窗口的句柄)
function EnableCloseItem(h: HWND): Boolean;
var
hM: HMENU;
begin
if h <> 0 then //有效句柄
begin
hM := GetSystemMenu(h, False);
result := EnableMenuItem(hM,SC_CLOSE,MF_BYCOMMAND+MF_ENABLED);
end
else
result := False;
end;
或者你把borderstyle改为bsSingle或者bsDialog就可以了