Draw Rectangle onto NULL

I'm sure this is existent somewhere, but I didn't know what its called... So I'm posting.

I'd like to know how to draw a rectangle around the mouse whenever it goes, I know an algorithm, in my head it works something like this

Insert width, insert height, and draw rectangle accordingly around the mouse.

I've been looking for a while but my searches aren't worded right.

Thanks.

P.S. I guess I'm basically asking how to draw onto nothing.
closed account (D80DSL3A)
Are you talking about drawing a rectangle around the mouse cursor in a windows program? That is sensible and not very hard (using GDI methods). Please clarify meaning of "draw onto nothing".
Pseudo-code:

1
2
3
4
5
6
Rectangle->left = Cursor.X - (width / 2);
Rectangle->right = Cursor.X + (width / 2);
Rectangle->top = Cursor.Y - (height / 2);
Rectangle->bottom = Cursor.Y + (height / 2);

Rectangle->draw();


How you actually draw the rectangle depends on what platform you're on, where you want to draw the rectangle, which libraries you choose to use, etc.
@fun2code

That is almost exactly what I'm talking about though, but without having any windows present. Draw onto nothing means, that it wouldn't be limited to windows.

@Kiana

Do you know any libraries? I'd prefer Windows libraries, but cross-platform works too.
Doing things to the cursor is a platform-specific task.

You'll have to set the global mouse cursor to a cursor that has the rectangle shape. Use an image editor to create the proper CUR file, (compile it into your application (as a resource), and use LoadCursor() to load the cursor resource) or (use LoadCursorFromFile() to load the CUR file), and SetCursor() to modify the current on-screen cursor, and SetSystemCursor() to modify the system cursors to your special one.

Good luck!
Would it really be done to the cursor?

There isn't a way to simulate a rectangle just around the cursor without affecting it?

The cursor would only be used for position.
Er, well, I suppose you could have a global cursor hook and draw directly on the display...
Topic archived. No new replies allowed.