FindWindow for ChildWindows. 
Author Message
 FindWindow for ChildWindows.

Hello,
I use eVB/eVC for HPC2000.

Q1:
I want to change the size of a childwindow control (e.g. Scrollbar).
Currently I can only get its handle by obtaining its Parent's handle using
FindWindow and then looping through all the controls before it until I reach
the Scrollbar. The problem here is that my loop predicate depends on the
number of controls I have on the Parent Window. Is there any way I can
directly obtain the handle to the child window (Findwindow only allows me to
get the handle of a Parent Window)?

Q2:
I would like to obtain the handle for a window using FindWindow(ClassName,
Caption). The problem arises when the window Caption is not the same
everytime. e.g. The window name always starts with the same words:
"Connected with ....". But after that the caption changes. Is there anyway I
can get the window handle using find window and partial string for the
Caption parameter? If not where can I get more information on how find
window works so that I can write my own FindWindow function?

Thanks,
Sami



Tue, 20 Sep 2005 19:35:21 GMT  
 FindWindow for ChildWindows.
I have a solution for Q2:
I can use the FindWindow to get the Class Name and then with GetWindowText I
can retrieve and compare the Window title. If it matches then I have my
window handle. But I would still appreciate a solution for Q1.
Sami



Quote:
> Hello,
> I use eVB/eVC for HPC2000.

> Q1:
> I want to change the size of a childwindow control (e.g. Scrollbar).
> Currently I can only get its handle by obtaining its Parent's handle using
> FindWindow and then looping through all the controls before it until I
reach
> the Scrollbar. The problem here is that my loop predicate depends on the
> number of controls I have on the Parent Window. Is there any way I can
> directly obtain the handle to the child window (Findwindow only allows me
to
> get the handle of a Parent Window)?

> Q2:
> I would like to obtain the handle for a window using FindWindow(ClassName,
> Caption). The problem arises when the window Caption is not the same
> everytime. e.g. The window name always starts with the same words:
> "Connected with ....". But after that the caption changes. Is there anyway
I
> can get the window handle using find window and partial string for the
> Caption parameter? If not where can I get more information on how find
> window works so that I can write my own FindWindow function?

> Thanks,
> Sami



Tue, 20 Sep 2005 20:38:50 GMT  
 FindWindow for ChildWindows.
(I think these are supported on HPC2000...)

Use GetDlgItem(hDlg, CONTROL_ID) to get the hWnd of the the control
directly.
As long as your progam is the one who creates the window and controls, this
is the easiest way to get the hwnd.

Or....

Use GetWindow(hParent, GW_CHILD) to enumerate the child windows.
You'll need to make it a recursive function so that you can walk more than
one layer deep.

--
~Demitri

(This posting is provided "AS IS" with no warranties, and confers no
rights.)


Quote:
> I have a solution for Q2:
> I can use the FindWindow to get the Class Name and then with GetWindowText
I
> can retrieve and compare the Window title. If it matches then I have my
> window handle. But I would still appreciate a solution for Q1.
> Sami



> > Hello,
> > I use eVB/eVC for HPC2000.

> > Q1:
> > I want to change the size of a childwindow control (e.g. Scrollbar).
> > Currently I can only get its handle by obtaining its Parent's handle
using
> > FindWindow and then looping through all the controls before it until I
> reach
> > the Scrollbar. The problem here is that my loop predicate depends on the
> > number of controls I have on the Parent Window. Is there any way I can
> > directly obtain the handle to the child window (Findwindow only allows
me
> to
> > get the handle of a Parent Window)?

> > Q2:
> > I would like to obtain the handle for a window using

FindWindow(ClassName,

- Show quoted text -

Quote:
> > Caption). The problem arises when the window Caption is not the same
> > everytime. e.g. The window name always starts with the same words:
> > "Connected with ....". But after that the caption changes. Is there
anyway
> I
> > can get the window handle using find window and partial string for the
> > Caption parameter? If not where can I get more information on how find
> > window works so that I can write my own FindWindow function?

