Dialog background picture
-
Hi, I have used the following codes to load a bitmap onto the dialog box for the background during onPaint.However I need to change the picture when i click another button. Is there a function which i can call to redraw the bitmap again? cos when i put these code into a function, it doesnt work. Any idea? [code] CDC BmpDc; CPaintDC dc(this); VERIFY( BmpDc.CreateCompatibleDC(&dc) ); CBitmap BkBmp, *pOldBmp; //BkBmp. BkBmp.LoadBitmap(IDB_background); pOldBmp = (CBitmap *)BmpDc.SelectObject(&BkBmp); dc.BitBlt(0,0,m_nW,m_nH,&BmpDc,0,0,SRCCOPY); BmpDc.SelectObject(pOldBmp); [/code] :confused: Newb VCer
-
Hi, I have used the following codes to load a bitmap onto the dialog box for the background during onPaint.However I need to change the picture when i click another button. Is there a function which i can call to redraw the bitmap again? cos when i put these code into a function, it doesnt work. Any idea? [code] CDC BmpDc; CPaintDC dc(this); VERIFY( BmpDc.CreateCompatibleDC(&dc) ); CBitmap BkBmp, *pOldBmp; //BkBmp. BkBmp.LoadBitmap(IDB_background); pOldBmp = (CBitmap *)BmpDc.SelectObject(&BkBmp); dc.BitBlt(0,0,m_nW,m_nH,&BmpDc,0,0,SRCCOPY); BmpDc.SelectObject(pOldBmp); [/code] :confused: Newb VCer
If OnPaint() takes the bitmap ID from a member variable and paints it, your button handler might simply change the ID of the bitmap to draw and invalidate the window. Something like this:
// Set the new background m_BackBitmapID = IDB_Background1; // Just invalidate the window // OnPaint will do the job. Invalidate();
-- jlr http://jlamas.blogspot.com/[^] -
If OnPaint() takes the bitmap ID from a member variable and paints it, your button handler might simply change the ID of the bitmap to draw and invalidate the window. Something like this:
// Set the new background m_BackBitmapID = IDB_Background1; // Just invalidate the window // OnPaint will do the job. Invalidate();
-- jlr http://jlamas.blogspot.com/[^]