Archived

This topic is now archived and is closed to further replies.

TwisteR

VC++ WM_PAINT

Recommended Posts

Hi...I am making a painting program and I want there to be a line drawn on the screen without the user having to do so.. the code i have so far is: MoveTo(100,200); LineTo(200,200); it is in the C___View::Draw(CDC *pDC) function.. How do i override WM_PAINT for this to work??? Thank you. ----------------------------- -------Mitch Mulholland------ ----A.K.A.= TwisteR---------- -----------------------------

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
With MFC you don''t handle the WM_PAINT message. Just put your drawing code in the OnDraw methoed of the CView class.

ECKILLER

Share this post


Link to post
Share on other sites
Well, sort of true.

Assuming you''re using MFC, you have to map the messages properly. Usually the way to do this is to just use the class wizard, but since you apparenly haven''t, here''s how to do it manually:

declare OnDraw as follows in your CView header:
virtual void OnDraw(CDC* pDC);

Place this in your message map (between BEGIN_MESSAGE_MAP(...) and END_MESSAGE_MAP())
ON_WM_PAINT()

Implement OnDraw as follows:
void C___View::OnDraw( CDC * pDC )

Without the ON_WM_PAINT in the message map your OnDraw will never get called. Yes, you have to call it OnDraw. No, the message map isn''t really C++, it''s sort of a script to set up the winproc that MFC does automagically for you.

-fel

Share this post


Link to post
Share on other sites