Re: Picture Box images
On Dec 22, 5:00 pm, Ed <m...@right.her> wrote:
I have a picture box that I am drawing a bargraph into IDC_BARS
It works with no problems and shows the bargraph in the picture box.
I would like to add a bitmap from a file in the background.
You picture box is already a CStatic, right?
* add a bitmap to your resources
* add a CBitmap member to your parent window
* when you create your parent window
* add SS_BITMAP style to your picture box when you create it (or do
it from dialog editor if your parent is a dialog)
* load bitmap
* call SetBitmap on your member
You don 't do any of that in drawbars (as Joe said, that's wrong,
wrong, wrong).
It's not hard to make your code correct, BTW: derive a class from
CStatic, move drawbars() code into OnPaint of your derived class
(dont' forget message map!) and create that instaed of a plain
CStatic. In OnPaint, do e.g.
CMyThang::OnPaint()
{
__super::OnPaint();
CPaintDC dc(this);
whatYouDidInDrawBars();
// but using dc, not GetDC();
}
And then, where you call drawbars, call invalidate on your control.
Goran.