> > Thanks,
> > Sami



Wed, 21 Sep 2005 01:08:07 GMT  
 FindWindow for ChildWindows.


Quote:
>Hello,
>I use eVB/eVC for HPC2000.

>Q1:
>I want to change the size of a childwindow control (e.g. Scrollbar).
>Currently I can only get its handle by obtaining its Parent's handle using
>FindWindow and then looping through all the controls before it until I reach
>the Scrollbar. The problem here is that my loop predicate depends on the
>number of controls I have on the Parent Window. Is there any way I can
>directly obtain the handle to the child window (Findwindow only allows me to
>get the handle of a Parent Window)?

If you know the control ID for a control and the HWND for its owner
dialog, you can use GetDlgItem to get the HWND for the control.

FindWindow will work for _any_ window (dialog box, control, ...).

If the scroll bar you care about is the only scroll bar,  you can use
the window class name for scroll bars as the first argument in
FindWindow, with NULL as the second argument. I don't remember the
class name offhand, but you can use Remote Spy++ to find it.

If several scroll bars are on the screen, but only one has the parent
you found, you can use EnumChildWindows to find all child windows for
that parent, use GetClassName to get the window class name for each,
and use that to find the scroll bar.

Quote:

>Q2:
>I would like to obtain the handle for a window using FindWindow(ClassName,
>Caption). The problem arises when the window Caption is not the same
>everytime. e.g. The window name always starts with the same words:
>"Connected with ....". But after that the caption changes. Is there anyway I
>can get the window handle using find window and partial string for the
>Caption parameter? If not where can I get more information on how find
>window works so that I can write my own FindWindow function?

If a window has a unique window class name, you can use it as the
first argument to FindWindow. If the window is in an application for
which you have no source, you can use Spy++ (or Remote Spy++) to find
the window class name, and you may be lucky. If you are the
programmer, you _can_ make sure any window has a unique class name,
although it requires a little extra work.

I suspect FindWindow use EnumWindows and EnumChildWindows.

Quote:

>Thanks,
>Sami

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
46 Beach Street
Boston, MA 02111
www.penfact.com



Wed, 21 Sep 2005 02:13:51 GMT  
 FindWindow for ChildWindows.

On Fri, 4 Apr 2003 09:08:07 -0800, "Demitri \(MS\)"

Quote:

>(I think these are supported on HPC2000...)

>Use GetDlgItem(hDlg, CONTROL_ID) to get the hWnd of the the control
>directly.
>As long as your progam is the one who creates the window and controls, this
>is the easiest way to get the hwnd.

I've used GetDlgItem on many Win 32 platforms, including Win 95, Win
98, Win NT, Win 2K, Win XP, CE 2.00 (HPC), CE 2.01 (Palm-size PC), CE
2.11 (HPC Pro and Palm-size PC 1.2), Pocket PC, and CE.NET. I don't
think anyone has actually tested any of my programs on HPC 2000, but
I'm quite confident.

Quote:

>Or....

>Use GetWindow(hParent, GW_CHILD) to enumerate the child windows.
>You'll need to make it a recursive function so that you can walk more than
>one layer deep.

This may need to supplemented by calls using GW_HWNDNEXT, as in:
 for (HWND hWndChild = ::GetWindow(hWnd, GW_CHILD);
 {
      hWndChild = ::GetWindow(hWndChild, GW_HWNDNEXT))
 }

I've used GetWindow, but not recently, and never used it with either
GW_CHILD or GW_HWNDNEXT.

Quote:

>--
>~Demitri

>(This posting is provided "AS IS" with no warranties, and confers no
>rights.)



>> I have a solution for Q2:
>> I can use the FindWindow to get the Class Name and then with GetWindowText
>I
>> can retrieve and compare the Window title. If it matches then I have my
>> window handle. But I would still appreciate a solution for Q1.
>> Sami



>> > Hello,
>> > I use eVB/eVC for HPC2000.

