Solved

FindWindowEx to find Child Window

Posted on 1997-02-26
6
2,840 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 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