Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi Gintaras,
I am trying to use the On-screendraw functions to make a small telestrator program. But it only works if I move really slow because of the absolute time difference between when the position is sampled and flickers a lot. I realize that a better way would be to gather all the positions that the mouse goes through and then "paint" those positions but not really sure how to do this. Any ideas?
Thanks, S
Macro OSD FreeDraw
int color=ColorFromRGB(255 0 0)
POINT p1 p2 p3 pp
xm p1; pp=p1
int h m
rep
,ifk((1)) m=1; else if(m) break
,xm p2
,OnScreenDraw(p2.x p2.y 20 20 &OSD_Proc_Red_Light 0 210)
,xm p3
,OnScreenDraw(p3.x p3.y 20 20 &OSD_Proc_Red_Light 0 210)
,if(!memcmp(&pp &p2 sizeof(POINT))) continue
,pp=p2
Posts: 12,062
Threads: 140
Joined: Dec 2002
insert
wait 0.01
Use window handle
,int h=OnScreenDraw(...... h)
maybe don't call OnScreenDraw 2 times. They draw the same. But maybe your callback function draws differently, I don't know.
Posts: 1,006
Threads: 330
Joined: Mar 2007
I tried rewriting it as you suggested but still getting spotty instead of continuous tracing.
Here is my current latest version: Note: Win-T triggers, then press t to cause trace with mouse movement (telestrator) and then double click t to erase. Can press and release t to make multiple tracings before double clicking to clear/end function
Function Telestrator
Trigger Wt
int color=ColorFromRGB(255 0 0)
spe
POINT p1 p2 p3 pp
xm p1; pp=p1
int h m
rep
,ifk(t)
,,wait 0.1 K t
,,err
,,,rep
,,,,ifk(t) m=1; else if(m) break
,,,,xm p2
,,,,h = OnScreenDraw(p2.x p2.y 10 10 &OSD_Proc_Red_Light 0 210 h)
,,,,if(!memcmp(&pp &p2 sizeof(POINT))) continue
,,,,pp=p2
,,wait 0.4 KF t;err continue
,,ret
II think for smoother tracing, I will need to get the exact coordinates that the mouse cursor went through and then paint them sequentially. This seems like it should be possible through GetMouseMovePointsEx but don't know how to implement in QM. I am looking at
http://msdn.microsoft.com/en-us/library/...s.85).aspx
http://www.pinvoke.net/default.aspx/user...ntsEx.html
but not successful yet at converting msdn stuff into QM.
Any thoughts?
S
Posts: 12,062
Threads: 140
Joined: Dec 2002
Why using h for flags?
The code could be simpler than your last version. And probably don't need to collect mouse points.
Posts: 1,006
Threads: 330
Joined: Mar 2007
sorry if I made it unnecessarily confusing but the h was the window hwnd not for flags...maybe I put it in the wrong place.
either way, if you move mouse too quickly in tracing mode, it creates gaps between circles instead of a continuous tracing/drawing line.
If I got all the points from GetMouseMovePoints, then could create continuous trace but maybe there is a simpler way.
I tried getting the x and y with a hook procedure taken from other stuff in the forum but got still same disconnected tracing.
Thanks for trying to help me with this,
Stuart
Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi Gintaras,
Sorry to bug you about this. The GetMouseMovePoints function would be useful for telestrator as well as gesture functions where it is important to know over what onscreen elements the gesture included (like lasso gesture).
I can't seem to figure out how to import this MSDN function into QM. Any suggestions?
Thanks, S
http://msdn.microsoft.com/en-us/library/aa932973.aspx
Quote:GetMouseMovePoints
Windows Mobile 6.5 This topic has not yet been rated - Rate this topic A version of this page is also available for
Windows Embedded CE 6.0 R3
4/8/2010
This function retrieves points, associated with WM_LBUTTONDOWN and WM_MOUSEMOVE messages, that the OS typically discards when an application cannot process these messages as fast as the application receives these messages.
Syntax
--------------------------------------------------------------------------------
Copy
BOOL WINAPI GetMouseMovePoints(
PPOINT pptBuf,
UINT nBufPoints,
UINT* pnPointsRetrieved
);
Parameters
--------------------------------------------------------------------------------
pptBuf
[out] Pointer to an array of POINT structures. This buffer contains the points retrieved from the current mouse move.
nBufPoints
[in] Unsigned integer that specifies the size, in points, of the buffer passed in the pptBuf parameter.
pnPointsRetrieved
[out] Pointer to an unsigned integer. This parameter contains the number of points actually retrieved into the pptBuf buffer.
Return Value
--------------------------------------------------------------------------------
TRUE indicates success. FALSE indicates failure. To get extended error information, call GetLastError.
Remarks
--------------------------------------------------------------------------------
This function allows an application to track mouse or stylus input at a somewhat higher resolution than the resolution of the display screen. This behavior improves inking performance. This function does not draw the ink, but just allows you to collect the points more easily so that another function can draw the ink.
This function is not supported for emulation.
Requirements
Posts: 12,062
Threads: 140
Joined: Dec 2002
Use GetMouseMovePointsEx, don't need to import somehow.
Posts: 1,006
Threads: 330
Joined: Mar 2007
I think I meant GetMouseMovePointsEx instead of GetMouseMovePoints but still don't know how to use it in QM. I don't find anything in the search or system functions.
S
Posts: 12,062
Threads: 140
Joined: Dec 2002
It's Windows API, look in MSDN library. I never used it, not sure if it would be useful in on-screen drawing, anyway, can draw without it, it will probably just make more difficult.
Posts: 1,006
Threads: 330
Joined: Mar 2007
ok, I understand, but still can't get the drawing to be continuous with Onscreendraw. It still skips spaces when I move mouse too quickly. Strange.
Thanks, S
Posts: 12,062
Threads: 140
Joined: Dec 2002
If delay is 10 ms, should not skip. Can try even 5 or 2. Mouse messages are not sent at such high rate. Probably highest is 10 ms.
If need 100% reliable, use low-level mouse hook. Some examples should be in this forum.
Also, make sure it draws always in the same window, ie use handle properly.
|