Click to See Complete Forum and Search --> : Drawing rectangles in 2D with mouse


BytePtr
November 20th, 2009, 06:42 AM
Here is video about example:
http://www.youtube.com/watch?v=cmcnIWN6y2Y

I would like to do same thing. But in plain 2D.

So i need just draw simple fixed size rectangles with mouse.
It could be made using OpenGL (better for me) or using GDI. This is not so important at the moment. But it should work on simple GRID that i also draw. The cells will have same width and height.

Where should i start?



Let's take simple rectangle, i can draw one. But what about the next? When im holding mouse down and dragging the program should draw rectangles just like in video.
But just plain 2D rectangles.


Draw one rect, remember it's position then whenever mouse moves away from it to next rect in grid draw another rect in there and so on?
Or what?



Maybe somebody knows similar example that could be downloaded or examined?



Thanks.

hoxsiew
November 20th, 2009, 07:55 AM
It's hard to understand what you are asking for and I can't get you-tube at work so I have to guess. Take a look at the DRAWCLI sample code from msdn:

http://msdn.microsoft.com/en-us/library/9t94971d%28VS.80%29.aspx

BytePtr
November 20th, 2009, 06:03 PM
Basically i need to draw many rectangles using mouse.
Look at simple screenshot for my example:

http://img18.imageshack.us/img18/9751/clip3w.png (http://img18.imageshack.us/i/clip3w.png/)


Like you see there is RED grid created with just holding down left mouse button and dragging the mouse.


Holding down mouse button and dragging creates simple rectangle under current mouse cursor position. Many rectangles creates a grid.



I need to draw rectangles aligned side by side with mouse.


Just like in screenshot.

hoxsiew
November 20th, 2009, 07:42 PM
Did you check out the DRAWCLI example? It has a rectangle shape that could probably be modified to draw a grid instead of a filled rectangle.

BytePtr
November 21st, 2009, 04:32 PM
Actually video shows exactly what i want to do. I must replicate it exactly one by one.
But i thought that first i will try it in 2D.


Yes this sample draws rects but i need to draw many of them side by side. Like you said grid.

Drawing rects is one thing but drawing rect and copying it over and over again to create grid is another thing.

And all this must be done using mouse.



Drawing rect under mouse is not very big problem but i need some direction how i could draw many of them, just like in video.