Article View: borland.public.cppbuilder.nativeapi
Article #12310Re: Simulate mouse click to another window
From: Jan
Date: Tue, 16 Dec 2003 14:25
Date: Tue, 16 Dec 2003 14:25
73 lines
3107 bytes
3107 bytes
Alan,
I have rewrite the code a little bit, and all the functions returns
true, any idea what is wrong ?
The main application (of my customer) is writting in Visual Foxpro and
the window that I must capture is a preview window from Crystal Reports
9 (RDC viewer) and is started inside the main app. The problem is when
you want a page up or page down then you must first click on the
preview window. So that is what I'm trying to simulate in code.
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));
Tmp = ClientToScreen(hTarget, &pt);
if(Tmp) {
logtxt("ClientToScreen X: " + IntToStr(pt.x));
logtxt("ClientToScreen Y: " + IntToStr(pt.y));
} else {
logtxt("ClientToScreen = false");
}
Tmp = ClipCursor(&rc);
if(Tmp)
logtxt("ClipCursor = true");
else
logtxt("Clipcursor = false");
//Tmp = SetCursorPos(rc.right / 2, rc.bottom / 2);
Tmp = SetCursorPos(pt.x, pt.y);
if(Tmp)
logtxt("SetCursor = true");
else
logtxt("SetCursor = false");
logtxt("Send WM_LBUTTONDOWN");
PostMessage(hTarget, WM_LBUTTONDOWN, 0,0);
logtxt("Sleep");
::Sleep(200);
logtxt("Send WM_LBUTTONUP");
PostMessage(hTarget, WM_LBUTTONUP, 0, 0);
ClipCursor(NULL);
//-- LOGFILE
16:18:06:88 - Target = valid
16:18:06:88 - Client window
16:18:06:88 - Top: 0
16:18:06:88 - Left: 0
16:18:06:88 - Right: 771
16:18:06:88 - Bottom: 672
16:18:06:88 - ClientToScreen X: 1222101
16:18:06:88 - ClientToScreen Y: 208
16:18:06:88 - ClipCursor = true
16:18:06:88 - SetCursor = true
16:18:06:88 - Send WM_LBUTTONDOWN
16:18:06:88 - Sleep
16:18:06:291 - Send WM_LBUTTONUP
Technical Details
Message-ID:
<3fdf23e1$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fddd8ec@newsgroups.borland.com> <3fddec56$1@newsgroups.borland.com> <3fdf1356$1@newsgroups.borland.com> <so6utv0rpln7uaispk5ga8t7hdvo3afm2t@4ax.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:40:06 PST From: "Jan" <jan@jlcsoft.com> Subject: Re: Simulate mouse click to another window Newsgroups: borland.public.cppbuilder.nativeapi References: <3fddd8ec@newsgroups.borland.com> <3fddec56$1@newsgroups.borland.com> <3fdf1356$1@newsgroups.borland.com> <so6utv0rpln7uaispk5ga8t7hdvo3afm2t@4ax.com> User-Agent: XanaNews/1.15.7.2 NNTP-Posting-Host: 81.82.220.99 Message-ID: <3fdf23e1$1@newsgroups.borland.com> Date: 16 Dec 2003 07:25:21 -0700 X-Trace: newsgroups.borland.com 1071588321 81.82.220.99 (16 Dec 2003 07:25:21 -0700) Lines: 74 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail