Forum > Options

'Minimize all on minimize main' disabled

<< < (3/3)

Drewski:
There is a bug that is related to your question: http://www.lazarus.freepascal.org/mantis/view.php?id=1058

Anonymous:
Yipiee! I've got a Lazarus (GTK/Linux) which minimizes and restores all children.
Previous state ("was minimized") ist taken care of and Z-Order is prevented.
It's a hack, because it uses a Timer to find out Main Window State. (Because of missing event)
Window States are adjusted by
XInternAtom(Display, 'WM_STATE', true); and so on.
Nothing serious but: My Linux-Lazarus minimizes all of it!

Anonymous:
If somebody cares: here's the code
"GetState" is from xutils http://www.tempest-sw.com/freeware/freeware.cgi?kylix



--- Code: ---procedure TMainIDE.OnMinTimer(Sender: TObject);
var i: Integer;
  AForm: TCustomForm;
  Winfo: TWinInfo;
begin
  if Screen = nil then exit;

  AdjustWinStateInfo(MainIDEBar);
  if MainIDEBar.WindowState = WsMinimized then begin
    if not fStateMinimized then
    begin
      fWinList.clear;

      for i := 0 to Screen.CustomFormCount - 1 do begin
        AForm := Screen.CustomForms[i];
        if (AForm.Parent = nil) and AForm.HandleAllocated then
        begin
          AdjustWinStateInfo(TForm(AForm));

          if AForm.WindowState <> wsminimized then
          begin
            fWinList.add(AForm);
            ShowWindow(AForm.Handle, SW_MINIMIZE);
          end;
        end;
      end;
    end;
    fStateMinimized := true;
  end else begin
    if fStateMinimized then
    begin
      for i := fWinList.Count - 1 downto 0 do begin
        AForm := TForm(fWinList[i]);
        if (AForm.Parent = nil) and AForm.HandleAllocated then begin
          if AForm.Visible then ShowWindow(AForm.Handle, SW_SHOWNORMAL);
        end;
      end; //scr
    end; //statemin
    fStateMinimized := false;
    MainIDEBar.SetFocus;
    MainIDEBar.Refresh;
  end;
end;

function TMainIDE.GetMinimized(FHandle: HWND): Boolean;
var
  XDisplay: PDisplay;
  XScreen: PScreen;
  XWindow: x.TWindow;
begin
  XDisplay := GDK_WINDOW_XDISPLAY(PGdkWindowPrivate(PGtkWidget(FHandle)^.window));
  XScreen := XDefaultScreenOfDisplay(XDisplay);
  XWindow := GDK_WINDOW_XWINDOW(PGdkWindowPrivate(PGtkWidget(FHandle)^.window));
  Result := GetState(XDisplay, XWindow) = IconicState;
end;

procedure TMainIDE.AdjustWinStateInfo(Window: TForm);
begin
  if GetMinimized(Window.Handle) then
  begin
    if Window.WindowState <> wsMinimized then Window.WindowState := wsMinimized;
  end else
  begin
    if Window.WindowState <> wsNormal then Window.WindowState := wsNormal;
  end;
end;                        
--- End code ---

Marc:
Thanks.
I don't think we will go throught the timer solution, but it gives an idea in what direction to look for a solution.

Navigation

[0] Message Index

[*] Previous page

Go to full version