tags:

views:

60

answers:

3
+2  Q: 

MFC Drawing Lines

Hi, 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

A: 

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

Martin Beckett
but there is no OnPaint() function in all the classes generated for a SDI application, then what should i do?
reonze
A: 

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.

sergiom
+3  A: 

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

sum1stolemyname