Dont want form to minimize

北慕城南 提交于 2021-02-05 08:49:26

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!