🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
18 messages
18 total messages Started by Keneth Wagner Thu, 10 Apr 2003 10:00
Finding Windows
#17124
Author: Keneth Wagner
Date: Thu, 10 Apr 2003 10:00
11 lines
1552 bytes
Hello, i'm trying to make an application works automatic, receiving orders
from my program.  I already can get the other window, minimize, maximize and
restore, but i can not make the destroy event and can not get none buttons
inside the other applicacion.  I use the Spy tool comes with Visual C++ and
i can see there all the handles, but how can i make that???.   Im trying to
get the buttons with the same FindWindow, i'm trying to with the GetDlgItem
but for this last function i need the ID of the control and for obtain it i
need the handle of the button.  So, can someone help me or give a north to
folllow??? please.

Thanks a lot.
Re: Finding Windows
#17031
Author: Ed Mulroy [TeamB]
Date: Thu, 10 Apr 2003 16:27
21 lines
1861 bytes
FindWindow only finds top level windows.

For child windows use the HWND of the top level window and call
EnumChildWindows.

.  Ed

> Keneth Wagner wrote in message
> news:3e9540f0@newsgroups.borland.com...
>
> Hello, i'm trying to make an application works automatic,
> receiving orders from my program.  I already can get the
> other window, minimize, maximize and restore, but i can
> not make the destroy event and can not get none buttons
> inside the other applicacion.  I use the Spy tool comes
> with Visual C++ and i can see there all the handles, but
> how can i make that???.   Im trying to get the buttons with
> the same FindWindow, i'm trying to with the GetDlgItem
> but for this last function i need the ID of the control and
> for obtain it i need the handle of the button.  So, can
> someone help me or give a north to folllow??? please.
Re: Finding Windows
#17032
Author: Remy Lebeau (TeamB)
Date: Thu, 10 Apr 2003 16:44
12 lines
1295 bytes
"Keneth Wagner" <Keneth_w@msn.com> wrote in message
news:3e9540f0@newsgroups.borland.com...
> i'm trying to with the GetDlgItem but for this last function
> i need the ID of the control and for obtain it i need the
> handle of the button.

The IDs are constant, always the same between executions.  So just use your
Spy tool to look them up and then hard-code them into your code.


Gambit
Re: Finding Windows
#17047
Author: Keneth Wagner
Date: Fri, 11 Apr 2003 07:20
20 lines
1531 bytes
Thank you very much

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> schrieb im Newsbeitrag
news:3e959f41$1@newsgroups.borland.com...
>
> "Keneth Wagner" <Keneth_w@msn.com> wrote in message
> news:3e9540f0@newsgroups.borland.com...
> > i'm trying to with the GetDlgItem but for this last function
> > i need the ID of the control and for obtain it i need the
> > handle of the button.
>
> The IDs are constant, always the same between executions.  So just use
your
> Spy tool to look them up and then hard-code them into your code.
>
>
> Gambit
>
>
>
Re: Finding Windows
#17046
Author: Keneth Wagner
Date: Fri, 11 Apr 2003 07:21
26 lines
2010 bytes
Tank you very much
"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> schrieb im Newsbeitrag
news:3e959b94@newsgroups.borland.com...
> FindWindow only finds top level windows.
>
> For child windows use the HWND of the top level window and call
> EnumChildWindows.
>
> .  Ed
>
> > Keneth Wagner wrote in message
> > news:3e9540f0@newsgroups.borland.com...
> >
> > Hello, i'm trying to make an application works automatic,
> > receiving orders from my program.  I already can get the
> > other window, minimize, maximize and restore, but i can
> > not make the destroy event and can not get none buttons
> > inside the other applicacion.  I use the Spy tool comes
> > with Visual C++ and i can see there all the handles, but
> > how can i make that???.   Im trying to get the buttons with
> > the same FindWindow, i'm trying to with the GetDlgItem
> > but for this last function i need the ID of the control and
> > for obtain it i need the handle of the button.  So, can
> > someone help me or give a north to folllow??? please.
>
>
Re: Finding Windows
#17050
Author: Keneth Wagner
Date: Fri, 11 Apr 2003 11:53
26 lines
1952 bytes
Sorry but i try what you say and the ID are variables.  At less is what my
Spy tell.  Now i using EnumChildWindow and is ok, but i still have problems
when i try to make diference between components.  I mean, i have in the
other program two toolbars, but i don't know which is what i want, and even
i don't know how to get a button inside a tool bar.  do I have to create
another EnumChildWindow for the handle of the Toolbar?


