3
votes

I draw some lines on a SDI application in visual c++, these lines are disappeared whenenver a new line or the size of the windo is changed, any clue how to keep these lines visible all the time?

thanks.

RZ

3
Show some examples of what you did. Firstly, have you overridden the OnEraseBkgnd, OnPaint or OnDraw methods?stackunderflow
Wow, just saw the date, 2010 post... lol. I imagine ya figured this out.stackunderflow

3 Answers

3
votes

The Correct Function handler in an SDI Application is OnDraw. Any Painting instructions should be put here.

It might cause some confusion that sdi/mdi-applictaions use Ondraw, while dialog applications use OnPaint.

The reason your lines are vanishing is probably due to the standard behaviour of OnDraw(), which is to clear the client area as its first action when it is invoked.

Update: Ondraw is a member of the View

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

0
votes

You must draw the lines in the OnPaint() function - this is called every time the window needs to be displayed

0
votes

You must handle the WM_PAINT message.

Windows sends your window a WM_PAINT message to ask your application to redraw all or part of the window.

If I do remember MFC (it's been a long time since I used it last time), this means that you have to implement the OnPaint method.