Article View: borland.public.cppbuilder.nativeapi
Article #15458Re: about get window by pos.
From: Siney San
Date: Sun, 29 Jun 2003 03:03
Date: Sun, 29 Jun 2003 03:03
90 lines
3190 bytes
3190 bytes
>
> 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;
> }
>
your code is also useless, i have a program that can't get any window on
screen and its key source(vc) below:
int CGetWindowInfo::GetRealWindow(HWND *phWnd, POINT ptPoint)
{
int nResult = false;
int nRetCode = false;
HWND hWndTop = NULL;
HWND hWndChild = NULL;
POINT ptCooChild = {0};
LONG lWindowStyle = 0;
hWndTop = ::WindowFromPoint(ptPoint);
ZOU_PROCESS_ERROR(hWndTop); //a macro to handle error
ptCooChild = ptPoint;
lWindowStyle = GetWindowLong(hWndTop, GWL_STYLE);
if(
!GetParent(hWndTop) ||
GetDesktopWindow() == GetParent(hWndTop) ||
!(lWindowStyle & WS_CHILDWINDOW)
)
{
*phWnd = hWndTop;
}
else
{
*phWnd = GetParent(hWndTop);
}
::ScreenToClient(*phWnd, &ptCooChild);
while (TRUE)
{
hWndChild = RealChildWindowFromPoint(*phWnd, ptCooChild);
if (hWndChild && (hWndChild != *phWnd))
*phWnd = hWndChild;
else
break;
}
nResult = true;
Exit0:
return nResult;
}
i copy-paste it into bcb ide,compiled,linked and ran it,but can't alow get
disabled window.(in vc can).why?
at last, i write code below:
HWND TMainForm::GetRealWindow(POINT ptPoint)
{
//HWND hParent = HWND_DESKTOP;
HWND hParent = WindowFromPoint(ptPoint);
::ScreenToClient(hParent,&ptPoint);
HWND hChild = ::ChildWindowFromPoint(hParent, ptPoint);
while( (hChild) && (hChild != hParent) )
{
::MapWindowPoints(hParent, hChild, &ptPoint, 1);
hParent = hChild;
hChild = ChildWindowFromPointEx(hParent, ptPoint,CWP_ALL);
}
return hChild;
}
if you move mouse to disabled window directly, it can get it.if
indirectly,it can't.why?
Technical Details
Message-ID:
<3efe571b@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!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> <3efdf892@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 20:16:12 PST Reply-To: "Siney San" <siney@yeah.net> From: "Siney San" <siney@yeah.net> Newsgroups: borland.public.cppbuilder.nativeapi References: <3efbf96b@newsgroups.borland.com> <3efc70d0@newsgroups.borland.com> <3efd6a06@newsgroups.borland.com> <3efdf892@newsgroups.borland.com> Subject: Re: about get window by pos. Date: Sun, 29 Jun 2003 11:03:44 +0800 Lines: 92 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: 202.100.9.1 Message-ID: <3efe571b@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1056855835 202.100.9.1 (28 Jun 2003 20:03:55 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail