PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

mouse pointer

Hello, I developed a little app which displays a mouse pointer. But I have an issue where it leaves some artefacts on the screen. This happens if the screen content under the mouse is changed.

Here is the part of the worker thread which is doing the job.

...
pt = ptAbs;
if( pt.x < 0 ) pt.x = 0;
if( pt.x >= ScreenSizeX ) pt.x = ScreenSizeX - 1;
if( pt.y < 0 ) pt.y = 0;
if( pt.y >= ScreenSizeY ) pt.y = ScreenSizeY - 1;

if( (pt.x != ptOld.x) || (pt.y != ptOld.y) ) {
SelectObject( hDC_Mouse, hBitmapCursor );

if( ptOld.x != -1 ) {
BitBlt( hDC_Main, ptOld.x, ptOld.y, 15, 25, hDC_Mouse, 0, 0, SRCINVERT );
}
BitBlt( hDC_Main, pt.x, pt.y, 15, 25, hDC_Mouse, 0, 0, SRCINVERT );

ptOld = pt;
...

This code is run if the mouse is moved. But if the screen changed since the last move, the first BitBlt leaves (or better produces) the artefacts. I know why the artefacts are left, but have no idea to gid rid of. I also can't use the normal window messages because this is not an application window, it is the normal desktop (today screen for example).

Are there any functions (BitBlt, PatBlt, MaskBlt...) to look if there is the older cursor displayed or allready overwritten by some other applications?
what about checking which app is under your cursor and asking it to redrawn this small part of screen?
Might be slow, but correct.
Thanks for your answer.

I tried to do this with no luck. I get the window handle with GetForegroundWindow, invalidate the rectangle. I called UpdateWindow/SendMessage(WM_PAINT) but nothing happens.

Could you please explain a little more how you would do it?
(This may be stabbing in the dark)...

Are you sure that the GetForegroundWindow isn't returning your own HWND? Try GetWindow with GW_HWNDNEXT as the uCmd parameter maybe?

Can you call InvalidateRect on the other window - that should trigger a WM_PAINT event in its thread.
Addendum:

This function retrieves the handle to the window that contains the specified point.

HWND WindowFromPoint(
POINT Point );


Try that instead of the GetWindow.
this is also untested, but what you want to do could be accomplished using window regions:

- set up a window with a window region matching your mouse pointer
- just move the window around, let WinCE handle the redrawing

hmm, this is interesting, i might give it a try later on :)

cryo
You mean a window exactly matching the pixels of the pointer? If not, if the window in the background updates, surely the "pointer" window won't know about it? (Windows GUI stuff isn't my strongest suit..).
check out :

http://www.em-motion.com/RgnSample.zip

it's just hacked together since my last post, so don't expect wonders here :)

It displays a topmost, transparent mouse cursor (done in paint *ahem*) that can be moved with the cursor keys.

cryo
Code:
// BitmapToRegion : Create a region from the "non-transparent" pixels of a bitmap


That's answered my question. Thanks Cryo :)
CE 2.11 and below did not support Window Regions (I know, I was going to use them a few years ago). So that must be a new addition to the API for CE 3.0.

Dan East
@cryo:
Create thanks for your effort. I also did a test with the small window. In general it works. But the problem is, you can not put that window above the task bar or start menu (at least I don't know how). Also, for mouse movements, this solution is very slow.

I will now try the WindowFromPoint. Let's see...

Again, great thanks for your effort. :)

May there is a very simple solution. Is there a good algorithm to compare a couple of pixel data and invert them individualy if needed?
Deje · 19 Sep 2002, 14:59 UTC — Anonymous is DeJe
Oh, I forgot.
If you have a PPC where you can plug in a USB mouse you can try and see what I am doing.

Mouse Pointer

Deje

Update:
I got it work so far. The answer is TransparentImage and some manipulations. It works to 99%. Thanks to all who spend time on that issue.
I came across this today, and it seemed pretty interesting. How do I work that rgnsample thing??? I would like to have a cursor on my PPC!!! :D