Met ShellExecuteEX open ik een programma. Nu wil ik controleren of de gemaakte window ook toplevel is en zo niet, dan moet hij top level worden. Helaas heb ik geen window handle maar alleen een hProcess. Hoe kan ik met die hProcess een window handle krijgen? Als ik ga zoeken kom ik continu op EnumWindows uit. Maar dat moet toch wel anders op te lossen zijn?
Ik heb de volgende code in delphi:
Ik heb de volgende code in delphi:
Delphi:
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
| procedure TStartUpProgram.execute; var ShellExInfo: TShellExecuteInfo; h : HWND; LInput: TLastInputInfo; TimeTest : Cardinal; sl : TstringList; begin try LInput.cbSize := SizeOf(TLastInputInfo); GetLastInputInfo(LInput); TimeTest := LInput.dwTime; FillChar(ShellExInfo, SizeOf(ShellExInfo), 0); with ShellExInfo do begin cbSize := SizeOf(ShellExInfo); fMask := SEE_MASK_FLAG_NO_UI or SEE_MASK_NOCLOSEPROCESS; //Wnd := form1.Handle; lpFile := PChar(prog); nShow := SW_SHOWMAXIMIZED; end; ShellExecuteEx(@ShellExInfo); while (ShellExInfo.HProcess = 0) do begin sleep(1); end; HprocessApp := ShellExInfo.HProcess; sl :=TStringList.Create; FoundWindow1 := false; //sleep(5000); HprocessApp := findwindow(nil,'PowerPoint Slide Show - [test.pps]'); while (foundwindow1 <> true) do begin beep; sl.Clear; enumwindows(@StartAndContinueCode.nextwindow,lparam(sl)); //EnumChildWindows //EnumThreadWindows end; sl.Free; //HprocessApp := GetActiveWindow(); while (WaitForSingleObject (ShellExInfo.HProcess,100) = WAIT_TIMEOUT) do begin SetWindowPos(HprocessApp,HWND_TOPMOST,0,0,screen.Width,screen.Height,0); //beep; Application.ProcessMessages; GetLastInputInfo(LInput); if (LInput.dwTime <> TimeTest) then begin KillProcess(ShellExInfo.hProcess); end; if (Application.Terminated) then begin Break; end; end; closehandle(ShellExInfo.HProcess); BlockForm3Popup := 0; except BlockForm3Popup := 0; exit; end; end; |
[ Voor 32% gewijzigd door Verwijderd op 22-04-2005 14:52 ]