_Leo Site Admin

Registrado: 11 Ago 2002Mensajes: 1875Ubicación: Lanzarote - Islas Canarias (España)
|
Publicado: Mie 11 Sep, 2002 5:06 pm Asunto: |
|
|
Hola:
Necesitaras las funciones del API EnumWindows y GetWindowText
Un ejemplo:
1.- Creamos un proyecto nuevo y añadimos un TListBox (ListBox1) y un TButton (Button1)
2.- Declaramos e implementamos la función de enumeración:
| Código: | ...
private: // User declarations
static bool __stdcall EnumWindowsProc(HWND hWnd, LPARAM lParam);
... |
| Código: | bool __stdcall TForm1::EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
TForm1 *frm = reinterpret_cast<TForm1*>(lParam);
char pszTitulo[256];
if ( GetWindowText(hWnd, pszTitulo, sizeof(pszTitulo)) )
frm->ListBox1->Items->Add( pszTitulo );
return true;
} |
3.- Añadimos el código siguiente al OnClick del Button1:
| Código: | EnumWindows( reinterpret_cast<WNDENUMPROC>(EnumWindowsProc),
reinterpret_cast<LPARAM>(this) );
|
Saludos:
_Leo |
|