Einzelnen Beitrag anzeigen

Benutzerbild von APP
APP

Registriert seit: 24. Feb 2003
Ort: Graz (A)
705 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: Minimieren eines Fensters (bei MDI anwendung)

  Alt 2. Aug 2003, 21:16
Hallo,
kopiere folgenden Code in einen onClick Event eines Buttons:
Delphi-Quellcode:
type
    { Array of form references }
    A_TForm = Array [0 .. (($fff0 div SizeOf(TForm)) - 1)]
        of TForm;
var
    ChildCount: Integer;
    CurrentMDIChildCount: Integer;
    CurrentMDIChildren: ^A_TForm;
begin
    { For some reason Delphi messes around with the MDIChildren array
      when child forms are repositioned in code, causing the routine to
      suddenly start accessing the wrong form in the middle of an
      iteration! To get around this problem, allocate some memory to
      make copies of the main form's MDIChildren array and use this
      copy throughout the rest of the routine }

    CurrentMDIChildCount := MDIChildCount;
    CurrentMDIChildren := AllocMem(CurrentMDIChildCount
        * SizeOf(CurrentMDIChildren^[0]));

    try
        { Copy all the child form references to the local
          array }

        for ChildCount := 0 to CurrentMDIChildCount - 1 do
            CurrentMDIChildren^[ChildCount] :=
                MDIChildren[ChildCount];

        for ChildCount := CurrentMDIChildCount - 1 downto 0 do
            CurrentMDIChildren^[ChildCount].WindowState := wsMinimized;

    finally
        { Free the memory allocated to the array of form
          references }

        FreeMem(CurrentMDIChildren, CurrentMDIChildCount
            * SizeOf(CurrentMDIChildren^[0]));
    end; { end try }

end;
Autor: Steve Turner, Leeds, England (gefunden in einer NewsGroup)
Armin P. Pressler

BEGIN
...real programmers are using C/C++ - smart developers Delphi;
END;
  Mit Zitat antworten Zitat