Bing
Bing

Reputation: 1

About MFC, how to pass parameters to function OnPaint

I write a override function OnPaint() in my own dialog, I don't know how to pass parameters to this function, it's called automatic. And I also wanna know that I used a PictureControl in my dialog, and load a picture file from disk using my own function( BitmapShow(UINT ctrlID, CString filePath) ), should I write code of loading picture in the override function OnPaint()? or copy this code segment into OnPaint()?

Upvotes: 0

Views: 559

Answers (1)

ScottMcP-MVP
ScottMcP-MVP

Reputation: 10415

You can not change the definition of the OnPaint function. It is called only in response to the automatic WM_PAINT message. You can, and should, store any additional information needed by your OnPaint function as member variables, not as parameters.

To paint a picture on a picture control you should override the OnPaint of the picture control, not the dialog. This is done in a class you derive from CStatic.

Upvotes: 3

Related Questions