#include <windows.h>
BOOL CALLBACK WindowEnumProc(HWND,LPARAM);
int main(int argc, char* argv[])
{
//search for the main window
//FindWindow(class,caption)
HWND Hwnd = FindWindow(NULL,"Window Caption");
//enum all child windows of the main window
EnumChildWindows(Hwnd,WindowEnumProc,NULL);
return 0;
}
BOOL CALLBACK WindowEnumProc(HWND hwnd, LPARAM lParam)
{
char WinName[256];
GetWindowText(hwnd,WinName,sizeof(WinName));
//try to find a component with Ok caption
if (strcmp(WinName,"OK")==0)
{
//change the component caption!
SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)(LPCTSTR)"Change by silviudog");
}
return TRUE;
}
|