void CEditDelayed::OnInit(CHeaderCtrl* pColumnHeader) { SetEditRect(false); CRect rectWindow; GetClientRect(rectWindow); m_pctrlColumnHeader = pColumnHeader; m_hCursor = LoadCursor(NULL, IDC_ARROW); m_nCurrentColumnIdx = 0; CImageList* pImageList = new CImageList(); pImageList->Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1); pImageList->SetBkColor(CLR_NONE); if (pColumnHeader != NULL) pImageList->Add(CTempIconLoader(_T("SEARCHEDIT"))); else pImageList->Add(CTempIconLoader(_T("KADNODESEARCH"))); m_iwColumn.SetImageList(pImageList); m_iwColumn.Create(_T(""), WS_CHILD | WS_VISIBLE, CRect(0, 0, ICON_LEFTSPACE, rectWindow.bottom), this, 1); pImageList = new CImageList(); pImageList->Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1); pImageList->SetBkColor(CLR_NONE); pImageList->Add(CTempIconLoader(_T("FILTERCLEAR1"))); pImageList->Add(CTempIconLoader(_T("FILTERCLEAR2"))); m_iwReset.SetImageList(pImageList); m_iwReset.Create(_T(""), WS_CHILD , CRect(0, 0, ICON_LEFTSPACE, rectWindow.bottom), this, 1); ShowColumnText(true); }
inline bool addFile(CListCtrl *lFiles, string filename, __int64 size){ char buffer[16]; HICON ico = NULL; int ico_id; CImageList *imgLst = NULL; if(size >= (__int64)4*1024*1024*1024){ MessageBox(0, loadString(IDS_TOO_BIG_FILE), "KGB Archiver", 0); return false; } ico = getIcon(filename); if(ico != NULL){ imgLst = lFiles->GetImageList(LVSIL_SMALL); if(imgLst == NULL){ imgLst = new CImageList(); imgLst->Create(16, 16, ILC_COLORDDB, 0, INT_MAX); imgLst->SetBkColor(0x00FFFFFF); } ico_id = imgLst->Add(ico); lFiles->SetImageList(imgLst, LVSIL_SMALL); lFiles->InsertItem(lFiles->GetItemCount(), "", ico_id); }else lFiles->InsertItem(lFiles->GetItemCount(), ""); lFiles->SetItemText(lFiles->GetItemCount()-1, 0, filename.c_str()); sprintf(buffer, "%s", convertUnits(size)); lFiles->SetItemText(lFiles->GetItemCount()-1, 1, buffer); return true; }
void CServerListCtrl::SetAllIcons() { CImageList iml; iml.Create(16,16,theApp.m_iDfltImageListColorFlags|ILC_MASK,0,1); iml.SetBkColor(CLR_NONE); iml.Add(CTempIconLoader(_T("Server"))); HIMAGELIST himl = ApplyImageList(iml.Detach()); if (himl) ImageList_Destroy(himl); }
void CKadContactListCtrl::SetAllIcons() { CImageList iml; iml.Create(16,16,theApp.m_iDfltImageListColorFlags|ILC_MASK,0,1); iml.SetBkColor(CLR_NONE); iml.Add(CTempIconLoader(_T("Contact0"))); iml.Add(CTempIconLoader(_T("Contact1"))); iml.Add(CTempIconLoader(_T("Contact2"))); iml.Add(CTempIconLoader(_T("Contact3"))); iml.Add(CTempIconLoader(_T("Contact4"))); ASSERT( (GetStyle() & LVS_SHAREIMAGELISTS) == 0 ); HIMAGELIST himl = ApplyImageList(iml.Detach()); if (himl) ImageList_Destroy(himl); }
/////////////////////////////////////////////////////////////////////////////// // DrawImage int CXHeaderCtrl::DrawImage(CDC* pDC, CRect rect, LPHDITEM lphdi, BOOL bRight) { CImageList* pImageList = GetImageList(); int iWidth = 0; if (lphdi->iImage != XHEADERCTRL_NO_IMAGE) { if (pImageList) { if (rect.Width() > 0) { POINT point; point.y = rect.CenterPoint().y - (m_sizeImage.cy >> 1); if (bRight) point.x = rect.right - m_sizeImage.cx; else point.x = rect.left; SIZE size; size.cx = rect.Width()<m_sizeImage.cx ? rect.Width():m_sizeImage.cx; size.cy = m_sizeImage.cy; // save image list background color COLORREF rgb = pImageList->GetBkColor(); // set image list background color to same as header control pImageList->SetBkColor(pDC->GetBkColor()); pImageList->DrawIndirect(pDC, lphdi->iImage, point, size, CPoint(0, 0)); pImageList->SetBkColor(rgb); iWidth = m_sizeImage.cx; } } }
// @pymethod |PyCImageList|SetBkColor|Sets the background color for an Image List. PyObject *PyCImageList_SetBkColor( PyObject *self, PyObject *args ) { CImageList *pList; if (!(pList=PyCImageList::GetImageList(self))) return NULL; int col; // @pyparm int|color||The new background color. if (!PyArg_ParseTuple( args, "i:SetBkColor", &col)) return NULL; GUI_BGN_SAVE; BOOL ok = pList->SetBkColor(col); GUI_END_SAVE; if (!ok) RETURN_ERR("SetBkColor failed"); RETURN_NONE; }
void CServerListCtrl::SetAllIcons() { CImageList iml; iml.Create(16,16,theApp.m_iDfltImageListColorFlags|ILC_MASK,0,1); iml.SetBkColor(CLR_NONE); iml.Add(CTempIconLoader(_T("Server"))); HIMAGELIST himl = ApplyImageList(iml.Detach()); if (himl) ImageList_Destroy(himl); //Chocobo Start //server icon related //服务器图标相关, added by Chocobo imagelist.DeleteImageList(); imagelist.Create(16,16,theApp.m_iDfltImageListColorFlags|ILC_MASK,0,1); imagelist.SetBkColor(CLR_NONE); imagelist.Add(CTempIconLoader(_T("Server"))); imagelist.SetOverlayImage(imagelist.Add(CTempIconLoader(_T("CLIENTSECUREOVL"))), 1); //Chocobo End }
void CCommentDialog::Localize(void) { GetDlgItem(IDC_RESET)->SetWindowText(GetResString(IDS_PW_RESET)); GetDlgItem(IDC_CMT_LQUEST)->SetWindowText(GetResString(IDS_CMT_QUEST)); GetDlgItem(IDC_CMT_LAIDE)->SetWindowText(GetResString(IDS_CMT_AIDE)); GetDlgItem(IDC_RATEQUEST)->SetWindowText(GetResString(IDS_CMT_RATEQUEST)); GetDlgItem(IDC_RATEHELP)->SetWindowText(GetResString(IDS_CMT_RATEHELP)); GetDlgItem(IDC_USERCOMMENTS)->SetWindowText(GetResString(IDS_COMMENT)); GetDlgItem(IDC_SEARCHKAD)->SetWindowText(GetResString(IDS_SEARCHKAD)); CImageList iml; iml.Create(16,16,theApp.m_iDfltImageListColorFlags|ILC_MASK,0,1); iml.SetBkColor(CLR_NONE); iml.Add(CTempIconLoader(_T("Rating_NotRated"), 16, 16)); iml.Add(CTempIconLoader(_T("Rating_Fake"), 16, 16)); iml.Add(CTempIconLoader(_T("Rating_Poor"), 16, 16)); iml.Add(CTempIconLoader(_T("Rating_Fair"), 16, 16)); iml.Add(CTempIconLoader(_T("Rating_Good"), 16, 16)); iml.Add(CTempIconLoader(_T("Rating_Excellent"), 16, 16)); m_ratebox.SetImageList(&iml); m_imlRating.DeleteImageList(); m_imlRating.Attach(iml.Detach()); m_ratebox.ResetContent(); m_ratebox.AddItem(GetResString(IDS_CMT_NOTRATED), 0); m_ratebox.AddItem(GetResString(IDS_CMT_FAKE), 1); m_ratebox.AddItem(GetResString(IDS_CMT_POOR), 2); m_ratebox.AddItem(GetResString(IDS_CMT_FAIR), 3); m_ratebox.AddItem(GetResString(IDS_CMT_GOOD), 4); m_ratebox.AddItem(GetResString(IDS_CMT_EXCELLENT), 5); UpdateHorzExtent(m_ratebox, 16); // adjust dropped width to ensure all strings are fully visible RefreshData(); }
//------------------------------------------------------------------------ //! Overrides the custom draw handler, to allow custom coloring of rows. //! - Fix white background for icon images //! - Fix white background between icon and cell text //! //! @param owner The list control drawing //! @param pLVCD Pointer to NMLVCUSTOMDRAW structure //! @param pResult Modification to the drawing stage (CDRF_NEWFONT, etc.) //------------------------------------------------------------------------ void CGridRowTraitXP::OnCustomDraw(CGridListCtrlEx& owner, NMLVCUSTOMDRAW* pLVCD, LRESULT* pResult) { if (owner.UsingVisualStyle()) { // Perform standard drawing CGridRowTraitText::OnCustomDraw(owner, pLVCD, pResult); return; } // We are using classic- or XP-style int nRow = (int)pLVCD->nmcd.dwItemSpec; // Repair the standard drawing switch (pLVCD->nmcd.dwDrawStage) { case CDDS_ITEMPREPAINT | CDDS_SUBITEM: { // We want to fix cell images *pResult |= CDRF_NOTIFYPOSTPAINT; } break; case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: { // Fix CListCtrl selection drawing bug with white background for icon image // Fix CListCtrl selection drawing bug with white margin between icon and text int nCol = pLVCD->iSubItem; if (CRect(pLVCD->nmcd.rc)==CRect(0,0,0,0)) break; int nImage = owner.GetCellImage(nRow, nCol); if (nImage == I_IMAGECALLBACK) break; CImageList* pImageList = owner.GetImageList(LVSIL_SMALL); if (pImageList==NULL) break; COLORREF backColor = COLORREF(-1); if (owner.GetExtendedStyle() & LVS_EX_TRACKSELECT && owner.GetHotItem()==nRow) { #if(WINVER >= 0x0500) backColor = ::GetSysColor(COLOR_HOTLIGHT); #else if (owner.IsRowSelected(nRow)) backColor = ::GetSysColor(COLOR_HIGHLIGHT); else break; #endif } else if (owner.IsRowSelected(nRow)) { if (!(owner.GetExtendedStyle() & LVS_EX_FULLROWSELECT)) break; // No drawing of selection color without full-row-select if (m_InvertCellSelection && owner.GetFocusRow()==nRow && owner.GetFocusCell()==nCol) { // No drawing of selection color for focus cell if (pLVCD->clrTextBk > RGB(255,255,255)) break; backColor = pLVCD->clrTextBk; } else { if (owner.GetFocus()!=&owner && !owner.IsCellEditorOpen()) { // Selection color is different when not having focus if (owner.GetStyle() & LVS_SHOWSELALWAYS) backColor = ::GetSysColor(COLOR_BTNFACE); else break; // no drawing of selection color when not in focus } else { backColor = ::GetSysColor(COLOR_HIGHLIGHT); } } } else { // Redraw with the given background color if (pLVCD->clrTextBk > RGB(255,255,255)) break; // If a color is more than white, then it is invalid backColor = pLVCD->clrTextBk; } CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc); CRect rcIcon, rcCell; VERIFY( owner.GetCellRect(nRow, nCol, LVIR_ICON, rcIcon) ); VERIFY( owner.GetCellRect(nRow, nCol, LVIR_BOUNDS, rcCell) ); // When the label column is placed first it has a left-margin if (nCol==0 && nCol==owner.GetFirstVisibleColumn()) { int cxborder = ::GetSystemMetrics(SM_CXBORDER); rcCell.left += cxborder*2; } // Remove white margin between cell-image and cell-text rcCell.right = rcIcon.right + 2; CBrush brush(backColor); pDC->FillRect(&rcCell, &brush); // Draw icon COLORREF oldBkColor = pImageList->SetBkColor(backColor); pImageList->Draw ( pDC, nImage, rcIcon.TopLeft(), ILD_NORMAL ); pImageList->SetBkColor(oldBkColor); if (nCol==0 && owner.GetExtendedStyle() & LVS_EX_CHECKBOXES) { CImageList* pStateImageList = owner.GetImageList(LVSIL_STATE); if (pImageList==NULL) break; int checkState = owner.GetCheck(nRow); COLORREF oldStateBkColor = pStateImageList->SetBkColor(backColor); pStateImageList->Draw ( pDC, checkState, rcCell.TopLeft(), ILD_NORMAL ); pStateImageList->SetBkColor(oldStateBkColor); } } break; } // Perform standard drawing CGridRowTraitText::OnCustomDraw(owner, pLVCD, pResult); }
//------------------------------------------------------------------------ //! Appends the checkbox state images to the list control image list //! //! @param owner The list control adding column //! @param imagelist The image list assigned to the list control //! @return Image index where the two state images (unchecked/checked) was inserted //------------------------------------------------------------------------ int CGridColumnTraitImage::AppendStateImages(CGridListCtrlEx& owner, CImageList& imagelist) { if (!(owner.GetExtendedStyle() & LVS_EX_SUBITEMIMAGES)) owner.SetExtendedStyle(owner.GetExtendedStyle() | LVS_EX_SUBITEMIMAGES); if (!imagelist) imagelist.Create(16, 16, ILC_COLOR16 | ILC_MASK, 1, 0); if (!owner.GetImageList(LVSIL_SMALL)) owner.SetImageList(&imagelist, LVSIL_SMALL); VERIFY(owner.GetImageList(LVSIL_SMALL) == &imagelist); bool createdStateImages = false; CImageList* pStateList = owner.GetImageList(LVSIL_STATE); if (pStateList == NULL) { if (!(owner.GetExtendedStyle() & LVS_EX_CHECKBOXES)) { createdStateImages = true; owner.SetExtendedStyle(owner.GetExtendedStyle() | LVS_EX_CHECKBOXES); pStateList = owner.GetImageList(LVSIL_STATE); } } int imageCount = -1; ASSERT(pStateList != NULL); if (pStateList != NULL && pStateList->GetImageCount() >= 2) { imageCount = imagelist.GetImageCount(); // Get the icon size of current imagelist CSize iconSize(16, 16); if (imageCount > 0) { IMAGEINFO iconSizeInfo = { 0 }; VERIFY(imagelist.GetImageInfo(0, &iconSizeInfo)); iconSize = CSize(iconSizeInfo.rcImage.right - iconSizeInfo.rcImage.left, iconSizeInfo.rcImage.bottom - iconSizeInfo.rcImage.top); } // Scale the icon-position if necessary CPoint iconPos(1, 0); // +1 pixel to avoid overlap with left-grid-line { IMAGEINFO stateSizeInfo = { 0 }; VERIFY(pStateList->GetImageInfo(0, &stateSizeInfo)); int stateIconHeight = stateSizeInfo.rcImage.bottom - stateSizeInfo.rcImage.top; if (iconSize.cy > stateIconHeight) iconPos.y = (iconSize.cy - stateIconHeight) / 2; } // Redraw the state-icon to match the icon size of the current imagelist (without scaling image) CClientDC clienDC(&owner); CDC memDC; VERIFY(memDC.CreateCompatibleDC(&clienDC)); CBitmap dstBmp; VERIFY(dstBmp.CreateCompatibleBitmap(&clienDC, iconSize.cx, iconSize.cy)); CBitmap* pBmpOld = memDC.SelectObject(&dstBmp); COLORREF oldBkColor = pStateList->SetBkColor(imagelist.GetBkColor()); CBrush brush(imagelist.GetBkColor()); memDC.FillRect(CRect(0, 0, iconSize.cx, iconSize.cy), &brush); VERIFY(pStateList->Draw(&memDC, 0, iconPos, ILD_NORMAL)); memDC.SelectObject(pBmpOld); VERIFY(imagelist.Add(&dstBmp, oldBkColor) != -1); pBmpOld = memDC.SelectObject(&dstBmp); memDC.FillRect(CRect(0, 0, iconSize.cx, iconSize.cy), &brush); VERIFY(pStateList->Draw(&memDC, 1, iconPos, ILD_NORMAL)); memDC.SelectObject(pBmpOld); VERIFY(imagelist.Add(&dstBmp, oldBkColor) != -1); pStateList->SetBkColor(oldBkColor); } if (createdStateImages) owner.SetExtendedStyle(owner.GetExtendedStyle() & ~LVS_EX_CHECKBOXES); return imageCount; }
void SmartListCtrl::setStyle( ViewStyle style ) { style_ = style; static CImageList dummyImgList; static const int IMGLIST_FORMAT = ILC_COLOR24|ILC_MASK; thumbnailManager_->resetPendingRequests( this ); if ( !dummyImgList.GetSafeHandle() ) { dummyImgList.Create( 1, 1, IMGLIST_FORMAT, 0, 0 ); dummyImgList.SetBkColor( GetBkColor() ); } // delete previous image list SetImageList( &dummyImgList, LVSIL_NORMAL ); SetImageList( &dummyImgList, LVSIL_SMALL ); SetImageList( &dummyImgList, LVSIL_STATE ); CImageList* imgListPtr = 0; // set thumbnail size according to list style DWORD wstyle = GetWindowLong( GetSafeHwnd(), GWL_STYLE ); // hack: have to force change the list view style so tooltip cache resets. SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_REPORT ); wstyle = GetWindowLong( GetSafeHwnd(), GWL_STYLE ); if ( style_ == BIGICONS ) { SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_ICON ); listViewIcons_ = true; thumbWidthCur_ = thumbWidth_; thumbHeightCur_ = thumbHeight_; listCache_ = &listCacheBig_; listCache_->setMaxItems( maxItems_ ); imgListPtr = &imgListBig_; } else if ( style_ == SMALLICONS ) { SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_LIST ); listViewIcons_ = true; thumbWidthCur_ = thumbWidthSmall_; thumbHeightCur_ = thumbHeightSmall_; // Since small icons take less space, up the max cache items (by 16 if // big thumbs are 64x64 and small thumbs are 16x16, for example) to // take advantage of the same memory space. int memoryMultiplier = ( thumbWidth_ * thumbHeight_ ) / ( thumbWidthSmall_ * thumbHeightSmall_ ); listCache_ = &listCacheSmall_; listCache_->setMaxItems( maxItems_ * memoryMultiplier ); imgListPtr = &imgListSmall_; } else { SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_LIST ); listViewIcons_ = false; thumbWidthCur_ = 0; thumbHeightCur_ = 0; imgListPtr = &dummyImgList; } // create image list if the style requires it if ( style_ != LIST ) { if ( !imgListPtr->GetSafeHandle() ) { imgListPtr->Create( thumbWidthCur_, thumbHeightCur_, IMGLIST_FORMAT, 0, 32 ); imgListPtr->SetBkColor( GetBkColor() ); imgListPtr->Add( AfxGetApp()->LoadIcon( IDI_UALFILE ) ); // clear cache listCache_->init( imgListPtr, 1 ); } } // set the image list if ( style_ == BIGICONS ) SetImageList( imgListPtr, LVSIL_NORMAL ); else if ( style_ == SMALLICONS ) SetImageList( imgListPtr, LVSIL_SMALL ); // clear and start SetItemCount( 0 ); if ( provider_ ) SetTimer( SMARTLIST_LOADTIMER_ID, SMARTLIST_LOADTIMER_MSEC, 0 ); }