"Remy Lebeau (TeamB)" <gambit47@yahoo.com> schrieb im Newsbeitrag
news:3e959f41$1@newsgroups.borland.com...
>
> "Keneth Wagner" <Keneth_w@msn.com> wrote in message
> news:3e9540f0@newsgroups.borland.com...
> > i'm trying to with the GetDlgItem but for this last function
> > i need the ID of the control and for obtain it i need the
> > handle of the button.
>
> The IDs are constant, always the same between executions.  So just use
your
> Spy tool to look them up and then hard-code them into your code.
>
>
> Gambit
>
>
>
Re: Finding Windows
#17048
Author: Keneth Wagner
Date: Fri, 11 Apr 2003 11:54
31 lines
2338 bytes
Now i using EnumChildWindow and is ok, but i still have problems when i try
to make diference between components.  I mean, i have in the other program
two toolbars, but i don't know which is what i want, and even i don't know
how to get a button inside a tool bar.  do I have to create another
EnumChildWindow for the handle of the Toolbar?

"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> schrieb im Newsbeitrag
news:3e959b94@newsgroups.borland.com...
> FindWindow only finds top level windows.
>
> For child windows use the HWND of the top level window and call
> EnumChildWindows.
>
> .  Ed
>
> > Keneth Wagner wrote in message
> > news:3e9540f0@newsgroups.borland.com...
> >
> > Hello, i'm trying to make an application works automatic,
> > receiving orders from my program.  I already can get the
> > other window, minimize, maximize and restore, but i can
> > not make the destroy event and can not get none buttons
> > inside the other applicacion.  I use the Spy tool comes
> > with Visual C++ and i can see there all the handles, but
> > how can i make that???.   Im trying to get the buttons with
> > the same FindWindow, i'm trying to with the GetDlgItem
> > but for this last function i need the ID of the control and
> > for obtain it i need the handle of the button.  So, can
> > someone help me or give a north to folllow??? please.
>
>
Re: Finding Windows
#17049
Author: Ed Mulroy [TeamB]
Date: Fri, 11 Apr 2003 12:00
11 lines
1456 bytes
I don't know how to tell which toolbar is the one you want.  You're going to
have to examine any differences between them to see how you can tell them
apart.

Try running WinSight32 or Spy when the program with the tool bars is active
and examining their characteristics.

.  Ed

> Keneth Wagner wrote in message
> news:3e96ad0d@newsgroups.borland.com...
Re: Finding Windows
#17057
Author: Remy Lebeau (TeamB)
Date: Fri, 11 Apr 2003 16:22
19 lines
1648 bytes
"Keneth Wagner" <Keneth_w@msn.com> wrote in message
news:3e96ad0d@newsgroups.borland.com...
> I mean, i have in the other program two toolbars, but i
> don't know which is what i want

That is your own responsibility to research ahead of time using spy tools
and such so you can properly code for it.  Look at the various properties,
names, values, etc for each toolbar and try to find something unique or
identifying that you can look for in your own code.

> i don't know how to get a button inside a tool bar.  do I
> have to create another EnumChildWindow for the handle
> of the Toolbar?

Yes.


