Jump to content
  • Advertisement

Archived

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

TwisteR

VC++ WM_PAINT

This topic is 6291 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!