Solved

FindWindowEx to find Child Window

Posted on 1997-02-26
6
2,773 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 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

12 Experts available now in Live!

Get 1:1 Help Now