Gambit
Re: Finding Windows
#17011
Author: Keneth Wagner
Date: Mon, 14 Apr 2003 09:15
106 lines
4606 bytes
Ok, i have two toolbar inside the mainform.  With the EnumChildWindows i am
able to get all the components inside the mainform, that is ok.  The
difference between the Toolbars is not important right now because i can
make the difference with the buttons each toolbar has inside.  The problem
is that i can not get the buttons inside the toolbar.
I tried to use the same function "EnumChildWindow" calling it with the
Handle of the toolBar, but nothing happens.  what I'm doing wrong?.  The
function don't execute itself when the handle is from a toolbar.  Even i
tried to get the menu of the application because i can get the functions i
need to run from there, but i am stock in there too.  The last i tried to do
was send a message to windows with a hotkey but i still don't know how to
put, by example,  the shortcut Ctrl+'N' for send it with the SendMessage()
function.
Excuse me for my poor knowledge in this, but is the first time i try to do
something like this.  I have an application that its suppose to do a test of
some hardware in an automatic way, but first i have to configurate the
hardware using a configuration tool, and will be great for me to make the
configuration (using the other program) automatically too.

Ok, so, I can not do this via DDE, so the only way for me is this.  This is
most for knowledge than because i have to.  I never was working like this
with the api.  Some recomendation? or can you tell me why (even the spy and
WinSight32) I'm not able to see or get the button handles inside the
toolbars?.  Thanks a lot for your answer.

-- Here is part of the code I have, the call from a button, and two
EnumChildProc, one for all the componetns and other when is a toolbar ----

//--------------------------------------------------------------------------
-
void __fastcall TForm1::Button9Click(TObject *Sender)
{
    bool ItsWorking;
    HWND bt=0;
    RECT lParam;
    long param;



ItsWorking=EnumChildWindows(MainHandle,WNDENUMPROC(EnumChildProc),(LPARAM)
&lParam);
    if(ItsWorking){
        ShowMessage("OK");
    }
}
//--------------------------------------------------------------------------
-
BOOL CALLBACK EnumChildProc(
    HWND hwndChild,
    LPARAM lParam
)

{
    LPRECT rcParent;
    int i, idChild;
    char strString[20];
    bool Working;

    idChild = GetWindowLong(hwndChild, GWL_ID);

    GetClassName(hwndChild,strString,20);
    if(AnsiString(strString) == "TToolBar"){

Working=EnumChildWindows(MainHandle,WNDENUMPROC(EnumChildProcNew),(LPARAM)
&lParam);
    }
    ShowMessage(AnsiString(strString) + " Actual Class.");
    return TRUE;

}

BOOL CALLBACK EnumChildProcNew(
    HWND hwndChild,
    LPARAM lParam
)

{
    LPRECT rcParent;
    int i, idChild;
    char strString[100];

    idChild = GetWindowLong(hwndChild, GWL_ID);

    GetClassName(hwndChild,strString,100);
    ShowMessage(AnsiString(strString) + " Inside if  the Tool Bar.");
    return TRUE;
}


"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> schrieb im Newsbeitrag
news:3e96ae95$1@newsgroups.borland.com...
> I don't know how to tell which toolbar is the one you want.  You're going
to
> have to examine any differences between them to see how you can tell them
> apart.
>
> Try running WinSight32 or Spy when the program with the tool bars is
active
> and examining their characteristics.
>
> .  Ed
>
> > Keneth Wagner wrote in message
> > news:3e96ad0d@newsgroups.borland.com...
>
>
Re: Finding Windows
#17013
Author: Keneth Wagner
Date: Mon, 14 Apr 2003 09:35
25 lines
2052 bytes
I just noted that i'm entering inside the controls of the toolbar, the
problem is with the SpeedButtons, i can not see it with the Spy or
Enumchildwindows function.  the others controls inside the toolbar i already
have it.  I'm wondering if the speed button is a class inside the ToolBar
and for that reason they uses the same HWND, but if that is right, how can i
click for code one of those buttons???


"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> schrieb im Newsbeitrag
news:3e96ae95$1@newsgroups.borland.com...
> I don't know how to tell which toolbar is the one you want.  You're going
to
> have to examine any differences between them to see how you can tell them
> apart.
>
> Try running WinSight32 or Spy when the program with the tool bars is
active
> and examining their characteristics.
>
> .  Ed
>
> > Keneth Wagner wrote in message
> > news:3e96ad0d@newsgroups.borland.com...
>
>
Re: Finding Windows
#17015
Author: Keneth Wagner
Date: Mon, 14 Apr 2003 10:32
19 lines
1651 bytes
I already find the way to access the Toolbar buttons ;o).

"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> schrieb im Newsbeitrag
news:3e96ae95$1@newsgroups.borland.com...
> I don't know how to tell which toolbar is the one you want.  You're going
to
> have to examine any differences between them to see how you can tell them
> apart.
>
> Try running WinSight32 or Spy when the program with the tool bars is
active
> and examining their characteristics.
>
> .  Ed
>
> > Keneth Wagner wrote in message
> > news:3e96ad0d@newsgroups.borland.com...
>
>
Re: Finding Windows
#17019
Author: Ed Mulroy [TeamB]
Date: Mon, 14 Apr 2003 13:05
20 lines
2242 bytes
I don't know if those buttons are separate windows or are just painted as if
they were.  You are trying to control a different program.  If you can see a
window in that program which is associated with the button you want, then
you can send it a message.  To help you see how the windows are arranged and
for help in locating the window I suggested that you use WinSight32 or Spy.
If they cannot show a window for the button then there may not be one.  The
alternative may be to move the mouse over the button and generate a mouse
click.  This has its own problems.  For instance if the program or your
program has captured the mouse then it won't be able to move there.

The net result is that there is no functionality built into Windows to
guarantee that you can control another program.  If you want to do that you
will have to sneak a peek at what the program is doing and try to subvert
its activities to achieve your goals.  I cannot give a cookbook recipe which
is guaranteed to work on a random program.

.  Ed

> Keneth Wagner wrote in message
> news:3e9a80ef@newsgroups.borland.com...
Re: Finding Windows
#17020
Author: Keneth Wagner
Date: Mon, 14 Apr 2003 13:43
44 lines
3103 bytes
yes i know what you mean.  Now i can access the buttons, i get the handle of
the toolbar, and using SendMessage i can access all the buttons, but the
problem is that i can change all in the button, all, but i can not make the
click event.  I'm still looking around to try to do it.  The buttons are
SpeedButtons but you have to access with an item index inside the Toolbar,
and that is what i'm doing with the sendMessage.  There is a message
TB_PUSHBUTTON, but the button only take the view like is pushed, but nothing
happens. I can get the IDCommand from the button, but i don't know if i can
use it to make the click event with other message, do you have any idea
about that?

Thank you very much.

"Ed Mulroy [TeamB]" <ed@mulroyREMOVETHESECHARS.org> schrieb im Newsbeitrag
news:3e9ab23e$1@newsgroups.borland.com...
> I don't know if those buttons are separate windows or are just painted as
if
> they were.  You are trying to control a different program.  If you can see
a
> window in that program which is associated with the button you want, then
> you can send it a message.  To help you see how the windows are arranged
and
> for help in locating the window I suggested that you use WinSight32 or
Spy.
> If they cannot show a window for the button then there may not be one.
The
> alternative may be to move the mouse over the button and generate a mouse
> click.  This has its own problems.  For instance if the program or your
> program has captured the mouse then it won't be able to move there.
>
> The net result is that there is no functionality built into Windows to
> guarantee that you can control another program.  If you want to do that
you
> will have to sneak a peek at what the program is doing and try to subvert
> its activities to achieve your goals.  I cannot give a cookbook recipe
which
> is guaranteed to work on a random program.
>
> .  Ed
>
> > Keneth Wagner wrote in message
> > news:3e9a80ef@newsgroups.borland.com...
>
>
Re: Finding Windows
#17022
Author: Ed Mulroy [TeamB]
Date: Mon, 14 Apr 2003 14:43
30 lines
2486 bytes
Unfortunately I cannot give you a guaranteed scheme for controlling another
program.

