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 70 71 72 73
|
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->listView->Items->Clear();
EnumWindows(WNDENUMPROC (EnumWindowsProc), 0);
}
LRESULT CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
{
char szClass[128];
GetClassName( hwnd, szClass, sizeof(szClass) );
if(!strcmp(szClass, "IEFrame"))
{
// Recherche des classes Enfants
EnumChildWindows(hwnd, WNDENUMPROC(EnumChildProc),0);
char szTitre[128];
GetWindowTextA(hwnd, szTitre, sizeof(szTitre));
bool trouver = false;
for(int i=0; i<Form1->listView->Items->Count && trouver==false; i++)
{
if( AnsiString(szTitre) == Form1->listView->Items->Strings[i] )
trouver = true;
}
if(!trouver) // titre des nouvelles fenetre IE
Form1->listView->Items->Add( szTitre );
}
return true;
}
//Avec cette methode : lire les url ne fonctionne pas si on utilise des onglets !!!
LRESULT CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
{
// Type de classe enfant :
// WorkerW||WorkerA; ReBarWindow32; ComboBoxEx32; ComboBox; Edit.
char szClass[128];
GetClassName( hwnd, szClass, sizeof(szClass) );
if(!strcmp(szClass, "Edit"))
{
char szTitre[128];
SendMessage(hwnd,WM_GETTEXT,sizeof(szTitre),LPARAM(szTitre));
Form1->listView->Items->Add( szTitre );
}
return true;
}
//Avec cette methode : c'est réussi, même si vous utilisez des onglets dans IE6
//cela fonctionne, il faut retirer la condition "IEframe"
LRESULT CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
{
char szTitre[128]; GetClassName(hwnd, szTitre, sizeof(szTitre) );
SendMessage(hwnd,WM_GETTEXT,sizeof(szTitre),LPARAM(szTitre));
if( (strstr(szTitre, "http") !=NULL)
|| (strstr(szTitre, "www") !=NULL) )
Form1->listView->Items->Add( szTitre );
return true;
} |
Partager