AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Ist Programm minimiert / in der Taskleiste?

Ein Thema von Alien426 · begonnen am 4. Jun 2006 · letzter Beitrag vom 11. Jun 2006
 
Heffalump

Registriert seit: 3. Aug 2005
278 Beiträge
 
RAD-Studio 2009 Ent
 
#8

Re: Ist Programm minimiert / in der Taskleiste?

  Alt 10. Jun 2006, 10:55
Und noch eine komplizierte Lösung (welchen nicht nur den minimiert oder maximiert Status speichert)
Delphi-Quellcode:
unit Unit2;

interface

uses Forms, IniFiles, Windows, Classes;

type
  Bytes = array of byte;

procedure SaveWindowPlacement(pvForm: TForm; pvIniFile: String);
procedure RestoreWindowPlacement(pvForm: TForm; pvIniFile: String);

implementation

procedure SaveWindowPlacement(pvForm: TForm; pvIniFile: String);
var lvIniFile: TIniFile;
    lvWindowPlacement: Bytes;

    function WindowPlacementToStr(pvWindowPlacement: Bytes):String;
    var lvSize: Byte;
    begin
      lvSize := SizeOf(TWindowPlacement);
      SetLength(Result,lvSize*2);
      BinToHex(@pvWindowPlacement[0],@Result[1],lvSize);
    end;

begin
  if pvForm = nil then Exit;
  if Length(pvIniFile)=0 then Exit;

  lvIniFile := TIniFile.Create(pvIniFile);
  SetLength(lvWindowPlacement,SizeOf(TWindowPlacement));
  TWindowPlacement((@lvWindowPlacement[0])^).length:=SizeOf(TWindowPlacement);

  if Windows.GetWindowPlacement(pvForm.Handle, @lvWindowPlacement[0]) then
    begin
    lvIniFile.WriteString(pvForm.Name,'WindowPlacement',WindowPlacementToStr(lvWindowPlacement));
    end;

  lvIniFile.Free;
end;

procedure RestoreWindowPlacement(pvForm: TForm; pvIniFile: String);
var lvIniFile: TIniFile;
    lvWindowPlacement: Bytes;

    function StrToWindowPlacement(pvWindowPlacement: String): Bytes;
    var lvSize: Byte;
    begin
      lvSize := SizeOf(TWindowPlacement);
      if length(pvWindowPlacement)<>(lvSize*2) then Result := nil;
      SetLength(Result,lvSize);
      HexToBin(@pvWindowPlacement[1],@Result[0],lvSize);
    end;

begin
  if pvForm = nil then Exit;
  if Length(pvIniFile)=0 then Exit;

  lvIniFile := TIniFile.Create(pvIniFile);

  if lvIniFile.ValueExists(pvForm.Name,'WindowPlacement') then
    begin
    lvWindowPlacement := StrToWindowPlacement(lvIniFile.ReadString(pvForm.Name,'WindowPlacement',''));
    if lvWindowPlacement <> nil then Windows.SetWindowPlacement(pvForm.Handle,@lvWindowPlacement[0]);
    end;

end;

end.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz