Einzelnen Beitrag anzeigen

mm1256

Registriert seit: 10. Feb 2014
Ort: Wackersdorf, Bayern
640 Beiträge
 
Delphi 10.1 Berlin Professional
 
#11

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

  Alt 27. Jun 2015, 07:51
Hallo,

also wenn ihr schon den Overhead mit einem eigenen Formular bzw. einer VCL-Anwendung gehen wollt, dann nimmt man einfach zwei (oder mehrere) Panels und klatscht da jeweils eine Explorer-Instanz hinein. Das ist nicht mehr als ein 2-Minuten-Programm.

In Beispiel ist Panel1.Align = alLeft und Panel2.Align = alClient.

Delphi-Quellcode:
unit uWinExplorer2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;

type
  TFrmExplorer2 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    procedure FormShow(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    procedure ExplorerStart(aPanel: TPanel;
                            aDirectory: string);
  end;

var
  FrmExplorer2: TFrmExplorer2;

implementation

{$R *.dfm}

uses ShellApi;

procedure TFrmExplorer2.ExplorerStart(aPanel: TPanel;
                                      aDirectory: string);
var
  SEI: TShellExecuteInfo;
  Style: Integer;
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('explorer.exe');
  SEI.lpParameters := PChar(aDirectory);
  SEI.lpDirectory := nil;
  SEI.nShow := SW_SHOWMAXIMIZED;
  if ShellExecuteEx(@SEI) then begin
    if SEI.hProcess > 32 then begin
      Sleep(500);
      aPanel.Tag := FindWindow('CabinetWClass',nil);
      if aPanel.Tag > 0 then begin
        Winapi.Windows.SetParent(aPanel.Tag, aPanel.Handle);
        Style := GetWindowLong(aPanel.Tag, GWL_STYLE);
        SetWindowLong(aPanel.Tag, GWL_STYLE, Style and NOT WS_BORDER );
      end;
    end;
  end;
  CloseHandle(SEI.hProcess);
end;

procedure TFrmExplorer2.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 TFrmExplorer2.FormShow(Sender: TObject);
begin
  Caption := 'Windows-Explorer mit zwei Fenstern';
  ExplorerStart(Panel1,'C:\Windows');
  ExplorerStart(Panel2,'C:\Users');
end;

end.
Gruss Otto
Wenn du mit Gott reden willst, dann bete.
Wenn du ihn treffen willst, schreib bei Tempo 220 eine SMS
  Mit Zitat antworten Zitat