Article View: borland.public.cppbuilder.nativeapi
Article #12308Re: Simulate mouse click to another window
From: Alan Bellingham
Date: Tue, 16 Dec 2003 14:55
Date: Tue, 16 Dec 2003 14:55
49 lines
2233 bytes
2233 bytes
"Jan" <jan@jlcsoft.com> wrote: >I have try this code, but don't work. What is wrong with this code ? > >HDC hdc; >RECT rc; >HWND hTarget; > >hTarget = (HWND)lPreviewHandle; Are you sure that's a valid window handle? Check with IsWindow(). >GetClientRect(hTarget, &rc); You've not checked the result of this call. Did it work? Oh, be warned - the resulting rectangle starts at (0, 0), which is the top left of the screen. You would want to translate this to screen coordinates, using ClientToScreen(). >hdc = GetDC(hTarget); Why do you want the DC? Are you drawing? >ClipCursor(&rc2); Where does rc2 come from? >MoveToEx(hdc, rc2.right / 2, rc2.bottom / 2, NULL); This is a graphics command, indicating that a following LineTo() (or some other drawing commands) should draw from this point. But you don't do the draw command. Did you mean to move the cursor? SetCursorPos(). >PostMessage(hTarget, WM_LBUTTONDOWN,0,0); >::Sleep(200); >PostMessage(hTarget, WM_LBUTTONUP, 0,0); Looks reasonable. >ClipCursor(NULL); >ReleaseDC(hTarget, hdc); Ditto. Except that the HDC is almost certainly unwanted. Alan Bellingham -- alanb@episys.com
Technical Details
Message-ID:
<so6utv0rpln7uaispk5ga8t7hdvo3afm2t@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!fr.ip.ndsoftware.net!proxad.net!news-out.visi.com!petbe.visi.com!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fddd8ec@newsgroups.borland.com> <3fddec56$1@newsgroups.borland.com> <3fdf1356$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 07:07:12 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 14:55:36 +0000 Reply-To: alanb@episys.com Message-ID: <so6utv0rpln7uaispk5ga8t7hdvo3afm2t@4ax.com> References: <3fddd8ec@newsgroups.borland.com> <3fddec56$1@newsgroups.borland.com> <3fdf1356$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 1071586535 193.129.251.130 (16 Dec 2003 06:55:35 -0700) Lines: 49 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!fr.ip.ndsoftware.net!proxad.net!news-out.visi.com!petbe.visi.com!ash.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail