Article View: borland.public.cppbuilder.nativeapi
Article #15457Re: about get window by pos.
From: Remy Lebeau (TeamB)
Date: Sat, 28 Jun 2003 20:24
Date: Sat, 28 Jun 2003 20:24
45 lines
2624 bytes
2624 bytes
"Siney San" <siney@yeah.net> wrote in message
news:3efd6a06@newsgroups.borland.com...
> but alsoe can't get any grayed disable, invisible window?why?
As the previously-mentioned, the documentation for WindowFromPoint() clearly
states that it will not work for disabled windows. Instead of using
WindowFromPos(), try calling ChildWindowFromPoint() using HWND_DESKTOP as
the parent window instead.
HWND TMainForm::GetRealWindow(POINT ptPoint) //Get real sub wnd
{
HWND hparent = ChildWindowFromPoint(HWND_DESKTOP, ptPoint);
...
There is also two bugs in your while() loop as well:
1) the loop is calling ScreenToClient() passing it client coordinates
instead of screen coordinates each time, since you already converted the
POINT to client coordinates before the loop. So either keep track of the
original screen coordinates each time, or else utilize MapWindowPoints()
instead.
2) your while() loop is testing hchild for NULL when it should be testing
for non-NULL instead. There's no point in continuing to loop if
ChildWindowForPoint() returns NULL each time indicating no window was found.
With that said, try this instead (untested):
HWND TMainForm::GetRealWindow(POINT ptPoint)
{
HWND hParent = HWND_DESKTOP;
HWND hChild = ::ChildWindowFromPoint(hParent, ptPoint);
while( (hChild) && (hChild != hParent) )
{
::MapWindowPoints(hParent, hChild, &ptPoint, 1);
hParent = hChild;
hChild = ::ChildWindowFromPoint(hParent, ptPoint);
}
return hChild;
}
Gambit
Technical Details
Message-ID:
<3efdf892@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3efbf96b@newsgroups.borland.com> <3efc70d0@newsgroups.borland.com> <3efd6a06@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5a7ad1e748c52c2b X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-28 13:26:06 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3efbf96b@newsgroups.borland.com> <3efc70d0@newsgroups.borland.com> <3efd6a06@newsgroups.borland.com> Subject: Re: about get window by pos. Date: Sat, 28 Jun 2003 13:24:54 -0700 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3efdf892@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1056831634 207.175.226.26 (28 Jun 2003 13:20:34 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail