Bonjour
J'ai un probl�me avec ShellExecute et c'est le suivant. Je dois contr�ler 2 app externes pour les positionner convenablement dans l'�cran. Pour le faire, j'appelle 2 fois a cette fonction (1 pour chaque application que je dois lancer).
Bon, si Wait et false tout va bien, mais si est true ShellExecute ne fonctionne pas la deuxi�me fois. Le probl�me est dans la fonction LocatedWindows (cherche dans toutes les fen�tres du Desktop un titre pour localiser le handle n�cessaire de la fen�tre pour SetWindowPos) mais je n'arrive a voir pourquoi
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 HWND __fastcall TStep3::EjecApp(AnsiString aFile, bool Wait) { bool Exit = false; int MSec = 0; HWND aHandle = 0; AnsiString aTitle = ""; ShellExecute(this->Handle, "open", (TmpDir + aFile).c_str(), NULL, NULL, SW_NORMAL); if ( !Wait ) return aHandle; do { Sleep(200); MSec = MSec + 200; if (MSec >= 2000) Exit = true; aHandle = LocatedWindows(aTitle, aPartialTitle); } while ( (aHandle != 0) | Exit ); return aHandle; }
Quelqu'un peut m'aider?
Code : S�lectionner tout - Visualiser dans une fen�tre � part
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 HWND __fastcall TStep3::LocatedWindows(AnsiString aTitle) { HWND nHwnd = 0; HWND nInitHwnd = 0; HWND nCurrWnd = 0; int nLength = 0; char * aTitulo = ""; nHwnd = GetDesktopWindow(); nInitHwnd = GetWindow( nHwnd, GW_CHILD ); nCurrWnd = GetWindow( nInitHwnd, GW_HWNDFIRST ); while ( nCurrWnd != 0 ) { nLength = GetWindowTextLength(nCurrWnd); if (nLength > 0) { GetWindowText(nCurrWnd, aTitulo, 255); if ( UpperCase(aTitulo) == UpperCase(aTitle) ) return nCurrWnd; } nCurrWnd = GetWindow( nCurrWnd, GW_HWNDNEXT ); } return 0; }
Merci en avance
Partager