Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Ausführen... Fenster öffnen (https://www.delphipraxis.net/139916-ausfuehren-fenster-oeffnen.html)

schwa226 8. Sep 2009 11:27


Ausführen... Fenster öffnen
 
Hi,

per:

Delphi-Quellcode:
var
Shell : OleVariant;
begin
Shell := CreateOleObject('Shell.Application');
Shell.FileRun;
Shell := Unassigned;
end;
kann man den Dialog "Ausführen..." öffnen.

Da ich aber an einem Shell Ersatz schreibe und die explorer.exe nicht geladen ist geht das nicht!?
Delphi-Quellcode:
Shell.ControlPanelItem('timedate.cpl');
(zeigt Eigenschaften der Uhr an)

Geht aber trotzdem!?

Das Interface geht also anscheinend aber wieso wird dann der RUN-Dialog nicht geöffnet?

Kennt jemand eine andere Art diesen Dialog zu öffnen?

Auch geht:
Delphi-Quellcode:
Shell.MinimizeAll;
nur wenn die explorer.exe geladen ist. Hier ist das gleiche Verhalten wie mit FileRun.

Sprint 8. Sep 2009 11:39

Re: Ausführen... Fenster öffnen
 
Ich hatte vor einigen Jahren mal einen Task Manager Clone geschrieben.
Kannst ja mal gucken ob's bei dir läuft.

Delphi-Quellcode:
function RunFileDlgWinNT(hWnd: HWND; hIcon: HICON; lpstrDirectory, lpstrTitle,
  lpstrDescription: LPWSTR; uFlags: UINT): DWORD; stdcall; external 'SHELL32.DLL' index 61;

function RunFileDlgWin95(hWnd: HWND; hIcon: HICON; lpstrDirectory, lpstrTitle,
  lpstrDescription: LPCSTR ; uFlags: UINT): DWORD; stdcall; external 'SHELL32.DLL' index 61;
Delphi-Quellcode:
const
  DLG_TITLE = 'Neuen Task erstellen';
begin
  if Win32Platform = VER_PLATFORM_WIN32_NT then
    RunFileDlgWinNT(Self.Handle, Application.Icon.Handle, nil, DLG_TITLE, nil, 0)
  else
    RunFileDlgWin95(Self.Handle, Application.Icon.Handle, nil, DLG_TITLE, nil, 0);

schwa226 8. Sep 2009 13:01

Re: Ausführen... Fenster öffnen
 
Super Danke für deine Hilfe!

Dadurch habe ich auch noch das gefunden:

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ This code uses the undocumented RunFileDlg function to show the "run" dialog }
{ Dieser Code verwendet die undokumentierte RunFileDlg Funktion, um den Ausführen Dialog anzuzeigen }
// For Win NT
procedure RunFileDlgW(OwnerWnd: HWND; Icon: HICON; lpstrDirectory: PWideChar;
  lpstrTitle: PWideChar; lpstrDescription: PWideChar; Flags: Longint); stdcall;
  external 'Shell32.dll' Index 61;
// For Win 9x (Win NT to show standard captions )
procedure RunFileDlg(OwnerWnd: HWND; Icon: HICON; lpstrDirectory: PChar;
  lpstrTitle: PChar; lpstrDescription: PChar; Flags: Longint); stdcall;
  external 'Shell32.dll' Index 61;

const
  RFF_NOBROWSE = 1; //Removes the browse button.
  RFF_NODEFAULT = 2; // No default item selected.
  RFF_CALCDIRECTORY = 4; // Calculates the working directory from the file name.
  RFF_NOLABEL = 8; // Removes the edit box label.
  RFF_NOSEPARATEMEM = 14; // Removes the Separate Memory Space check box (Windows NT only)

function ShowRunFileDialg(OwnerWnd: HWND; InitialDir, Title, Description: PChar;
  flags: Integer; StandardCaptions: Boolean): Boolean;
var
  HideBrowseButton: Boolean;
  TitleWideChar, InitialDirWideChar, DescriptionWideChar: PWideChar;
  Size: Integer;
begin
  if (Win32Platform = VER_PLATFORM_WIN32_NT) and not StandardCaptions then
  begin
    Size := SizeOf(WideChar) * MAX_PATH;
    InitialDirWideChar := nil;
    TitleWideChar := nil;
    DescriptionWideChar := nil;
    GetMem(InitialDirWideChar, Size);
    GetMem(TitleWideChar, Size);
    GetMem(DescriptionWideChar, Size);
    StringToWideChar(InitialDir, InitialDirWideChar, MAX_PATH);
    StringToWideChar(Title, TitleWideChar, MAX_PATH);
    StringToWideChar(Description, DescriptionWideChar, MAX_PATH);
    try
      RunFileDlgW(OwnerWnd, 0, InitialDirWideChar, TitleWideChar, DescriptionWideChar, Flags);
    finally
      FreeMem(InitialDirWideChar);
      FreeMem(TitleWideChar);
      FreeMem(DescriptionWideChar);
    end;
  end else
    RunFileDlg(OwnerWnd, 0, PChar(InitialDir), PChar(Title), PChar(Description), Flags);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 ShowRunFileDialg(Self.Handle, nil, nil, nil, 0, True);
end;

end.
Geht einwandfrei, auch bei nicht gestarteten explorer.exe!

Jetzt brauch ich noch den Index für MinimizeAll...

Sprint 8. Sep 2009 14:04

Re: Ausführen... Fenster öffnen
 
Zitat:

Zitat von schwa226
Jetzt brauch ich noch den Index für MinimizeAll...

Kannst du doch selber machen. In dem du mit EnumWindows die vorhanden Fenster ermittelst. Guckst ob es sich um TopLevel Fenster handelt
und diese sichtbar sind. Dann schickst du WM_SYSCOMMAND und SC_MINIMIZE an die Fenster und gut ist.


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz