CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Location
    Estonia
    Posts
    235

    Drawing rectangles in 2D with mouse

    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.
    Rate my post if i it was useful!

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Drawing rectangles in 2D with mouse

    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/libr...8VS.80%29.aspx

  3. #3
    Join Date
    May 2005
    Location
    Estonia
    Posts
    235

    Re: Drawing rectangles in 2D with mouse

    Basically i need to draw many rectangles using mouse.
    Look at simple screenshot for my example:




    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.
    Rate my post if i it was useful!

  4. #4
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Drawing rectangles in 2D with mouse

    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.

  5. #5
    Join Date
    May 2005
    Location
    Estonia
    Posts
    235

    Re: Drawing rectangles in 2D with mouse

    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.
    Rate my post if i it was useful!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured