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 CBCGPropertySheet::InternalAddPage (int nTab) { CTabCtrl* pTab = GetTabControl (); ASSERT_VALID (pTab); TCHAR szTab [256]; TCITEM item; item.mask = TCIF_TEXT; item.cchTextMax = 255; item.pszText = szTab; pTab->GetItem (nTab, &item); if (m_wndOutlookBar.GetSafeHwnd () != NULL) { HICON hIcon = m_Icons.ExtractIcon (nTab); m_wndOutlookBar.AddButton (hIcon, szTab, 0, (UINT) -1, (UINT) -1, m_bAlphaBlendIcons); ::DestroyIcon (hIcon); } if (m_wndTree.GetSafeHwnd () != NULL) { CBCGPropertyPage* pPage = DYNAMIC_DOWNCAST (CBCGPropertyPage, GetPage (nTab)); if (pPage == NULL) { ASSERT (FALSE); return; } HTREEITEM hParent = NULL; if (pPage->m_pCategory != NULL) { ASSERT_VALID (pPage->m_pCategory); hParent = pPage->m_pCategory->m_hTreeItem; } HTREEITEM hTreeItem = m_wndTree.InsertItem (szTab, I_IMAGECALLBACK, I_IMAGECALLBACK, hParent); m_wndTree.SetItemData (hTreeItem, (DWORD_PTR) pPage); pPage->m_hTreeNode = hTreeItem; } if (m_wndTab.GetSafeHwnd () != NULL) { CBCGPropertyPage* pPage = DYNAMIC_DOWNCAST (CBCGPropertyPage, GetPage (nTab)); if (pPage == NULL) { ASSERT (FALSE); return; } UINT uiImage = m_Icons.GetSafeHandle () == NULL ? (UINT)-1 : nTab; m_wndTab.AddTab (pPage, szTab, uiImage); } }
void CuDlgPageFixedWidth::OnCheckConfirmChoice() { // // You have already checked one.\nThe previous check will be cancelled. CString strMsg; strMsg.LoadString(IDS_CONFIRM_CHOICE_WITH_CHECKBOX); CWnd* pParent = GetParent(); ASSERT(pParent && pParent->IsKindOf(RUNTIME_CLASS(CTabCtrl))); if (pParent && pParent->IsKindOf(RUNTIME_CLASS(CTabCtrl))) { BOOL nAsked = FALSE; TCITEM item; memset (&item, 0, sizeof (item)); item.mask = TCIF_PARAM; CTabCtrl* pTab = (CTabCtrl*)pParent; int nCheck, i, nCount = pTab->GetItemCount(); for (i=0; i<nCount; i++) { if (pTab->GetItem (i, &item)) { CWnd* pPage = (CWnd*)item.lParam; ASSERT (pPage); if (!pPage) continue; if (pPage == this) continue; nCheck = pPage->SendMessage(WMUSRMSG_GETITEMDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); if (nCheck == 1) { if (!nAsked) { nAsked = TRUE; int nAnswer = AfxMessageBox (strMsg, MB_OKCANCEL|MB_ICONEXCLAMATION); if (nAnswer != IDOK) { m_cCheckConfirmChoice.SetCheck (0); return; } // // Uncheck the checkbox m_cCheckConfirmChoice: pPage->SendMessage(WMUSRMSG_UPDATEDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); } else { // // Uncheck the checkbox m_cCheckConfirmChoice: pPage->SendMessage(WMUSRMSG_UPDATEDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); } } } } } }
void CMyPropertySheet::InitList(void) { LVITEM lvi; ::ZeroMemory(&lvi, sizeof(lvi)); CHeaderCtrl *pHeader = m_wndList.GetHeaderCtrl(); pHeader->ShowWindow(SW_HIDE); CRect rectList; m_wndList.GetWindowRect(&rectList); ScreenToClient(&rectList); //报表头不会显示,但是是必需的 m_wndList.InsertColumn(0,_T("设置"), LVCFMT_CENTER, rectList.Width(), 0); CString strCaption; CTabCtrl *pTab = GetTabControl(); TCITEM tci; ::ZeroMemory(&tci,sizeof(tci)); tci.mask = TCIF_TEXT; tci.cchTextMax = 256; TCHAR szBuf[256] = {0}; tci.pszText = szBuf; for (int idxPge = 0; idxPge < GetPageCount(); idxPge ++) { if(pTab->GetItem(idxPge, &tci)) { lvi.iItem = idxPge; lvi.iSubItem = 0; lvi.iImage = idxPge; lvi.mask = LVIF_TEXT | LVIF_IMAGE; lvi.pszText = tci.pszText ; m_wndList.InsertItem(&lvi); } } }
void TreePropertySheet::fillTree() { CTabCtrl tab = GetTabControl(); int pages = tab.GetItemCount(); TCHAR buf[MAX_NAME_LENGTH]; TCITEM item; item.mask = TCIF_TEXT; item.pszText = buf; item.cchTextMax = MAX_NAME_LENGTH - 1; HTREEITEM initialItem = NULL; for(int i = 0; i < pages; ++i) { tab.GetItem(i, &item); if(i == (int)m_psh.nStartPage) initialItem = createTree(buf, TVI_ROOT, i); else createTree(buf, TVI_ROOT, i); } ctrlTree.SelectItem(initialItem); }
void CuDlgPageCsv::OnCheckConfirmChoice() { CaDataPage1& dataPage1 = m_pData->m_dataPage1; if (m_cCheckConfirmChoice.GetCheck() == 1) { CStringArray arrayHeader; BOOL bFirstLineAsHeader = GenerateHeader(dataPage1, m_pSeparatorSet, m_pSeparator, m_nCoumnCount, arrayHeader); if (dataPage1.GetFirstLineAsHeader() && dataPage1.GetLineCountToSkip() == 1) { if (!bFirstLineAsHeader) AfxMessageBox (IDS_MSG_ERROR_HEADERLINE); } } // // You have already checked one.\nThe previous check will be cancelled. CString strMsg; strMsg.LoadString(IDS_CONFIRM_CHOICE_WITH_CHECKBOX); CWnd* pParent = GetParent(); ASSERT(pParent && pParent->IsKindOf(RUNTIME_CLASS(CTabCtrl))); if (pParent && pParent->IsKindOf(RUNTIME_CLASS(CTabCtrl))) { BOOL nAsked = FALSE; TCITEM item; memset (&item, 0, sizeof (item)); item.mask = TCIF_PARAM; CTabCtrl* pTab = (CTabCtrl*)pParent; int nCheck, i, nCount = pTab->GetItemCount(); for (i=0; i<nCount; i++) { if (pTab->GetItem (i, &item)) { CWnd* pPage = (CWnd*)item.lParam; ASSERT (pPage); if (!pPage) continue; if (pPage == this) continue; nCheck = pPage->SendMessage(WMUSRMSG_GETITEMDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); if (nCheck == 1) { if (!nAsked) { nAsked = TRUE; int nAnswer = AfxMessageBox (strMsg, MB_OKCANCEL|MB_ICONEXCLAMATION); if (nAnswer != IDOK) { m_cCheckConfirmChoice.SetCheck (0); return; } // // Uncheck the checkbox m_cCheckConfirmChoice: pPage->SendMessage(WMUSRMSG_UPDATEDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); } else { // // Uncheck the checkbox m_cCheckConfirmChoice: pPage->SendMessage(WMUSRMSG_UPDATEDATA, (WPARAM)CHECK_CONFIRM_CHOICE, 0); } } } } } }
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 CXTPSkinObjectTab::DrawTabText(CDC* pDC, CRect& rcItem, int iItem, int iCount, BOOL bSelected) { CTabCtrl* pTabCtrl = (CTabCtrl*)this; CString strCaption; LPTSTR pszText = strCaption.GetBuffer(256); pszText[0] = 0; TC_ITEM tci; tci.mask = TCIF_TEXT; tci.pszText = pszText; tci.cchTextMax = 255; BOOL bResult = pTabCtrl->GetItem(iItem, &tci); strCaption.ReleaseBuffer(); #ifdef _UNICODE if (!bResult) { char tText[256]; tText[0] = 0; TC_ITEMA tcia; ::ZeroMemory(&tcia, sizeof(TC_ITEMA)); tcia.mask = TCIF_TEXT; // Get the header item text and format tcia.pszText = tText; tcia.cchTextMax = 255; ::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia); strCaption = tText; } #else if (!bResult) return; #endif if (strCaption.GetLength() == 0) return; pDC->SetTextColor(GetColor(COLOR_BTNTEXT)); // Set the font for the tab label. DWORD dwStyle = GetStyle(); CXTPSkinManagerClass* pClass = GetSkinClass(); int nStateId = bSelected ? TIS_SELECTED: m_nHotItem == iItem ? TIS_HOT : TIS_NORMAL; int nPartId = iItem == 0 ? TABP_TOPTABITEMLEFTEDGE : iItem == iCount - 1 && !bSelected ? TABP_TOPTABITEMRIGHTEDGE : TABP_TOPTABITEM; // Draw the tab label. if (IsHorz(dwStyle)) { UINT dsFlags = DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS; if (SendMessage(WM_QUERYUISTATE) & UISF_HIDEACCEL) { dsFlags |= DT_HIDEPREFIX; } if (!(GetStyle() & TCS_BUTTONS)) { rcItem.top += bSelected ? -2 : 1; rcItem.right -= iItem == 0 ? 3 : 0; } else { rcItem.top += bSelected ? 0 : -1; } pClass->DrawThemeText(pDC, nPartId, nStateId, strCaption, dsFlags, &rcItem); } else { CSize sz = pDC->GetTextExtent(strCaption); rcItem.left = rcItem.right-(rcItem.Width()-sz.cy + 1)/ 2; rcItem.top = rcItem.top+(rcItem.Height()-sz.cx + 1)/ 2; pClass->DrawThemeText(pDC, nPartId, nStateId, strCaption, DT_SINGLELINE | DT_NOCLIP, &rcItem); } }
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) ); } } } }