CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2007
    Location
    Bangalore,India
    Posts
    164

    Smile draw multiple lines and move then on screen

    I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.

    I have created rectangle region for each line and trying to move the line.

    When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.

    How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC. Please help me how can I do it. Any help is highly appreciated. Thanks Sujan

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: draw multiple lines and move then on screen

    It would be helpful if you posted your code so that we can see what you are doing. What are you doing for the WM_PAINT message?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: draw multiple lines and move then on screen

    You may want to post your code for drawing...
    Victor Nijegorodov

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: draw multiple lines and move then on screen

    Quote Originally Posted by sujan.dasmahapatra View Post
    When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.
    The main principle is: you remember all the objects you have drawn (color, weight, location, orientation, etc.), and you re-draw every single object on WM_PAINT.

    See the sample project in the post.
    Best regards,
    Igor

  5. #5

    Re: draw multiple lines and move then on screen

    For drawing with 2D application, to use MFC will saves much time, and some sample like drawcli will be help, and a few other third - party library (like E-XD++ Visualization) will saves you more time.

    Jackie Zhang

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