Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Title bar text from child window of MDI App

Status
Not open for further replies.

M8KWR

Programmer
Aug 18, 2004
864
0
0
GB
Hi all,

I need to be able to obtain the text from the title bar of a child window of a seperate MDI application.

Any help would be much appreciated; and thanks in advance.

 
You can pass a user defined parameter in LPARAM so I'll leave the return of the window text to you.
In the EnumWindowProc or EnumChildProc you can pass your own type (AKA ProcessInfo_t)....
ProcessInfo_t * processInfo;
processInfo = reinterpret_cast<ProcessInfo_t*>(lParam);


In the header file of the C++ app add the following:
bool CBogusDlg::FindDesiredWindow(UINT state);

static BOOL WINAPI EnumWindowsProc(HWND hwnd, LPARAM lParam);
static BOOL WINAPI EnumChildProc(HWND hwnd, LPARAM lParam);

In the cpp file add:


bool CBogusDlg::FindDesiredWindow(UINT state)
{
int bogus;
// If a name wasn't supplied, don't bother.
EnumWindows(EnumWindowsProc, (LPARAM)(&bogus));
return false;
}

BOOL WINAPI CBogusDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
int bogus;
// char title[100];

EnumChildWindows(hwnd, EnumChildProc, (LPARAM)(&bogus));
// ::GetWindowText(hwnd, title, 100);


return 1;

}

BOOL WINAPI CBogusDlg::EnumChildProc(HWND hwnd, LPARAM lParam)
{
char title[100];

::GetWindowText(hwnd, title, 100);

TRACE("%s\n", title);
return 1;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top