Newsgroups: comp.windows.ms.programmer
Path: utzoo!utgpu!watserv1!sunee!gpsteffl
From: gpsteffl@sunee.waterloo.edu (Glenn Patrick Steffler)
Subject: Re: FindWindow() question, not documented(!)
Message-ID: <1991Jan9.164427.7084@sunee.waterloo.edu>
Organization: Gerbils On Speed Inc.
References: <1991Jan9.050715.1567@javelin.es.com>
Date: Wed, 9 Jan 91 16:44:27 GMT
Lines: 43

In article <1991Jan9.050715.1567@javelin.es.com> lwallace@javelin.es.com (Lynn Wallace) writes:
>I'll need to use the FindWinow() function to locate a window by title.  But
>the dox don't say what happens if there's more than one instance of an app
>(window) running.  Does anyone know, or should I call Microsoft?  (What's their
>number?)

I just wrote code to do this for my tool popups last night...lucky you!

FindWindow will indeed find only a single instances window.  However, 
why not just do the following:

hwndNext = GetWindow (hwndParent, GW_HWNDFIRST);
while (hwndNext) {
	if ((GetParent(hwndNExt) == hwndParent) &&
	    (GetWindowLong(hwndNext, GWL_STYLE) & WS_POPUP) {
		// yahoo!  land ho!
		GetWindowText (hwndNext, sz, sizeof(sz)-1);
		if (lstrcmp (sz, "title") == 0)
			break;
	}
}

** by the way, I am doing this from the top of my head.  But it looks right!

The code about assumes the window is a popup window.  Thus is is on the same
level as all top level windows in the manager list.

>I will need to know the handles for all windows matching the title I look for

Not with this code you don't.  In fact I have only 10 globals in my program
of over 180k non-debug compiled.  If I can, a Gerbil could.

>Thanks for any help!
>-- 
>Lynn Wallace			   |I speak for absolutely no one.
>Evans and Sutherland Computer Corp.|


-- 
Co-Op Scum                            "Bo doesn't know software" - George Brett

"The galaxial hearth steams the sea as the sky blood red embrasses darkness"
-John Constantine (HellBlazer)                          Glenn Steffler