You are assuming that the program in its current state will honor the push
of that button.  The word is "assume".  Unless you know the exact logic of
that other program which you are trying to control you cannot know that it
will honor the push so could in fact be doing the right thing to generate a
button push.

This might be a useful time to start the help on the Windows API (win32.hlp)
and look up the function mouse_event.

.  Ed

> Keneth Wagner wrote in message
> news:3e9abb23$1@newsgroups.borland.com...
>
> yes i know what you mean.  Now i can access the buttons,
> i get the handle of the toolbar, and using SendMessage i
> can access all the buttons, but the problem is that i can
> change all in the button, all, but i can not make the
> click event.  I'm still looking around to try to do it.  The
> buttons are SpeedButtons but you have to access with an
> item index inside the Toolbar, and that is what i'm doing
> with the sendMessage.  There is a message
> TB_PUSHBUTTON, but the button only take the view like
> is pushed, but nothing happens. I can get the IDCommand
> from the button, but i don't know if i can use it to make the
> click event with other message, do you have any idea
> about that?
Re: Finding Windows
#17024
Author: Remy Lebeau (TeamB)
Date: Mon, 14 Apr 2003 17:08
12 lines
1509 bytes
"Keneth Wagner" <Keneth_w@msn.com> wrote in message
news:3e9a80ef@newsgroups.borland.com...
> the problem is with the SpeedButtons, i can not see it
> with the Spy or Enumchildwindows function.

TSpeedButton is not a windowed control.  It does not derived from
TWinControl, but from TGraphicControl instead.  Thus is has no HWND of its
own, and thus can't be manipulated via HWND-based functions.


Gambit
Re: Finding Windows
#16934
Author: Keneth Wagner
Date: Tue, 15 Apr 2003 06:52
31 lines
2659 bytes
Ok, thanks Remy, i understand now. But must  be a way to manipulate the
speedButton then, i'm trying sending messages and i can access it now but i
still can not make the click event.  Even i can send a push message but the
button only take the look like pushed but the event is not invoked.  I find
other message for get some idCommand from the button, i think that is the
way but i'm still looking for the way to do it.  I know maybe with the mouse
event is more ease, but is not elegant.  I only want to avoid say the user
"please, open here. Ok, now click there, now Write this, etc etc".  I have
to configurate the hardware first to make my program do what one assumes
that does, make an "autotest" and is a little rare to see something
automatic receiving too many steps.
But ok, i think i have to make it like that if i can not find the other way
i want, thanks for your help, really, at less i learned many thinks i had
not idea about that before.  But i keep trying ;o).  Bye

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> schrieb im Newsbeitrag
news:3e9aeb3d$1@newsgroups.borland.com...
>
> "Keneth Wagner" <Keneth_w@msn.com> wrote in message
> news:3e9a80ef@newsgroups.borland.com...
> > the problem is with the SpeedButtons, i can not see it
> > with the Spy or Enumchildwindows function.
>
> TSpeedButton is not a windowed control.  It does not derived from
> TWinControl, but from TGraphicControl instead.  Thus is has no HWND of its
> own, and thus can't be manipulated via HWND-based functions.
>
>
> Gambit
>
>
Re: Finding Windows
#16938
Author: Remy Lebeau (TeamB)
Date: Tue, 15 Apr 2003 16:24
13 lines
1657 bytes
"Keneth Wagner" <Keneth_w@msn.com> wrote in message
news:3e9bac63$1@newsgroups.borland.com...
> Ok, thanks Remy, i understand now. But must  be
> a way to manipulate the speedButton then

Nope, because there's no way to find it externally, let alone manipulate it,
as it has nothing that can be manipulated externally to begin with.  For
what you ask, you need a HWND, and TSpeedButton simply doesn't have one.
You need a windowed button instead, such as TButton or TBitBtn.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads