Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FindWindow With regular expression

228 views
Skip to first unread message

Yaniv Refael

unread,
Oct 1, 2009, 5:50:58 AM10/1/09
to
Hi

I need to get window hwnd and the title of the window is change evrey few
secondes.
how can I Use the FindWindow function with regular expression or any
different way to get the window hwnd

Remy Lebeau

unread,
Oct 1, 2009, 2:17:42 PM10/1/09
to

"Yaniv Refael" <Yaniv....@live.com> wrote in message
news:F24CAB74-064E-4924...@microsoft.com...

> how can I Use the FindWindow function with regular expression

You can't.

> or any different way to get the window hwnd

Use EnumWindows() to loop through all available windows, calling
GetWindowText() on each one and then comparing it as needed. When you find
a match, return it via the callback's lParam value. For example:

BOOL CALLBACK FindWindowWithExpr(HWND hwnd, LPARAM lParam)
{
TCHAR szText[256] = {0};
GetWindowText(hWnd, szText, 255);

if (szText matches your regular expression)
{
*((HWND*) lParam) = hWnd;
return FALSE;
}

reutrn TRUE;
}

{
HWND hWnd = NULL;
EnumWindows((WNDENUMPROC)&FindWindowWithExpr, (LPARAM)&hWnd);
if (hWnd != NULL)
...
}

--
Remy Lebeau (TeamB)\


0 new messages