问题
Is it possible to disallow minimizing of a form\application in Delphi ?
I found the following code:
procedure TForm1.WMShowWindow(var Msg: TWMShowWindow);
begin
if not Msg.Show then
Msg.Result := 0
else
inherited;
end;
But if I press windows key + M or WindowsKey + D, then it still gets minimized. Is there a way to prevent this?
回答1:
Setting BorderIcons.bsMinimized to false (removing it from the set) will work for WindowsKey + M but will not stop WindowsKey + D. I think that makes sense. The difference between the two is the first is asking all windows to minimize while the second is an explicit request by the user to see their desktop. Overriding the latter would probably annoy the user (similiar to forcing yourself into focus).
回答2:
or you can place a keyboard hook and catch winkey+d or winkey+m and keep your form maxmized.
回答3:
Just put to the form onShow event such code:
WindowState:=wsMaximized;
And to the OnCanResize this:
if (newwidth<width) and (newheight<height) then
Resize:=false;
来源:https://stackoverflow.com/questions/943551/dont-want-form-to-minimize