Article View: borland.public.cppbuilder.nativeapi
Article #17199Re: More sending mouse clicks?
From: Remy Lebeau (TeamB)
Date: Wed, 02 Apr 2003 17:36
Date: Wed, 02 Apr 2003 17:36
35 lines
2073 bytes
2073 bytes
"Chris W" <chrisw3@cox.net> wrote in message
news:3E8B193A.11681D9C@cox.net...
> I can't just send the mouse click to the application window
> handle at the correct (x, y) location to click on a button,
> I have to find the window handle of the button and send
> the mouse click to its handle.
Correct. That is how Windows is designed to work - each visual control that
can receive user input has its own handle which messages are directed to
individually.
> I don't suppose there is an easier way?
Nope. You have to locate the main window at the desired screen coordinates
first, and then recursive iterate through its child windows until you find
the one you are looking for. For example:
POINT p = some screen coordinates;
HWND hWnd = ::WindowFromPoint(p);
while( hWnd != NULL )
{
POINT p2 = p;
::ScreenToClient(hWnd, &p2);
HWND hChild = ::ChildWindowFromPoint(hWnd, p2);
if( hChild == NULL || hChild == hWnd )
break;
hWnd = hChild;
}
if( hWnd != NULL )
// send messages to hWnd as needed
Gambit
Technical Details
Message-ID:
<3e8b1fa3$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3E8B193A.11681D9C@cox.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,a4bcdcbe0081dd78 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-02 09:44:03 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3E8B193A.11681D9C@cox.net> Subject: Re: More sending mouse clicks? Date: Wed, 2 Apr 2003 09:36:40 -0800 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3e8b1fa3$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049304995 207.175.226.26 (2 Apr 2003 09:36:35 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail