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
-
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
You should draw all the lines in the code that handles the
WM_PAINT
message. Each time a new line is created, you save the details in a list or similar array. Then as your paint code is called, it should iterate that list and draw each line.Use the best guess
-
You should draw all the lines in the code that handles the
WM_PAINT
message. Each time a new line is created, you save the details in a list or similar array. Then as your paint code is called, it should iterate that list and draw each line.Use the best guess
how can I implement a transform for each line. I want to pick a line by mouse and then move it anywhere on the screen and place it. drag and move. Currently I am defining a a rect for each line and doing InvalidateRect() and moving and when this line is crossing other line , the other line is getting removed or wiped out. How can I move lines on screen without affecting other lines. Thanks Sujan
-
how can I implement a transform for each line. I want to pick a line by mouse and then move it anywhere on the screen and place it. drag and move. Currently I am defining a a rect for each line and doing InvalidateRect() and moving and when this line is crossing other line , the other line is getting removed or wiped out. How can I move lines on screen without affecting other lines. Thanks Sujan
I just explained what you have to do; redraw them all, not just the one that has moved. You need to invalidate the entire Window, or ensure that you check each line within the invalidated rectangle. Understanding this basic concept is key to writing Windows applications.
Use the best guess
-
I just explained what you have to do; redraw them all, not just the one that has moved. You need to invalidate the entire Window, or ensure that you check each line within the invalidated rectangle. Understanding this basic concept is key to writing Windows applications.
Use the best guess
-
how can I implement a transform for each line. I want to pick a line by mouse and then move it anywhere on the screen and place it. drag and move. Currently I am defining a a rect for each line and doing InvalidateRect() and moving and when this line is crossing other line , the other line is getting removed or wiped out. How can I move lines on screen without affecting other lines. Thanks Sujan
Richarsd just told you! Learn to read before learning to code.
-
Richarsd just told you! Learn to read before learning to code.
That is perhaps the most ugliest way to solve the problem and has many horrible disadvantages ... IT IS OLD SCHOOL HORRIBLE DONT DO IT. Problems you will definitely encounter: 1.) The draw process become slower and slower the more lines you have to draw 2.) As your draw process is contained inside the WM_PAINT message your can't thread it 3.) Your application becomes locked and unresponsive while in the draw process 4.) Every time you resize the window it will redraw all the line database 5.) Every time you move the window order or position it will do an entire redraw Get an old copy of MS_WORD and open a 1MB image file if you want to see what it looks like. Old versions of many Cad programs and Corel draw were practically unusable because they used the above technique and we have long since moved on from it. The correct and more modern way to do this is to create a drawing thread that converts your line database onto a memory DC. That is all the thread does all the time when triggered. The WM_PAINT message simply puts the last finished memory DC from the thread to screen. Usually every database alteration is held so you can also undo-redo function it. The obvious advantages is your program never suffers non responsive or semi locked behavior no matter how complex the drawing gets and the application drawing process does not flash and carry on. Let me know if you get stuck and I will do a quick stub to show you how it works.