Board index » Visual Studio » Bitmap and Picture Control ???
|
janesc
|
Bitmap and Picture Control ???
Visual Studio94
I'm trying to write a simple example program to learn more about using bitmaps and picture controls. It is a dialog-based program with only two buttons and one picture control. One button is to display a bitmap, and the other is to erase the bitmap. The bitmap is displayed correctly and does erase with the other button, but I am not able to click on the display button again without an Assertion Error. Although I have found that if I declare the bitmap locally in the display button handler and put another bitmap declaration in the erase button handler, it is possible to click the display button after the erase button and the bitmap is redisplayed. However when declared locally, the bitmap is lost if the dialog is covered and then does not repaint the bitmap. It does repaint when the bitmap is declared in the class declaration. So, I would prefer to declare the bitmap in the class declaration, but what is required to be able to click on the display button again. Code is below: void CBitmapTestDlg::OnDisplay() { // CBitmap bitmap1; ***remove this*** bitmap1.LoadBitmap(IDB_BITMAP1); m_bmp1.SetBitmap(bitmap1); } void CBitmapTestDlg::OnErase() { // CBitmap bitmap1; ***remove this*** DeleteObject(bitmap1); Invalidate(); UpdateWindow(); } - |
