Recent

Author Topic: Block form minimize event [SOLVED]  (Read 1627 times)

Phoenix

  • Jr. Member
  • **
  • Posts: 87
Block form minimize event [SOLVED]
« on: January 17, 2018, 03:41:59 pm »
Hello,
I'd like to find a cross-platform (priority windows, linux) solution to block the form minimize event and in its place run Hide ().

Thanks for every help.
« Last Edit: January 17, 2018, 06:39:41 pm by Phoenix »

RayoGlauco

  • Full Member
  • ***
  • Posts: 176
  • Beers: 1567
Re: Block form minimize event
« Reply #1 on: January 17, 2018, 04:31:45 pm »
Code: [Select]
procedure TForm1.FormWindowStateChange(Sender: TObject);
begin
  if self.WindowState = wsMinimized then self.hide;
end;

If you want to restore the form:

Code: [Select]
self.windowstate:= wsNormal;
I think this works on any platform.
« Last Edit: January 17, 2018, 04:36:38 pm by RayoGlauco »
To err is human, but to really mess things up, you need a computer.

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: Block form minimize event
« Reply #2 on: January 17, 2018, 05:08:37 pm »
Code: [Select]
procedure TForm1.FormWindowStateChange(Sender: TObject);
begin
  if self.WindowState = wsMinimized then self.hide;
end;

Yes, it works on my test on Linux.

Phoenix

  • Jr. Member
  • **
  • Posts: 87
Re: Block form minimize event
« Reply #3 on: January 17, 2018, 06:39:03 pm »
This is a valid solution without blocking the form messages.
It also works on Windows10.

Thank you @RayoGlauco and @Handoko for test!!  :D

 

TinyPortal © 2005-2018