Search code examples
delphimaximize-window

Disable form restoring on title doubleclick


  1. Create an empty Delphi VCL project
  2. Remove all BorderIcons of main form
  3. Set WindowState to wsMaximized
  4. Run application. Main window appears maximized.
  5. Double click on window title. Main window restores it's size and there is no possibility to maximize it again.

How to prevent window restoring on title double click without hiding title bar?


Solution

  • You can intercept the restore and additionally the move system commands to prevent restoring by dragging the caption.

    type
      TForm1 = class(TForm)
      protected
        procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
    
    ...
    
    procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
    begin
      case Message.CmdType and $FFF0 of
        SC_MOVE, SC_RESTORE: Exit;
      end; 
      inherited;
    end;