I am trying to put an HICON (converted from a CExtBitmap) on a CExtButton. The first two blocks of code show how I am converting two 24-bit bitmap resources into two HCON handles. This creation ocurrs in the constructor of a CExtResizableDialog derived class. The on button handler below shows how I am attempting to switch the button’s icon when the user presses the button. The problem is stated below:
- Upon boot, the button shows the default icon fine. This icon is set in the OnInitDialog routine.
- The first press works fine. The icon is toggled as expected.
- The second press, the button shows no icon. Just blank.
- All subsequent presses show a blank icon.
It cannot figure out what is wrong.
Gil
//Load bitmap for maximize tab button and setup button. VERIFY(bmpTemp.LoadBMP_Resource( MAKEINTRESOURCE(IDB_bmpMaxTabSize), RT_BITMAP, GlobalInstance)); bmpTemp.Make32(); bmpTemp.AlphaColor( RGB(255,255,255), RGB(0,0,0), 0); m_hIconMaxTabSize = bmpTemp.CreateHICON(); //Load bitmap for minimize tab button. VERIFY(bmpTemp.LoadBMP_Resource( MAKEINTRESOURCE(IDB_bmpMinTabSize), RT_BITMAP, GlobalInstance)); bmpTemp.Make32(); bmpTemp.AlphaColor( RGB(255,255,255), RGB(0,0,0), 0); m_hIconMinTabSize = bmpTemp.CreateHICON();
void VRTabTeachpoints::OnBnClickedMaxScreen() { //!This call will toggle the full-screen mode state and adjust the tab size //!appropriately. That is, if the call toggles the state to full-screen, the //!tab size is increased. If the call toggles the state to normal-size, //!the tab size will be decreased. m_diagnostics.SetTabFullSizeFlg(!m_diagnostics.GetTabFullSizeFlg()); //Change the icon on the button. HICON hIcon = m_diagnostics.GetTabFullSizeFlg() ? m_hIconMinTabSize : m_hIconMaxTabSize; m_btnMaxScreen.SetIcon(hIcon); }