Solved

FindWindowEx to find Child Window

Posted on 1997-02-26
6
2,785 Views
Last Modified: 2013-12-04
am attempting to test for the existence of a child window with a specific
name using FindWindowEx, and I am coming up empty.

The parent form is of class TAFOSParent and the child is a TMainForm in the
example below.  EditFile is the name of the child window I am looking for.
The FindWindow function does successfully find the handle of the parent
window.  However, the only way I can get a child window handle from
FindWindowEx is to set the class name and window name pointers both to NIL,
and of course that handle is not to the window I am looking for.  What may
I be doing wrong (I created the program that creates the window in
question, if the problem is likely there).

    HParentWindow:=FindWindow('TAFOSParent','AFOSED');
    ClassName:='TMainForm';
    repeat
      SleepEx(3000,false);
      Y:=FindWindowEx(HParentWindow,0,PChar(ClassName),PChar(EditFile));
    until Y=0;
0
Comment
Question by:sooman
6 Comments
 
LVL 3

Expert Comment

by:sperling
ID: 1299081
Have you used a spy program to make absolutely sure the spelling and case of both class and window name are correct?

Is this a MDI app?



0
 
LVL 3

Expert Comment

by:gaohong
ID: 1299082
Hi:

If you sure the name and class is same, then check if the window
with name EditFile is one of DIRECT child of the parent window.
Documentation stressed that it must be direct child. In this case

Y:=FindWindow(PChar(ClassName),PChar(EditFile)); may be a better
choice.  If this one fails, then you have to find your window
through child window chain, until you locate what you want.

Hope this helps

Gaohong Xie
0
 

Author Comment

by:sooman
ID: 1299083
I stress that I CAN get A child window when I specify NIL (NUL) for both the Child window class name and name pointers when using FindWindowEx, which I would assume means that my child windows ARE direct decendents.  Besides, having made the program containing the child windows I know they are direct decendents and that it is an MDI application.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:manfred022897
ID: 1299084
There a two low-level ways to walk the child windows list:
- use GetTopWindow() / GetNextWindow()
- use EnumChildWindows()

both work, but the first one is unsafe (cannot handle the case of one child being destroyed whilöe walking the list). FindWindowEx is probably using the second method.
So, I would recommend you just try those ways to walk your children list and dump any class names/window names you find. Maybe you find that your child is really not in this list.
0
 
LVL 1

Accepted Solution

by:
pavel030297 earned 70 total points
ID: 1299085
You always call FindWindowEx with the second parameter (child window handle) set to 0. Then FindWindowEx always starts search from the first child in Z order. Try set the second parameter to the handle You got in previous iteration, like this:
  Y := FindWindowEx(HParentWindow,Y,PChar(ClassName),PChar(EditFile);
0
 

Expert Comment

by:sachin_chatekar
ID: 21221364
I'm facing the same problem with IE7.
The strange thing is that I'm not facing the issue with IE6, FindWindowEx works perfectly fine with IE6
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now