>> > Q1:
>> > I want to change the size of a childwindow control (e.g. Scrollbar).
>> > Currently I can only get its handle by obtaining its Parent's handle
>using
>> > FindWindow and then looping through all the controls before it until I
>> reach
>> > the Scrollbar. The problem here is that my loop predicate depends on the
>> > number of controls I have on the Parent Window. Is there any way I can
>> > directly obtain the handle to the child window (Findwindow only allows
>me
>> to
>> > get the handle of a Parent Window)?

>> > Q2:
>> > I would like to obtain the handle for a window using
>FindWindow(ClassName,
>> > Caption). The problem arises when the window Caption is not the same
>> > everytime. e.g. The window name always starts with the same words:
>> > "Connected with ....". But after that the caption changes. Is there
>anyway
>> I
>> > can get the window handle using find window and partial string for the
>> > Caption parameter? If not where can I get more information on how find
>> > window works so that I can write my own FindWindow function?

>> > Thanks,
>> > Sami

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
46 Beach Street
Boston, MA 02111
www.penfact.com



Wed, 21 Sep 2005 23:54:47 GMT  
 FindWindow for ChildWindows.
Hello,
I thought I had a solution to Q1 but when I use FindWindow("Dialog", Null)
in eVB I get a 0 return handle value. The FindWindow API function says that
the second parameter expects a Long pointer to a null-terminated string that
specifies the window name (the window's title). If this parameter is NULL,
all window names match.

What exactly is returned as a handle when the second parameter is Null?

Thanks,
Sami



Fri, 23 Sep 2005 23:32:45 GMT  
 FindWindow for ChildWindows.
Because "dialog" is the window class name for most dialog boxes, it
seems like a poor choice for the first arg of FindWindows. I would
have expected a handle to some dialog box (probably not the one you
want), and am surprised you got a NULL.

I routinely use FIndWindow with NULL as a second argument. I use a
unique window class name as the first argument to get a handle to my
application's main dialog box so I can make sure only one instance of
my application runs at a time. And I get back a valid handle that I
use in SetForegroundWindow.

I suppose using non-NULL for both arguments might be useful. I tend to
use one _or_ the other.

I use VC++ and eVC++, so I can't vouch for VB or eVB.

On Mon, 7 Apr 2003 17:32:45 +0200, "Sami Islam"

Quote:

>Hello,
>I thought I had a solution to Q1 but when I use FindWindow("Dialog", Null)
>in eVB I get a 0 return handle value. The FindWindow API function says that
>the second parameter expects a Long pointer to a null-terminated string that
>specifies the window name (the window's title). If this parameter is NULL,
>all window names match.

>What exactly is returned as a handle when the second parameter is Null?

>Thanks,
>Sami

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
46 Beach Street
Boston, MA 02111
www.penfact.com



Sat, 24 Sep 2005 04:50:34 GMT  
 FindWindow for ChildWindows.
I can only use "Dialog" as the first argument because that is what the class
name for the particular window is. I got it from Spy++. And since there are
more than one "Dialog" class I thought it might be useful to get a handle
for each and check the Window title by using GetWindowText(handle). And if
my title matched then I would have the handle to the particular "Dialog"
class that I need. But I keep getting 0.
I am sure it will work in eVC++ but I don't want to create a .dll for this
simple call when I don't absolutely have to.



Quote:
> Because "dialog" is the window class name for most dialog boxes, it
> seems like a poor choice for the first arg of FindWindows. I would
> have expected a handle to some dialog box (probably not the one you
> want), and am surprised you got a NULL.

> I routinely use FIndWindow with NULL as a second argument. I use a
> unique window class name as the first argument to get a handle to my
> application's main dialog box so I can make sure only one instance of
> my application runs at a time. And I get back a valid handle that I
> use in SetForegroundWindow.

> I suppose using non-NULL for both arguments might be useful. I tend to
> use one _or_ the other.

> I use VC++ and eVC++, so I can't vouch for VB or eVB.

> On Mon, 7 Apr 2003 17:32:45 +0200, "Sami Islam"

> >Hello,
> >I thought I had a solution to Q1 but when I use FindWindow("Dialog",
Null)
> >in eVB I get a 0 return handle value. The FindWindow API function says
that
> >the second parameter expects a Long pointer to a null-terminated string
that
> >specifies the window name (the window's title). If this parameter is
NULL,
> >all window names match.

> >What exactly is returned as a handle when the second parameter is Null?

> >Thanks,
> >Sami

> -----------------------------------------
> To reply to me, remove the underscores (_) from my email address (and

please indicate which newsgroup and message).

- Show quoted text -

Quote:

> Robert E. Zaret
> PenFact, Inc.
> 46 Beach Street
> Boston, MA 02111
> www.penfact.com



Sun, 25 Sep 2005 17:12:37 GMT  
 FindWindow for ChildWindows.
Just enumerate all the windows in the system using GetWindow and checking
the title of each (using recursion). All FindWindow does is wrap that
functionality, so doing it yourself is more beneficial because FindWindow
only checks the top level windows and with recursion, you can find any
window in the system.

Don't forget that the class names are case sensitive.

btw - Do you own the child control (scrollbar)?

--
~Demitri

(This posting is provided "AS IS" with no warranties, and confers no
rights.)


Quote:
> I can only use "Dialog" as the first argument because that is what the
class
> name for the particular window is. I got it from Spy++. And since there
are
> more than one "Dialog" class I thought it might be useful to get a handle
> for each and check the Window title by using GetWindowText(handle). And if
> my title matched then I would have the handle to the particular "Dialog"
> class that I need. But I keep getting 0.
> I am sure it will work in eVC++ but I don't want to create a .dll for this
> simple call when I don't absolutely have to.



> > Because "dialog" is the window class name for most dialog boxes, it
> > seems like a poor choice for the first arg of FindWindows. I would
> > have expected a handle to some dialog box (probably not the one you
> > want), and am surprised you got a NULL.

> > I routinely use FIndWindow with NULL as a second argument. I use a
> > unique window class name as the first argument to get a handle to my
> > application's main dialog box so I can make sure only one instance of
> > my application runs at a time. And I get back a valid handle that I
> > use in SetForegroundWindow.

> > I suppose using non-NULL for both arguments might be useful. I tend to
> > use one _or_ the other.

> > I use VC++ and eVC++, so I can't vouch for VB or eVB.

> > On Mon, 7 Apr 2003 17:32:45 +0200, "Sami Islam"

> > >Hello,
> > >I thought I had a solution to Q1 but when I use FindWindow("Dialog",
> Null)
> > >in eVB I get a 0 return handle value. The FindWindow API function says
> that
> > >the second parameter expects a Long pointer to a null-terminated string
> that
> > >specifies the window name (the window's title). If this parameter is
> NULL,
> > >all window names match.

> > >What exactly is returned as a handle when the second parameter is Null?

> > >Thanks,
> > >Sami

> > -----------------------------------------
> > To reply to me, remove the underscores (_) from my email address (and
> please indicate which newsgroup and message).

> > Robert E. Zaret
> > PenFact, Inc.
> > 46 Beach Street
> > Boston, MA 02111
> > www.penfact.com



Mon, 26 Sep 2005 02:03:06 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Convert FindWindow to FindWindow Ex *HELP*

2. Childwindows created on the heap doesnt receive messages

3. NonClient area and ChildWindows

4. ChildWindows/views position and size and PreCreateWindow??!!

5. how to add a StatusBar to MDI Childwindows?

6. How to avoid unwanted refreshing the childwindows in a view

7. how to add a StatusBar to MDI Childwindows?

8. FindWindow in .Net?

9. FindWindow...

10. FindWindow API

11. Problem with calling function FindWindow from NT Service

12. findwindow,getwindowaddress,writeproccesmemory(flags), hack windows

 

 
Powered by phpBB® Forum Software