void CTreePropSheet::UpdateCaption() { HWND hPage = PropSheet_GetCurrentPageHwnd(GetSafeHwnd()); BOOL bRealPage = IsWindow(hPage) && ::IsWindowVisible(hPage); HTREEITEM hItem = m_pwndPageTree->GetSelectedItem(); if (!hItem) return; CString strCaption = m_pwndPageTree->GetItemText(hItem); // if empty page, then update empty page message if (!bRealPage) m_pFrame->SetMsgText(GenerateEmptyPageMessage(m_strEmptyPageMessage, strCaption)); // if no captions are displayed, cancel here if (!m_pFrame->GetShowCaption()) return; // get tab control, to the the images from CTabCtrl *pTabCtrl = GetTabControl(); if (!IsWindow(pTabCtrl->GetSafeHwnd())) { ASSERT(FALSE); return; } if (m_bTreeImages) { // get image from tree int nImage; m_pwndPageTree->GetItemImage(hItem, nImage, nImage); HICON hIcon = m_Images.ExtractIcon(nImage); m_pFrame->SetCaption(strCaption, hIcon); if (hIcon) DestroyIcon(hIcon); } else if (bRealPage) { // get image from hidden (original) tab provided by the original // implementation CImageList *pImages = pTabCtrl->GetImageList(); if (pImages) { TCITEM ti; ZeroMemory(&ti, sizeof(ti)); ti.mask = TCIF_IMAGE; HICON hIcon = NULL; if (pTabCtrl->GetItem((int)m_pwndPageTree->GetItemData(hItem), &ti)) hIcon = pImages->ExtractIcon(ti.iImage); m_pFrame->SetCaption(strCaption, hIcon); if (hIcon) DestroyIcon(hIcon); } else m_pFrame->SetCaption(strCaption); } else m_pFrame->SetCaption(strCaption); }
void CXTPSkinObjectTab::DrawTabIcon(CDC* pDC, CRect& rcItem, int iItem) { CTabCtrl* pTabCtrl = (CTabCtrl*)this; TC_ITEM tci; tci.mask = TCIF_IMAGE; BOOL bResult = pTabCtrl->GetItem(iItem, &tci); #ifdef _UNICODE if (!bResult) { TC_ITEMA tcia; ::ZeroMemory(&tcia, sizeof(TC_ITEMA)); tcia.mask = TCIF_IMAGE; bResult = (BOOL)::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia); tci.iImage = tcia.iImage; } #endif if (!bResult) return; CImageList* pImageList = pTabCtrl->GetImageList(); if (!pImageList || tci.iImage < 0) return; CPoint point = rcItem.TopLeft(); DWORD dwStyle = GetStyle(); if (IsHorz(dwStyle)) { point.Offset(GetMetrics()->m_cxEdge * 2, IsTop(dwStyle) ? GetMetrics()->m_cyEdge : 1); } else { point.Offset(IsLeft(dwStyle) ? GetMetrics()->m_cxEdge : 1, GetMetrics()->m_cyEdge * 2); } // Draw any associated icons. pImageList->Draw(pDC, tci.iImage, point, ILD_TRANSPARENT); IMAGEINFO info; ::ZeroMemory(&info, sizeof(info)); pImageList->GetImageInfo(tci.iImage, &info); CRect rcImage(info.rcImage); if (IsHorz(dwStyle)) { rcItem.left += rcImage.Width() + GetMetrics()->m_cxEdge; } else { rcItem.top += rcImage.Height() + GetMetrics()->m_cyEdge; } }
void CTreePropSheet::RefillPageTree() { if (!IsWindow(m_hWnd)) return; m_pwndPageTree->DeleteAllItems(); CTabCtrl *pTabCtrl = GetTabControl(); if (!IsWindow(pTabCtrl->GetSafeHwnd())) { ASSERT(FALSE); return; } const int nPageCount = pTabCtrl->GetItemCount(); // rebuild image list if (m_bTreeImages) { for (int i = m_Images.GetImageCount()-1; i >= 0; --i) m_Images.Remove(i); // add page images CImageList *pPageImages = pTabCtrl->GetImageList(); if (pPageImages) { for (int nImage = 0; nImage < pPageImages->GetImageCount(); ++nImage) { HICON hIcon = pPageImages->ExtractIcon(nImage); m_Images.Add(hIcon); DestroyIcon(hIcon); } } // add default images if (m_DefaultImages.GetSafeHandle()) { HICON hIcon; // add default images hIcon = m_DefaultImages.ExtractIcon(0); if (hIcon) { m_Images.Add(hIcon); DestroyIcon(hIcon); } hIcon = m_DefaultImages.ExtractIcon(1); { m_Images.Add(hIcon); DestroyIcon(hIcon); } } } // insert tree items for (int nPage = 0; nPage < nPageCount; ++nPage) { // Get title and image of the page CString strPagePath; TCITEM ti; ZeroMemory(&ti, sizeof(ti)); ti.mask = TCIF_TEXT|TCIF_IMAGE; ti.cchTextMax = MAX_PATH; ti.pszText = strPagePath.GetBuffer(ti.cchTextMax); ASSERT(ti.pszText); if (!ti.pszText) return; pTabCtrl->GetItem(nPage, &ti); strPagePath.ReleaseBuffer(); // Create an item in the tree for the page HTREEITEM hItem = CreatePageTreeItem(ti.pszText); ASSERT(hItem); if (hItem) { m_pwndPageTree->SetItemData(hItem, nPage); // set image if (m_bTreeImages) { int nImage = ti.iImage; if (nImage < 0 || nImage >= m_Images.GetImageCount()) nImage = m_DefaultImages.GetSafeHandle()? m_Images.GetImageCount()-1 : -1; m_pwndPageTree->SetItemImage(hItem, nImage, nImage); } } } }
void CTreePropSheetBase::RefillPageTree() { if (!IsWindow(m_hWnd)) return; // TreePropSheetEx: OnPageTreeSelChanging does not process message. TreePropSheet::CIncrementScope RefillingPageTreeContentGuard( m_nRefillingPageTreeContent ); // TreePropSheetEx: End OnPageTreeSelChanging does not process message. m_pwndPageTree->DeleteAllItems(); CTabCtrl *pTabCtrl = GetTabControl(); if (!IsWindow(pTabCtrl->GetSafeHwnd())) { ASSERT(FALSE); return; } const int nPageCount = pTabCtrl->GetItemCount(); // rebuild image list if (m_bTreeImages) { for (int i = m_Images.GetImageCount()-1; i >= 0; --i) m_Images.Remove(i); // add page images CImageList *pPageImages = pTabCtrl->GetImageList(); if (pPageImages) { for (int nImage = 0; nImage < pPageImages->GetImageCount(); ++nImage) { HICON hIcon = pPageImages->ExtractIcon(nImage); m_Images.Add(hIcon); DestroyIcon(hIcon); } } // add default images if (m_DefaultImages.GetSafeHandle()) { HICON hIcon; // add default images hIcon = m_DefaultImages.ExtractIcon(0); if (hIcon) { m_Images.Add(hIcon); DestroyIcon(hIcon); } hIcon = m_DefaultImages.ExtractIcon(1); { m_Images.Add(hIcon); DestroyIcon(hIcon); } } } // insert tree items for (int nPage = 0; nPage < nPageCount; ++nPage) { // Get title and image of the page CString strPagePath; TCITEM ti; ZeroMemory(&ti, sizeof(ti)); ti.mask = TCIF_TEXT|TCIF_IMAGE; ti.cchTextMax = MAX_PATH; ti.pszText = strPagePath.GetBuffer(ti.cchTextMax); ASSERT(ti.pszText); if (!ti.pszText) return; pTabCtrl->GetItem(nPage, &ti); strPagePath.ReleaseBuffer(); // Create an item in the tree for the page HTREEITEM hItem = CreatePageTreeItem(ti.pszText); ASSERT(hItem); if (hItem) { m_pwndPageTree->SetItemData(hItem, nPage); // set image if (m_bTreeImages) { int nImage = ti.iImage; if (nImage < 0 || nImage >= m_Images.GetImageCount()) nImage = m_DefaultImages.GetSafeHandle()? m_Images.GetImageCount()-1 : -1; m_pwndPageTree->SetItemImage(hItem, nImage, nImage); } // Set font if disabled. CPropertyPage* pPage = GetPage( nPage ); ASSERT( pPage ); if( NULL != pPage && !IsPageEnabled( pPage ) ) { ::SendMessage( m_pwndPageTree->GetSafeHwnd(), WMU_ENABLETREEITEM, (WPARAM)hItem, (LPARAM)GetSysColor(COLOR_GRAYTEXT) ); } } } }