// list 是个全局TList实例
bool CALLBACK EnumWindowProc(HWND hwnd,LPARAM lParam)
{
char ClassName[255];
if ( GetClassName(hwnd,ClassName,256)>0 )
{
if ( SameText(ClassName,"TEdit") || SameText(ClassName,"Edit") )
{
list->Add(hwnd);
return true;
}
}
return true;
}
void __fastcall TfrmMain1::Button4Click(TObject *Sender)
{
HWND hWin;
char *buf;
int iLen;
hWin = FindWindow("#32770",NULL);
if (hWin != 0 )
{
list->Clear();
EnumChildWindows(hWin,(WNDENUMPROC)EnumWindowProc,0);
}
char a[10];
for (int i = 0 ; i < list->Count ; i++)
{
HWND hwnd = (HWND)(list->Items);
iLen = SendMessage(hwnd,WM_GETTEXTLENGTH,0,0);
buf = new char[iLen+1];
GetWindowText(hwnd,buf,iLen+1);
ShowMessage(buf);
}
}