sooman
asked on
FindWindowEx to find Child Window
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( 'TAFOSPare nt','AFOSE D');
ClassName:='TMainForm';
repeat
SleepEx(3000,false);
Y:=FindWindowEx(HParentWin dow,0,PCha r(ClassNam e),PChar(E ditFile));
until Y=0;
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(
ClassName:='TMainForm';
repeat
SleepEx(3000,false);
Y:=FindWindowEx(HParentWin
until Y=0;
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(ClassN ame),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
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(ClassN
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
ASKER
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.
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.
- 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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
The strange thing is that I'm not facing the issue with IE6, FindWindowEx works perfectly fine with IE6
Is this a MDI app?