🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12313

Re: Simulate mouse click to another window

#12313
From: Alan Bellingham
Date: Tue, 16 Dec 2003 16:10
45 lines
2550 bytes
"Jan" <jan@jlcsoft.com> wrote:

>I have rewrite the code a little bit, and all the functions returns
>true, any idea what is wrong ?
>
>         RECT rc;
>         POINT pt;
>
>         hTarget = (HWND)lPreviewHandle;
>         Tmp = IsWindow(hTarget);
>         if(Tmp)
>          logtxt("Target = valid");
>         else
>          logtxt("Target = Invalid");
>
>         logtxt("Client window");
>         GetClientRect(hTarget, &rc);
>         logtxt("Top: " + IntToStr(rc.top));
>         logtxt("Left: " + IntToStr(rc.left));
>         logtxt("Right: " + IntToStr(rc.right));
>         logtxt("Bottom: " + IntToStr(rc.bottom));

So far, so good

>         Tmp = ClientToScreen(hTarget, &pt);

Where did pt come from? It's an uninitialised variable. You want to set
it to the top and left coordinates of the rectangle (well, to (0, 0).

>         if(Tmp) {
>          logtxt("ClientToScreen X: " + IntToStr(pt.x));
>          logtxt("ClientToScreen Y: " + IntToStr(pt.y));
>         } else {
>          logtxt("ClientToScreen = false");
>         }

As you saw, garbage out.

Do the ClientToScreen, and add the resulting X and Y values to the
rectangle (so top += Y, bottom += Y, left += X and right += X). You may
then get the resulting rectangle in the right place.

Alan Bellingham
-- 
alanb@episys.com
Technical Details
Message-ID: <gbbutvshm50b84q3f9736fan5q8gm0ndhe@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer2.atl.newshosting.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3fddd8ec@newsgroups.borland.com> <3fddec56$1@newsgroups.borland.com> <3fdf1356$1@newsgroups.borland.com> <so6utv0rpln7uaispk5ga8t7hdvo3afm2t@4ax.com> <3fdf23e1$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,aaf30719407ea571
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-16 08:17:54 PST
From: Alan Bellingham <alanb@episys.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Simulate mouse click to another window
Date: Tue, 16 Dec 2003 16:10:31 +0000
Reply-To: alanb@episys.com
Message-ID: <gbbutvshm50b84q3f9736fan5q8gm0ndhe@4ax.com>
References: <3fddd8ec@newsgroups.borland.com> <3fddec56$1@newsgroups.borland.com> <3fdf1356$1@newsgroups.borland.com> <so6utv0rpln7uaispk5ga8t7hdvo3afm2t@4ax.com> <3fdf23e1$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.92/32.572
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 193.129.251.130
X-Trace: newsgroups.borland.com 1071591032 193.129.251.130 (16 Dec 2003 08:10:32 -0700)
Lines: 45
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer2.atl.newshosting.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail