Solved

FindWindowEx to find Child Window

Posted on 1997-02-26
6
2,795 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL Debugging - Temp Object Content 2 54
GUI: DIalog Stacking and Popping in MS C++ 4 74
Where to obtain Oracle Data Provider for .NET 3.5 7 51
Problem to file 3 74
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

14 Experts available now in Live!

Get 1:1 Help Now