1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| procedure TFormTest.BtnExplorerClick(Sender: TObject);
var
HandleEx: Cardinal;
Dir: string;
CountTest: Integer;
begin
Dir := InputBox('Dossier à Visualiser', 'Saisissez le Répertoire', ExtractFileDir(Application.ExeName));
HandleEx := ShellExecute(Self.Handle, 'open', PChar(Dir), nil, nil, SW_HIDE);
Sleep(100);
HandleByClass := 0;
CountTest := 0;
while (HandleByClass = 0) and (CountTest < 1000) do
begin
HandleByClass := FindWindow('CabinetWClass', PChar(Dir));
Inc(CountTest);
Sleep(1);
end;
HandleChild := FoundChild(HandleByClass, 'SysListView32', 'FolderView');
// HandleChild := FoundChild(HandleByClass, 'SHELLDLL_DefView', '');
if HandleChild > 0 then
begin
HandleOld := SetParentEx(HandleChild, PanelDialog.Handle)
end;
ShowMessageFmt('Ex %d, Class %d, Child %d, Old %d', [HandleEx, HandleByClass, HandleChild, HandleOld]);
end;
procedure TFormTest.BtnExplorerShImgVwClick(Sender: TObject);
var
HandleByClass: Cardinal;
Path: string;
CountTest: Integer;
Box: TScrollBox;
Panel: TPanel;
begin
Path := InputBox('Fichier à Visualiser', 'Saisissez le Fichier', ExtractFilePath(Application.ExeName));
ShellExecute(Self.Handle, 'open', 'rundll32.exe', PChar('C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen ' + Path), nil, SW_NORMAL);
Sleep(100);
HandleByClass := 0;
CountTest := 0;
while (HandleByClass = 0) and (CountTest < 1000) do
begin
HandleByClass := FindWindow('ShImgVw:CPreviewWnd', nil);
Inc(CountTest);
Sleep(1);
end;
if HandleByClass > 0 then
begin
ShowWindow(HandleByClass, SW_RESTORE);
SetWindowPos(HandleByClass, 0, Application.MainForm.Left + Application.MainForm.Width, Application.MainForm.Top, Screen.WorkAreaWidth - (Application.MainForm.Left + Application.MainForm.Width), Application.MainForm.Height, SWP_SHOWWINDOW);
end;
// ShowMessageFmt('Ex %d, Class %d, Child %d, Old %d', [HandleEx, HandleByClass, HandleChild, HandleOld]);
end; |
Partager