Autor Beitrag
djmasi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54

Win XP Prof. Tablet PC Edition 2005
D7 Enterprise
BeitragVerfasst: Mi 23.04.03 14:33 
Ich versuche mit CreateProcess aus meiner Anwendung ein Programm zu starten. Funktioniert auch. Aber ich will die Größe und die Position des Fensters angeben. SetWindowPos geht rein theoretisch, jedoch habe ich beim Starten das Handle noch nicht. Bei CreateProcess gib es die Möglichkeit das einzustellen, es wird aber bei mir anscheinend nicht unterstützt. Hier der Code:
ausblenden volle Höhe Quelltext
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:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
unit Unit1;

interface

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

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

var
  Form1: TForm1;
  TListe: TList;
  FensterHandle: HWND;


implementation

{$R *.dfm}
function RunProcess(FileName: string): Longword;
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  FillChar(StartupInfo, SizeOf(StartupInfo),#0);
  StartupInfo.cb          := SizeOf(StartupInfo);
  StartupInfo.dwFlags     := STARTF_USEPOSITION and STARTF_USESHOWWINDOW and STARTF_USESIZE;
  StartupInfo.dwX         := 100;
  StartupInfo.dwY         := 100;
  StartupInfo.wShowWindow := SW_SHOWDEFAULT;
  StartupInfo.dwXSize     := 600;
  StartupInfo.dwYSize     := 400;
  if not CreateProcess(nil,
    @Filename[1],
    nil,
    nil,
    True,
    CREATE_NEW_CONSOLE or
    NORMAL_PRIORITY_CLASS,
    nil,
    nil,
    StartupInfo,
    ProcessInfo)
    then
      Result := WAIT_FAILED;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Close
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  RunProcess('D:\Microsoft Office\Office10\WinWord.exe');
end;

end.


Die StartUpInfo wird wahrscheinlich nicht richtig verarbeitet. Habe ich einen Fehler in meinem Quelltext oder ist das ein allgemeines Problem???
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mi 23.04.03 17:06 
tja, grad office merkt sich beim beenden den letzten Fensterpos. Ich schätze, das deine gwünschten Einstellungen zwar ausgeführt aber durch die Anwendung ignoriert werden.
grez
msch
djmasi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54

Win XP Prof. Tablet PC Edition 2005
D7 Enterprise
BeitragVerfasst: Do 24.04.03 07:56 
Dem ist glaube ich nicht so. Denn es gibt ein Programm (in Delphi geschrieben) welches das wunderbar hinbekommt. Nur leider ist da kein Quellcode dazu. Dieses Programm setzt jede Anwendung auf eine bestimmte Größe nd Position. Das Hauptprogramm wird darübergelegt (teilweise transparent) und die Statusleiste und sonstiges wird durch die Oberfläche bedeckt. Vielleicht wird es durch andere Prozeduren/Funktionen geregelt.
Ich habe es auch mit anderen Programmen ausprobiert (Notepad, iexplorer,...) und jedesmal das selbe Ergebnis - ich kann es minimieren, maximieren, aber nicht direkt die Position und Größe angeben.
Falls doch jemand eine Möglichkeit hat bitte bitte schnell melden. :wink: