BOOL CStartupView::SetButtonImage(CXTButton *btnButton, UINT uiID, CSize size) { CSize sz; CRect dimensions; btnButton->GetClientRect(dimensions); CXTPImageManagerIconHandle iconHandle; CXTPImageManagerIcon* pIcon; // load icon iconHandle = pIcon->LoadBitmapFromResource(MAKEINTRESOURCE(uiID), NULL); pIcon = new CXTPImageManagerIcon(0, iconHandle.GetExtent().cx, iconHandle.GetExtent().cy); pIcon->SetNormalIcon(iconHandle); CMDTARGET_RELEASE(pIcon); sz.cx = size.cx; sz.cy = size.cy; // set icon to the button BOOL bIconSet = btnButton->SetIcon(sz,iconHandle,iconHandle); UINT uIcon[] = {(UINT)btnButton->GetDlgCtrlID()}; m_pImageManager->SetIcons(uiID, uIcon, _countof(uIcon), size); return bIconSet; }
void CSgSelectionPreparationBar::SetButtonImage(CXTPButton* pButton, UINT nID, CSize sz) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CXTPImageManagerIconHandle iconHandle; CXTPImageManagerIcon* pIcon; // load icon iconHandle = pIcon->LoadBitmapFromResource(::AfxGetResourceHandle(), MAKEINTRESOURCE(nID), NULL); pIcon = new CXTPImageManagerIcon(0, iconHandle.GetExtent().cx, iconHandle.GetExtent().cy); pIcon->SetNormalIcon(iconHandle); pButton->SetIcon(sz,iconHandle,iconHandle); CMDTARGET_RELEASE(pIcon); }
void CXTPPopupControl::SetRegionAlphaLayer(CXTPImageManagerIcon* pIcon) { if (!pIcon) return; if (!m_pfnUpdateLayeredWindow) return; CXTPImageManagerIconHandle hShadow; hShadow.CopyHandle(pIcon->GetIcon()); if (!hShadow.PreMultiply()) return; PBYTE pBits = hShadow.PreMultiply(); CSize szIcon = hShadow.GetExtent(); int cx = szIcon.cx; int cy = szIcon.cy; BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = 255; bf.AlphaFormat = 0x01; POINT pt = {0, 0}; CClientDC cDC(this); CDC dc; dc.CreateCompatibleDC(&cDC); UINT* pvBits = NULL; HBITMAP hBitmap = CXTPImageManager::Create32BPPDIBSection(cDC, cx, cy, (LPBYTE*)&pvBits); if (pvBits == NULL || hBitmap == NULL) return; MEMCPY_S(pvBits, pBits, cx * cy* 4); HBITMAP hOld = (HBITMAP)SelectObject(dc, hBitmap); ModifyStyleEx(0, WS_EX_LAYERED); m_pfnUpdateLayeredWindow((HWND)GetSafeHwnd(), (HDC)0, 0, &szIcon, dc.GetSafeHdc(), &pt, 0, &bf, 0x02); SelectObject(dc, hOld); DeleteObject(hBitmap); dc.DeleteDC(); m_bLayered = TRUE; }