Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#21

AW: Zwei Windows Explorer starten und nebeneinander bildschirmfüllend positionieren

  Alt 15. Jul 2015, 08:21
Nach dem gleichen Verfahren lassen sich auch 2 IEXPLORE.exe anzeigen.
Es sind nur geringe Änderungen erforderlich.

Delphi-Quellcode:
unit Unit1; //20150630 20150715

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Winapi.ShellApi, Vcl.StdCtrls, Winapi.ShlObj, Winapi.ActiveX, System.Win.ComObj;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    bnClose: TButton;
    bnMax: TButton;
    bnMin: TButton;
    Button1: TButton;
    Button2: TButton;
    procedure FormShow(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure bnCloseClick(Sender: TObject);
    procedure bnMaxClick(Sender: TObject);
    procedure bnMinClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    procedure ExplorerStart(aPanel: TPanel; aDirectory: string);
  protected

  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  SetWindowLong(Handle, GWL_STYLE, (GetWindowLong(Handle, GWL_STYLE) and not WS_Caption));
end;

procedure TForm1.bnMaxClick(Sender: TObject);
begin Perform(WM_SYSCOMMAND,SC_MAXIMIZE,0); end;

procedure TForm1.bnMinClick(Sender: TObject);
begin Perform(WM_SYSCOMMAND,SC_MINIMIZE,0); end;

procedure TForm1.Button2Click(Sender: TObject);
begin //
end;

procedure TForm1.ExplorerStart(aPanel: TPanel; aDirectory: string);
var SEI: TShellExecuteInfo;
begin
  aPanel.Caption := aDirectory;
  FillChar(SEI, SizeOf(SEI), #0);
  SEI.cbSize := SizeOf(SEI);
  SEI.Wnd := Handle;
  SEI.fMask := SEE_MASK_NOCLOSEPROCESS;
  SEI.lpVerb := 'open';
  SEI.lpFile := PChar('iexplore.exe'); // <--------------------
  SEI.lpParameters := PChar(aDirectory);
  SEI.lpDirectory := nil;
  SEI.nShow := SW_MINIMIZE;
  if ShellExecuteEx(@SEI) then begin
    if SEI.hProcess > 32 then begin
      Sleep(500);
      aPanel.Tag := FindWindow('IEFrame',nil); // <--------------------
      if aPanel.Tag > 0 then begin
        Winapi.Windows.SetParent(aPanel.Tag, aPanel.Handle);
        SetWindowLongPtr(aPanel.Tag, GWL_STYLE, GetWindowLongPtr(aPanel.Tag, GWL_STYLE)
        and not WS_BORDER);
        SetWindowPos(aPanel.Tag, HWND_TOP, Left, Top, Width, Height, SWP_FRAMECHANGED);
      end;
    end;
  end;
  CloseHandle(SEI.hProcess);
end;
//------------------------------------------------------------------------------
procedure TForm1.FormDestroy(Sender: TObject);
begin
  if Panel1.Tag > 0 then PostMessage(Panel1.Tag, WM_CLOSE, 0, 0);
  if Panel2.Tag > 0 then PostMessage(Panel2.Tag, WM_CLOSE, 0, 0);
end;

procedure TForm1.bnCloseClick(Sender: TObject);
begin Application.Terminate; end;

procedure TForm1.FormResize(Sender: TObject);
begin
  Panel1.Width := ClientWidth div 2;
  if Panel1.Tag > 0 then MoveWindow(Panel1.Tag, 0, 0, Panel1.Width, Panel1.Height, True);
  if Panel2.Tag > 0 then MoveWindow(Panel2.Tag, 0, 0, Panel2.Width, Panel2.Height, True);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  ExplorerStart(Panel1,'-new www.web.de'); // <------------ // Sample
  ExplorerStart(Panel2,'-new www.google.de'); // <------------// Sample
end;

end.
Miniaturansicht angehängter Grafiken
iexplore2x.jpg   wetter-lte-1.jpg  

Geändert von hathor (15. Jul 2015 um 08:36 Uhr)
  Mit Zitat antworten Zitat