Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Putting an HICON (converted from a CExtBitmap) on a CExtButton Collapse All
Subject Author Date
Krustys Donuts Jul 25, 2008 - 6:51 PM

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:


 



  1. Upon boot, the button shows the default icon fine. This icon is set in the OnInitDialog routine.

  2. The first press works fine. The icon is toggled as expected.

  3. The second press, the button shows no icon. Just blank.

  4. 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); }

Technical Support Jul 28, 2008 - 5:08 AM

If you are passing some HICON handle in CExtButton::SetIcon(), you should forget about this HICON handle. It becomes part of an internal image object inside the button control so the HICON handle does not exist after the CExtButton::SetIcon() method returns execution control.

We would like to ask you not to use HICON handles at all because only latest two Windows version (XP and Vista) support icons with alpha channel. Please use the m_btnMaxScreen.m_icon.m_bmpNormal property directly. This is an object of CExtBitmap type. You can assign it from other CExtBitmap objects.