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.