[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Drawing and deleting lines

Posted on 2000-03-17
2
Medium Priority
?
228 Views
Last Modified: 2013-11-20
Hi,

I made the following code. It should Draw lines with black color, if lDel is FALSE, if lDel is FALSE, it should delete this lines by setting the line-colour to the background-colour, so that the already drawn lines are overdrawn by the background-colour. But - that doesn´t work. How does it work the right way? Please give a detailed answer! Thanks in advance!


COLORREF BkColor, FgColor;

if (lDel)      // Set backgroundcolor
{      FgColor = dc->GetTextColor();
      BkColor = dc->GetBkColor();
      dc->SetTextColor(BkColor);
}

// Now I draw or delete some lines
...

if (lDel)      // Set old line-color as the new linecolor
{      dc->SetTextColor(FgColor);
}
0
Comment
Question by:erebel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Expert Comment

by:migel
ID: 2629708
Hi!
When you Draw line DC use PEN currently selected to it, so lines always appear in PEN`s color, not setted by SetTextColor functions.
Best way to erase lines is using XOR mode while drawing
to do it you must call SetROP2 with R2_XORPEN;
line will be erased when you draw it next time.
0
 
LVL 3

Accepted Solution

by:
kulina earned 150 total points
ID: 2654484
In OnPaint enter these lines
// start
CPen pen;
CPaintDC dc(this);
// Don't forget to do this...
CPen* pOldPen = dc.SelectObject (&pen);
if(IDel == FALSE)
{
BkColor = dc->GetBkColor();
pen.CreatePen(PS_SOLID, 1, BkColor );
dc.SelectObject(&pen);
dc.MoveTo(x, y);
dc.LineTo(a, b);
}
dc.SelectObject(pOldPen);
// end

....where x and y are coordinates starting postition of your line, and a and b are ending positions of your line.
I haven't tried this possible solution but I'm pretty convicned it'll work.
Good Luck!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question