void CMainFrame::InitializeDefaultPanes(void) { CRect rcClient; this->GetClientRect(&rcClient); CRect rcFloat(0,0,400,200); CRect rcDock(0,0,220,/*rcClient.Width()-200*/200); CRect rcFileTreeDock(0,0,220,10); CRect rcItemListDock(0,0,150,300); CRect rcvgmfileDock(0,0,220,/*rcClient.Width()-200*/300); CRect rcCollListDock(150,150,220,/*rcClient.Width()-200*/100); CRect rcLogListDock(0,0,400,80); //CRect rcDock(); CImageList ilIcons; ilIcons.Create(16, 16, ILC_MASK | ILC_COLOR24, 0, 0); CBitmap bmpIcons; bmpIcons.LoadBitmap(IDB_TAB_ICONS); ilIcons.Add((HBITMAP)bmpIcons, RGB(0,255,0)); HWND hWndFirst = //CreateVGMFilesTreeViewPane(VGMFilesView, _T("Detected VGM Files"), ilIcons.ExtractIcon(10), rcFloat, rcvgmfileDock, NULL); CreateVGMFileListViewPane(theVGMFileListView, _T("Detected Music Files"), ilIcons.ExtractIcon(10), rcFloat, rcvgmfileDock, NULL); CreateFileListViewPane(rawFileListView, _T("Scanned Files"), ilIcons.ExtractIcon(6), rcFloat, rcFileTreeDock, NULL); CreateVGMCollListViewPane(theVGMCollListView, _T("Collections"), ilIcons.ExtractIcon(10), rcFloat, rcCollListDock, NULL); //this->CreatePlainTextOutputPane(m_OutputView, _T("Output"), ilIcons.ExtractIcon(3), rcFloat, rcDock, hWndFirst); //this->CreatePlainTextOutputPane(m_FindResultsView, _T("Find Results 1"), ilIcons.ExtractIcon(11), rcFloat, rcDock, hWndFirst); CreateCollDialogPane(theCollDialog, _T("Coll Info"), rcFloat, rcDock, NULL); CreateLogListViewPane(theLogListView, _T("Logs"), ilIcons.ExtractIcon(10), rcFloat, rcLogListDock, NULL); }
BOOL CMainFrame::CreateShortcutsBar () { CMFCOutlookBarTabCtrl::EnableAnimation (); const int nInitialWidth = 150; const CString strCaption = _T("Shortcuts"); // <snippet2> // int nInitialWidth // CString strCaption if (!m_wndShortcutsBar.Create (strCaption, this, CRect (0, 0, nInitialWidth, nInitialWidth), ID_VIEW_OUTLOOKBAR, WS_CHILD | WS_VISIBLE | CBRS_LEFT)) { TRACE0("Failed to create outlook bar\n"); return FALSE; // fail to create } // </snippet2> CMFCOutlookBarTabCtrl* pShortcutsBarContainer = DYNAMIC_DOWNCAST (CMFCOutlookBarTabCtrl, m_wndShortcutsBar.GetUnderlyingWindow ()); if (pShortcutsBarContainer == NULL) { TRACE0("Cannot get outlook bar container\n"); return FALSE; } // <snippet4> CImageList images; images.Create (IDB_SHORTCUTS, 32, 0, RGB (255, 0, 255)); // Create first page: m_wndShortcutsPane1.Create (&m_wndShortcutsBar, AFX_DEFAULT_TOOLBAR_STYLE, ID_SHORTCUTS_PANE_1); // The this pointer points to a CMainFrame class which extends the CFrameWnd class m_wndShortcutsPane1.SetOwner (this); m_wndShortcutsPane1.EnableTextLabels (); m_wndShortcutsPane1.EnableDocking (CBRS_ALIGN_ANY); m_wndShortcutsPane1.EnablePageScrollMode(); m_wndShortcutsPane1.SetBackColor(RGB(0,255,0)); m_wndShortcutsPane1.AddButton (images.ExtractIcon (0), _T("View 1"), ID_SHORTCUT_1); m_wndShortcutsPane1.AddButton (images.ExtractIcon (1), _T("View 2"), ID_SHORTCUT_2); m_wndShortcutsPane1.AddButton (images.ExtractIcon (2), _T("View 3"), ID_SHORTCUT_3); m_wndShortcutsPane1.AddButton (images.ExtractIcon (3), _T("View 4"), ID_SHORTCUT_4); // </snippet4> pShortcutsBarContainer->AddTab (&m_wndShortcutsPane1, _T("Views"), (UINT)-1, FALSE); return TRUE; }
CPlayerToolBar::CPlayerToolBar() : fDisableImgListRemap(false) , m_pButtonsImages(NULL) , m_hDXVAIcon(NULL) { HBITMAP hBmp = CMPCPngImage::LoadExternalImage(L"gpu", IDB_DXVA_ON, IMG_TYPE::UNDEF); BITMAP bm = { 0 }; ::GetObject(hBmp, sizeof(bm), &bm); if (CMPCPngImage::FileExists(CString(L"gpu")) && (bm.bmHeight > 32 || bm.bmWidth > 32)) { hBmp = CMPCPngImage::LoadExternalImage(L"", IDB_DXVA_ON, IMG_TYPE::UNDEF); ::GetObject(hBmp, sizeof(bm), &bm); } if (bm.bmWidth <= 32 && bm.bmHeight <= 32) { CBitmap *bmp = DNew CBitmap(); bmp->Attach(hBmp); CImageList *pButtonDXVA = DNew CImageList(); pButtonDXVA->Create(bm.bmWidth, bm.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0); pButtonDXVA->Add(bmp, static_cast<CBitmap*>(NULL)); m_hDXVAIcon = pButtonDXVA->ExtractIcon(0); delete pButtonDXVA; delete bmp; } iDXVAIconHeight = bm.bmHeight; iDXVAIconWidth = bm.bmWidth; DeleteObject(hBmp); }
BOOL CuDlgIpmPageLockLists::OnInitDialog() { CDialog::OnInitDialog(); VERIFY (m_cListCtrl.SubclassDlgItem (IDC_LIST1, this)); // // Initalize the Column Header of CListCtrl (CuListCtrl) LSCTRLHEADERPARAMS2 lsp[LAYOUT_NUMBER] = { {IDS_TC_LOCKLIST_ID, 91, LVCFMT_LEFT, FALSE}, {IDS_TC_SESSION, 60, LVCFMT_LEFT, FALSE}, {IDS_TC_LOCKS, 45, LVCFMT_LEFT, FALSE}, {IDS_TC_LOGICAL, 50, LVCFMT_LEFT, FALSE}, {IDS_TC_MAXL, 40, LVCFMT_LEFT, FALSE}, {IDS_TC_STATUS, 200, LVCFMT_LEFT, FALSE} }; InitializeHeader2(&m_cListCtrl, LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH, lsp, LAYOUT_NUMBER); m_ImageList.Create(IDB_TM_LOCKLIST, 16, 1, RGB(255, 0, 255)); CImageList im; if (im.Create(IDB_TM_LOCKLIST_BLOCKED_YES, 16, 1, RGB(255, 0, 255))) { HICON hIconBlock = im.ExtractIcon(0); if (hIconBlock) { m_ImageList.Add (hIconBlock); DestroyIcon (hIconBlock); } } m_cListCtrl.SetImageList(&m_ImageList, LVSIL_SMALL); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CuDlgIpmTabCtrl::OnInitDialog() { CDialog::OnInitDialog(); VERIFY (m_staticHeader.SubclassDlgItem (IDC_STATIC, this)); m_staticHeader.SetImage (-1); // No Image for Now CWnd* pParent1 = GetParent(); // The view: CImView2 ASSERT (pParent1); CdIpmDoc* pDoc = (CdIpmDoc*)((CView*)pParent1)->GetDocument(); ASSERT (pDoc); if (!pDoc->GetCurrentProperty()) return TRUE; // // When the document is Loaded ... try { CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame(); CvIpmLeft* pIpmView1= (CvIpmLeft*)pFrame->GetLeftPane(); CTreeCtrl& treeCtrl = pIpmView1->GetTreeCtrl(); HTREEITEM hSelected= treeCtrl.GetSelectedItem (); ASSERT (hSelected); if (!hSelected) return TRUE; CTreeItem* pItem = (CTreeItem*)treeCtrl.GetItemData (hSelected); CuPageInformation* pPageInfo = pDoc->GetCurrentProperty()->GetPageInfo(); LPIPMUPDATEPARAMS pUps = pPageInfo->GetUpdateParam(); pUps->nType = pItem->GetType(); pUps->pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL; pUps->pSFilter= pDoc->GetFilter(); int nImage = -1, nSelectedImage = -1; CImageList* pImageList = treeCtrl.GetImageList (TVSIL_NORMAL); HICON hIcon = NULL; int nImageCount = pImageList? pImageList->GetImageCount(): 0; if (pImageList && treeCtrl.GetItemImage(hSelected, nImage, nSelectedImage)) { if (nImage < nImageCount) hIcon = pImageList->ExtractIcon(nImage); } pPageInfo->SetImage (hIcon); LoadPage (pDoc->GetCurrentProperty()); m_bIsLoading = TRUE; if (m_pCurrentPage) { UINT nMask = IPMMASK_FONT|IPMMASK_SHOWGRID; m_pCurrentPage->SendMessage (WMUSRMSG_CHANGE_SETTING, (UINT)nMask, (LPARAM)&(pDoc->GetProperty())); } } catch (CMemoryException* e) { theApp.OutOfMemoryMessage (); m_pCurrentPage = NULL; m_pCurrentProperty = NULL; e->Delete(); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
HICON CXTPIconHandle::ScaleToFit(HICON hIcon, CSize desiredExtent) { if (desiredExtent == CSize(0)) { // invalid arg return NULL; } CSize realExtent = GetExtent(hIcon); if (realExtent == CSize(0)) { // icon destroyed or not created yet return NULL; } // ensure icon retains aspect after scaling int delta = desiredExtent.cx * realExtent.cy - desiredExtent.cy * realExtent.cx; if (delta < 0) { desiredExtent.cy = MulDiv(realExtent.cy, desiredExtent.cx, realExtent.cx); } else if (delta > 0) { desiredExtent.cx = MulDiv(realExtent.cx, desiredExtent.cy, realExtent.cy); } // scale the icon CImageList images; VERIFY(images.Create(desiredExtent.cx, desiredExtent.cy, ILC_COLOR32 | ILC_MASK, 1, 1)); images.Add(hIcon); return images.ExtractIcon(0); }
BOOL CEditButton::Create(CWnd* pWnd, SEARCH_TYPE eType, UINT nMenu) { ASSERT(eType != -1); ASSERT_VALID(pWnd); m_eType = eType; m_nMenu = nMenu; m_pWnd = pWnd; CWnd* pWndParent = m_pWnd->GetParent(); ASSERT_VALID(pWndParent); CRect rc; m_pWnd->GetWindowRect(&rc); m_pWnd->SetWindowPos(NULL, 0, 0, rc.Width()-23, rc.Height(), SWP_NOZORDER|SWP_NOMOVE); pWndParent->ScreenToClient(&rc); rc.left = rc.right-18; DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_CENTER|BS_VCENTER; switch (m_eType) { case SEARCH_DIRECTORY: case SEARCH_FILE: { if (CButton::Create(_T("..."), dwStyle, rc, pWndParent, GetNextID(pWndParent))) { SetWindowPos(m_pWnd, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); EnableWindow(m_pWnd->IsWindowEnabled()); SetFont(&m_Font); return TRUE; } } case SEARCH_POPUP: { if (CButton::Create(_T("..."), dwStyle|BS_ICON, rc, pWndParent, GetNextID(pWndParent))) { SetWindowPos(m_pWnd, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); EnableWindow(m_pWnd->IsWindowEnabled()); SetFont(&m_Font); CImageList imageList; CBitmap bitmap; bitmap.LoadBitmap(IDB_BTN_ARROW); imageList.Create(15, 17, ILC_COLORDDB|ILC_MASK, 1, 1); imageList.Add(&bitmap, RGB(255,0,255)); SetIcon(imageList.ExtractIcon(0)); imageList.Detach(); bitmap.Detach(); return TRUE; } } } return FALSE; }
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); }
BOOL CTreePropSheet::SetPageIcon(CPropertyPage *pPage, CImageList &Images, int nImage) { HICON hIcon = Images.ExtractIcon(nImage); if (!hIcon) return FALSE; return SetPageIcon(pPage, hIcon); }
void CXTPEditListBoxToolBar::Initialize(bool bAutoFont/*= true*/) { // Create the ToolTip control. m_tooltip.Create(this); m_tooltip.Activate(TRUE); CImageList imageList; imageList.Create(14, 12, ILC_COLOR8 | ILC_MASK, 0, 1); CBitmap bmp; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadBitmap(&bmp, XTP_IDB_LISTEDIT)); imageList.Add(&bmp, RGB(255, 0, 255)); for (int i = 0; i < _countof(m_arButton); ++i) { if ((!m_bShowNewDeleteButtons) && ((i==0) || (i==1))) continue; if ((!m_bShowUpDownButtons) && ((i==2) || (i==3))) continue; if (!m_arButton[i].Create(NULL, WS_CHILD | WS_VISIBLE | BS_ICON | BS_CENTER | BS_VCENTER, CRect(0, 0, 0, 0), this, _arButtonID[i])) { TRACE0("Unable to create edit button.\n"); continue; } m_arIcon[i] = imageList.ExtractIcon(i); m_arButton[i].SetIcon(CSize(0), m_arIcon[i]); CString strToolTip; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strToolTip, _arButtonID[i])); // Add tooltips to group buttons. m_tooltip.AddTool(&m_arButton[i], strToolTip); // make sure the button is Windows XP theme compatible using // the toolbar button theme. if (m_arButton[i].SetTheme(xtpControlThemeFlat)) { CXTPButtonTheme* pTheme = m_arButton[i].GetTheme(); if (pTheme) { pTheme->EnableToolbarStyle(TRUE); } m_arButton[i].SetUseVisualStyle(TRUE); } } // Move the buttons to their correct location. MoveButtons(); // Set the font for this window. if (bAutoFont) { SetFont(&XTPAuxData().font); } }
//------------------------------------------------------------------------ //! 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) { imageCount = imagelist.GetImageCount(); HICON uncheckedIcon = pStateList->ExtractIcon(0); imagelist.Add(uncheckedIcon); DestroyIcon(uncheckedIcon); HICON checkedIcon = pStateList->ExtractIcon(1); imagelist.Add(checkedIcon); DestroyIcon(checkedIcon); } if (createdStateImages) owner.SetExtendedStyle(owner.GetExtendedStyle() & ~LVS_EX_CHECKBOXES); return imageCount; }
BOOL CuDlgMain::OnInitDialog() { CDialog::OnInitDialog(); m_hIconOpen = theApp.LoadIcon (IDI_OPEN); m_hIconSave = theApp.LoadIcon (IDI_SAVE); m_hIconNode = theApp.LoadIcon (IDI_NODE); m_cButtonSc2Save.SetIcon(m_hIconSave); m_cButtonSc2Open.SetIcon(m_hIconOpen); m_cButtonSc1Save.SetIcon(m_hIconSave); m_cButtonSc1Open.SetIcon(m_hIconOpen); VERIFY (m_cListCheckBox.SubclassDlgItem (IDC_LIST1, this)); m_ImageListNode.Create(IDB_NODES, 16, 1, RGB(255, 0, 255)); m_ImageListUser.Create(IDB_USER, 16, 1, RGB(255, 0, 255)); m_ImageListDatabase.Create(IDB_DATABASE, 16, 1, RGB(255, 0, 255)); UINT narrayImage[3] = {IDB_INGRESOBJECT3_16x16, IDB_DATABASE_DISTRIBUTED, IDB_DATABASE_COORDINATOR}; for (int i = 0; i<3; i++) { CImageList im; if (im.Create(narrayImage[i], 16, 1, RGB(255, 0, 255))) { HICON hIconBlock = im.ExtractIcon(0); if (hIconBlock) { m_ImageListDatabase.Add (hIconBlock); DestroyIcon (hIconBlock); } } } m_cComboNode1.SetImageList(&m_ImageListNode); m_cComboNode2.SetImageList(&m_ImageListNode); m_cComboDatabase1.SetImageList(&m_ImageListDatabase); m_cComboDatabase2.SetImageList(&m_ImageListDatabase); m_cComboUser1.SetImageList(&m_ImageListUser); m_cComboUser2.SetImageList(&m_ImageListUser); HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hFont == NULL) hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); m_cListCheckBox.SendMessage(WM_SETFONT, (WPARAM)hFont); m_cCheckIgnoreOwner.SetCheck(1); m_vsdaCtrl.SetSessionStart(500); m_vsdaCtrl.SetSessionDescription(_T("Ingres Visual Database Objects Differences Analyzer (vsda.ocx)")); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CuDlgIpmPageActiveDatabases::OnInitDialog() { CDialog::OnInitDialog(); VERIFY (m_cListCtrl.SubclassDlgItem (IDC_LIST1, this)); // // Initalize the Column Header of CListCtrl (CuListCtrl) LSCTRLHEADERPARAMS2 lsp[LAYOUT_NUMBER] = { {IDS_TC_DATABASE, 91, LVCFMT_LEFT, FALSE}, {IDS_TC_STATUS, 110, LVCFMT_LEFT, FALSE}, {IDS_TC_TX_CNT, 50, LVCFMT_LEFT, FALSE}, {IDS_TC_BEGIN, 55, LVCFMT_LEFT, FALSE}, {IDS_TC_END, 55, LVCFMT_LEFT, FALSE}, {IDS_TC_READ, 55, LVCFMT_LEFT, FALSE}, {IDS_TC_WRITE, 55, LVCFMT_LEFT, FALSE} }; InitializeHeader2(&m_cListCtrl, LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH, lsp, LAYOUT_NUMBER); // // Possible enhancement: personnalize according to database type m_ImageList.Create(IDB_TM_DB, 16, 1, RGB(255, 0, 255)); UINT narrayImage[3] = {IDB_TM_DB_TYPE_DISTRIBUTED, IDB_TM_DB_TYPE_COORDINATOR, IDB_TM_DB_TYPE_ERROR}; for (int i = 0; i<3; i++) { CImageList im; if (im.Create(narrayImage[i], 16, 1, RGB(255, 0, 255))) { HICON hIconBlock = im.ExtractIcon(0); if (hIconBlock) { m_ImageList.Add (hIconBlock); DestroyIcon (hIconBlock); } } } m_cListCtrl.SetImageList(&m_ImageList, LVSIL_SMALL); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CIpmCtrl::SelectItem(LPCTSTR lpszNode, LPCTSTR lpszServer, LPCTSTR lpszUser, LPCTSTR lpszKey, VARIANT FAR* pArrayItem, short nShowTree) { class CaLockDisplayRightPaneProperty { public: CaLockDisplayRightPaneProperty(CdIpmDoc* pDoc):m_pDoc(pDoc), m_bLock(FALSE){} ~CaLockDisplayRightPaneProperty(){UnLock();} void Lock(){m_pDoc->SetLockDisplayRightPane(TRUE);} void UnLock(){m_pDoc->SetLockDisplayRightPane(FALSE);} protected: BOOL m_bLock; CdIpmDoc* m_pDoc; }; CWaitCursor doWaitCursor ; BOOL bOK = FALSE; try { CdIpmDoc* pDoc = new CdIpmDoc(lpszKey, pArrayItem, (BOOL)nShowTree); if (m_pIpmFrame) { m_pIpmFrame->ShowWindow (SW_HIDE); m_pIpmFrame->DestroyWindow(); m_pIpmFrame = NULL; } CaIpmProperty& property = pDoc->GetProperty(); ConstructPropertySet (property); SFILTER* pFilter = theApp.GetFilter(); SFILTER* pDocFilter = pDoc->GetFilter(); memcpy (pDocFilter, pFilter, sizeof(SFILTER)); CaLockDisplayRightPaneProperty lock(pDoc); if (nShowTree == 1) { // // During the process of expanding tree up to search item, // prohibit the display of the properties of the selected tree item lock.Lock(); } CWnd* pParent = this; CRect r; GetClientRect (r); m_pIpmFrame = new CfIpmFrame(pDoc); m_pIpmFrame->Create ( NULL, NULL, WS_CHILD, r, pParent); if (!m_pIpmFrame) return FALSE; m_pIpmFrame->InitialUpdateFrame(NULL, TRUE); m_pIpmFrame->ShowWindow(SW_SHOW); bOK = pDoc->Initiate(lpszNode, lpszServer, lpszUser, NULL); if (!bOK) return FALSE; CTypedPtrList<CObList, CuIpmTreeFastItem*> listItemPath; bOK = IPM_BuildItemPath (pDoc, listItemPath); if (!bOK) { while (!listItemPath.IsEmpty()) delete listItemPath.RemoveHead(); return FALSE; } ExpandUpToSearchedItem(m_pIpmFrame, listItemPath, TRUE); lock.UnLock(); // // Cleanup: while (!listItemPath.IsEmpty()) delete listItemPath.RemoveHead(); // // Fetch the selected tree item and display the corresponding right pane: IPMUPDATEPARAMS ups; CTreeGlobalData* pGD = pDoc->GetPTreeGD(); ASSERT (pGD); if (!pGD) return FALSE; CTreeCtrl* pTree = pGD->GetPTree(); ASSERT (pTree); if (!pTree) return FALSE; CuDlgIpmTabCtrl* pTabDlg = (CuDlgIpmTabCtrl*)m_pIpmFrame->GetTabDialog(); if (!pTabDlg) return FALSE; HTREEITEM hSelected = pTree->GetSelectedItem(); if (!hSelected) return FALSE; // // Notify the container of sel change: ContainerNotifySelChange(); memset (&ups, 0, sizeof (ups)); CTreeItem* pItem = (CTreeItem*)pTree->GetItemData (hSelected); if (pItem->IsNoItem() || pItem->IsErrorItem()) { pTabDlg->DisplayPage (NULL); return TRUE; } if (pItem->ItemDisplaysNoPage()) { CString caption = pItem->ItemNoPageCaption(); pTabDlg->DisplayPage (NULL, caption); return TRUE; } if (pItem->HasReplicMonitor()) { pDoc->InitializeReplicator(pItem->GetDBName()); } int nImage = -1, nSelectedImage = -1; CImageList* pImageList = pTree->GetImageList (TVSIL_NORMAL); HICON hIcon = NULL; int nImageCount = pImageList? pImageList->GetImageCount(): 0; if (pImageList && pTree->GetItemImage(hSelected, nImage, nSelectedImage)) { if (nImage < nImageCount) hIcon = pImageList->ExtractIcon(nImage); } CuPageInformation* pPageInfo = pItem->GetPageInformation(); ASSERT(pPageInfo); if (!pPageInfo) return FALSE; int nSelectTab = GetDefaultSelectTab (pDoc); CString strItem = pItem->GetRightPaneTitle(); pItem->UpdateDataWhenSelChange(); // Has an effect only if the class has specialied the method. ups.nType = pItem->GetType(); ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL; ups.pSFilter= pDoc->GetPTreeGD()->GetPSFilter(); pPageInfo->SetUpdateParam (&ups); pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, pDoc); pPageInfo->SetImage (hIcon); pTabDlg->DisplayPage (pPageInfo, NULL, nSelectTab); return TRUE; } catch(CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch(CResourceException* e) { AfxMessageBox (IDS_E_LOAD_DLG); e->Delete(); } catch(...) { AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY); } return FALSE; }
BOOL COXCustomizeManager::InsertPage(COXCustomizePage* pCustomizePage, int nPageIndex) { ASSERT(pCustomizePage!=NULL); CString sTitle=pCustomizePage->GetTitle(); LPCTSTR lpszImageResource=pCustomizePage->GetImageResource(); COLORREF clrMask=pCustomizePage->GetImageMask(); CString sTooltip=pCustomizePage->GetTooltip(); CString sGroup=pCustomizePage->GetGroup(); #ifdef _DEBUG ASSERT(nPageIndex>=0 && nPageIndex<=GetPageCount(sGroup)); HSHBGROUP hGroupTest=NULL; int nIndexTest=-1; ASSERT(!FindPage(pCustomizePage,hGroupTest,nIndexTest)); ASSERT(!FindPage(sTitle,sGroup,hGroupTest,nIndexTest)); #endif // find/create the corresponding shortcut bar group HSHBGROUP hGroup=m_shb.FindGroupByTitle(sGroup); BOOL bNewGroup=FALSE; if(hGroup==NULL) { hGroup=m_shb.InsertGroup(sGroup); bNewGroup=TRUE; } if(hGroup==NULL) { TRACE(_T("COXCustomizeManager::InsertPage: failed to create group for the specified page\n")); if(bNewGroup) m_shb.DeleteGroup(hGroup); return FALSE; } // associate image list with the created group m_shb.SetLCImageList(hGroup,&m_ilShortcutBar,LVSIL_NORMAL); // get image index for new page int nImageIndex=-1; if(lpszImageResource!=NULL) { CImageList imageList; if(!imageList.Create(lpszImageResource,32,0,clrMask)) { TRACE(_T("COXCustomizeManager::InsertPage: failed to extract image for new page\n")); if(bNewGroup) { m_shb.DeleteGroup(hGroup); } return FALSE; } HICON hIcon=imageList.ExtractIcon(0); ASSERT(hIcon!=NULL); nImageIndex=m_ilShortcutBar.Add(hIcon); ASSERT(nImageIndex!=-1); VERIFY(::DestroyIcon(hIcon)); } int nItem=m_shb.InsertLCItem(hGroup,nPageIndex,sTitle,nImageIndex, (LPARAM)pCustomizePage); if(nItem==-1) { TRACE(_T("COXCustomizeManager::InsertPage: failed to insert new item into the shortcut bar\n")); if(bNewGroup) { m_shb.DeleteGroup(hGroup); } return FALSE; } m_mapPages.SetAt(pCustomizePage,((PtrToLong(hGroup))<<16)+nItem); m_mapTooltips.SetAt(pCustomizePage,sTooltip); return TRUE; }
BOOL CdIpmDoc::UpdateDisplay() { TRACE0("CdIpmDoc::UpdateDisplay()\n"); try { m_pTreeGD->RefreshAllTreeBranches(); // refresh left pane IPMUPDATEPARAMS ups; memset (&ups, 0, sizeof (ups)); CTreeItem* pItem = NULL; CTreeCtrl* pTree = m_pTreeGD->GetPTree(); ASSERT (pTree); HTREEITEM hSelectedItem = pTree->GetSelectedItem(); if (!hSelectedItem) return FALSE; pItem = (CTreeItem*)pTree->GetItemData(hSelectedItem); ASSERT (pItem); if (pItem->IsNoItem() || pItem->IsErrorItem()) { m_pTabDialog->DisplayPage (NULL); } else if (pItem->ItemDisplaysNoPage()) { CString caption = pItem->ItemNoPageCaption(); m_pTabDialog->DisplayPage (NULL, caption); } else { int nImage = -1, nSelectedImage = -1; CImageList* pImageList = pTree->GetImageList (TVSIL_NORMAL); HICON hIcon = NULL; int nImageCount = pImageList? pImageList->GetImageCount(): 0; if (pImageList && pTree->GetItemImage(hSelectedItem, nImage, nSelectedImage)) { if (nImage < nImageCount) hIcon = pImageList->ExtractIcon(nImage); } CuPageInformation* pPageInfo = pItem->GetPageInformation(); CString strItem = pItem->GetRightPaneTitle(); ups.nType = pItem->GetType(); ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL; ups.pSFilter= m_pTreeGD->GetPSFilter(); pPageInfo->SetUpdateParam (&ups); pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, this); pPageInfo->SetImage (hIcon); m_pTabDialog->DisplayPage (pPageInfo); } // Replicator Monitor special management // ASSUMES we did not change the current item! BOOL bReplMonWasOn = (m_hReplMonHandle != -1) ? TRUE: FALSE; BOOL bReplMonToBeOn = pItem->HasReplicMonitor(); // 3 cases : // - on to off ---> replicator has been uninstalled // - off to on ---> replicator has been installed // - on to on, or off to off: state has not changed if (bReplMonWasOn && !bReplMonToBeOn) { BOOL bOK = TerminateReplicator(); ASSERT (bOK); } else if (!bReplMonWasOn && bReplMonToBeOn) { CString csDbName = pItem->GetDBName(); BOOL bOK = InitializeReplicator(csDbName); ASSERT (bOK); } // // Refresh right pane CfIpmFrame* pIpmFrame = (CfIpmFrame*)pTree->GetParentFrame(); UpdateAllViews((CView *)pIpmFrame->GetLeftPane()); } catch(CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); return FALSE; } catch(CResourceException* e) { //_T("Cannot load dialog box"); AfxMessageBox (IDS_E_LOAD_DLG); e->Delete(); return FALSE; } catch(...) { //_T("Cannot construct the property pane"); AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY); return FALSE; } return TRUE; }
//----- OnInitialUpdate() --------------------------------------------------- void CFormChunkMergeView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); // initialize GUI (icons, texts, read-only) CImageList* pImageList (CFDResourceManager::getInstance()->getImageListBrowse()); CImageList* pImageListDis(CFDResourceManager::getInstance()->getImageListOtherDis()); ((CMFCButton*) GetDlgItem(IDC_BT_FILE_IN)) ->SetImage(pImageList->ExtractIcon(1)); ((CMFCButton*) GetDlgItem(IDC_BT_FILE_COLL))->SetImage(pImageList->ExtractIcon(1)); /* ((CEdit*) ((CComboBox*) GetDlgItem(IDC_CB_TEMPLATE)) ->GetDlgItem(1001))->SetReadOnly(); ((CEdit*) ((CComboBox*) GetDlgItem(IDC_CB_MAT_SINGLE))->GetDlgItem(1001))->SetReadOnly(); */ ::SetWindowTheme(GetDlgItem(IDC_GBOX_FILES) ->GetSafeHwnd(), _T(""), _T("")); ::SetWindowTheme(GetDlgItem(IDC_GBOX_HINTS) ->GetSafeHwnd(), _T(""), _T("")); ::SetWindowTheme(GetDlgItem(IDC_GBOX_COLLISION)->GetSafeHwnd(), _T(""), _T("")); ::SetWindowTheme(GetDlgItem(IDC_GBOX_MATERIAL) ->GetSafeHwnd(), _T(""), _T("")); ::SetWindowTheme(GetDlgItem(IDC_GBOX_HANDLING) ->GetSafeHwnd(), _T(""), _T("")); pImageList = CFDResourceManager::getInstance()->getImageListNumbers(); for (short i(1); i < 6; ++i) { ((CStatic*) GetDlgItem(IDC_PC_NUM_0+i)) ->SetIcon(pImageList->ExtractIcon(i)); ((CStatic*) GetDlgItem(IDC_PC_HINT_0+i))->SetIcon(pImageList->ExtractIcon(i)); } pImageList = CFDResourceManager::getInstance()->getImageListOther(); ((CMFCButton*) GetDlgItem(IDC_BT_CONVERT)) ->SetImage(pImageList->ExtractIcon(0)); ((CMFCButton*) GetDlgItem(IDC_BT_MAT_DEFINE)) ->SetImage(pImageList->ExtractIcon(7), true, NULL, pImageListDis->ExtractIcon(7)); ((CMFCButton*) GetDlgItem(IDC_BT_RESET_FORM)) ->SetImage(pImageList->ExtractIcon(2)); ((CMFCButton*) GetDlgItem(IDC_BT_VIEW_IN)) ->SetImage(pImageList->ExtractIcon(4), true, NULL, pImageListDis->ExtractIcon(4)); ((CMFCButton*) GetDlgItem(IDC_BT_VIEW_COLL)) ->SetImage(pImageList->ExtractIcon(4), true, NULL, pImageListDis->ExtractIcon(4)); ((CMFCButton*) GetDlgItem(IDC_BT_TEMPLATE)) ->SetImage(pImageList->ExtractIcon(3)); ((CMFCButton*) GetDlgItem(IDC_BT_NSCOPE_IN)) ->SetImage(pImageList->ExtractIcon(10), true, NULL, pImageListDis->ExtractIcon(10)); ((CMFCButton*) GetDlgItem(IDC_BT_NSCOPE_COLL))->SetImage(pImageList->ExtractIcon(10), true, NULL, pImageListDis->ExtractIcon(10)); GetDlgItem(IDC_BT_VIEW_IN) ->EnableWindow(FALSE); GetDlgItem(IDC_BT_NSCOPE_IN) ->EnableWindow(FALSE); GetDlgItem(IDC_BT_VIEW_COLL) ->EnableWindow(FALSE); GetDlgItem(IDC_BT_NSCOPE_COLL) ->EnableWindow(FALSE); GetDlgItem(IDC_RD_COLL_LOCAL) ->EnableWindow(FALSE); GetDlgItem(IDC_RD_COLL_GLOBAL) ->EnableWindow(FALSE); GetDlgItem(IDC_CK_REORDER_TRIS)->EnableWindow(FALSE); // initialize log view CRichEditCtrl* pLogView((CRichEditCtrl*) GetDlgItem(IDC_RE_LOG)); CHARFORMAT cf = { 0 }; cf.cbSize = sizeof(cf); cf.dwMask = CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_PROTECTED; cf.dwEffects = 0; cf.yHeight = 127; lstrcpy(cf.szFaceName, _T("Small Fonts")); pLogView->SetDefaultCharFormat(cf); pLogView->SetReadOnly (TRUE); if (Configuration::getInstance()->_lvwLogActive[0]) { pLogView->SetBackgroundColor(FALSE, Configuration::getInstance()->_lvwColors[0]); } // prepare tool tips if (_toolTipCtrl.Create(this, TTS_USEVISUALSTYLE | TTS_BALLOON)) { for (short i(0); glToolTiplist[i]._uid != -1; ++i) { _toolTipCtrl.AddTool(GetDlgItem(glToolTiplist[i]._uid), CString(glToolTiplist[i]._text.c_str())); } _toolTipCtrl.SetMaxTipWidth(260); _toolTipCtrl.Activate(Configuration::getInstance()->_showToolTipps); } // set settings from configuration BroadcastEvent(IBCE_CHANGED_SETTINGS); // disable 'defining materials' until working GetDlgItem(IDC_RD_MAT_DEFINE)->EnableWindow(FALSE); }
//----- OnInitialUpdate() --------------------------------------------------- void CFormBlenderPrepareView::OnInitialUpdate() { CFormView::OnInitialUpdate(); GetParentFrame()->RecalcLayout(); // initialize GUI (icons, texts, read-only) CImageList* pImageList (CFDResourceManager::getInstance()->getImageListBrowse()); CImageList* pImageListDis(CFDResourceManager::getInstance()->getImageListOtherDis()); ((CMFCButton*) GetDlgItem(IDC_BT_FILE_IN)) ->SetImage(pImageList->ExtractIcon(1)); ((CMFCButton*) GetDlgItem(IDC_BT_FILE_OUT))->SetImage(pImageList->ExtractIcon(1)); ::SetWindowTheme(GetDlgItem(IDC_GBOX_FILES)->GetSafeHwnd(), _T(""), _T("")); ::SetWindowTheme(GetDlgItem(IDC_GBOX_HINTS)->GetSafeHwnd(), _T(""), _T("")); ::SetWindowTheme(GetDlgItem(IDC_GBOX_TOOLS)->GetSafeHwnd(), _T(""), _T("")); pImageList = CFDResourceManager::getInstance()->getImageListNumbers(); for (short i(1); i < 5; ++i) { if (i != 3) { ((CStatic*) GetDlgItem(IDC_PC_NUM_0+i))->SetIcon(pImageList->ExtractIcon(i)); } ((CStatic*) GetDlgItem(IDC_PC_HINT_0+i))->SetIcon(pImageList->ExtractIcon(i)); } pImageList = CFDResourceManager::getInstance()->getImageListOther(); ((CMFCButton*) GetDlgItem(IDC_BT_CONVERT)) ->SetImage(pImageList->ExtractIcon(0)); ((CMFCButton*) GetDlgItem(IDC_BT_RESET_FORM)) ->SetImage(pImageList->ExtractIcon(2)); ((CMFCButton*) GetDlgItem(IDC_BT_VIEW_IN)) ->SetImage(pImageList->ExtractIcon(4), true, NULL, pImageListDis->ExtractIcon(4)); ((CMFCButton*) GetDlgItem(IDC_BT_VIEW_OUT)) ->SetImage(pImageList->ExtractIcon(4), true, NULL, pImageListDis->ExtractIcon(4)); ((CMFCButton*) GetDlgItem(IDC_BT_NSCOPE_IN)) ->SetImage(pImageList->ExtractIcon(10), true, NULL, pImageListDis->ExtractIcon(10)); ((CMFCButton*) GetDlgItem(IDC_BT_NSCOPE_OUT)) ->SetImage(pImageList->ExtractIcon(10), true, NULL, pImageListDis->ExtractIcon(10)); GetDlgItem(IDC_BT_VIEW_IN) ->EnableWindow(FALSE); GetDlgItem(IDC_BT_NSCOPE_IN) ->EnableWindow(FALSE); GetDlgItem(IDC_BT_VIEW_OUT) ->EnableWindow(FALSE); GetDlgItem(IDC_BT_NSCOPE_OUT)->EnableWindow(FALSE); // initialize log view CRichEditCtrl* pLogView((CRichEditCtrl*) GetDlgItem(IDC_RE_LOG)); CHARFORMAT cf = { 0 }; cf.cbSize = sizeof(cf); cf.dwMask = CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_PROTECTED; cf.dwEffects = 0; cf.yHeight = 127; lstrcpy(cf.szFaceName, _T("Small Fonts")); pLogView->SetDefaultCharFormat(cf); pLogView->SetReadOnly (TRUE); if (Configuration::getInstance()->_lvwLogActive[0]) { pLogView->SetBackgroundColor(FALSE, Configuration::getInstance()->_lvwColors[0]); } // create initial sub form CRect tRect; GetDlgItem(IDC_SUBFORM_BOX)->GetWindowRect(&tRect); _subFormList.SetPosition (tRect); _subFormList.CreateSubForm(IDD_SUB_ARMOR_BLENDER, this, new CSubFormArmorBlender()); _subFormList.CreateSubForm(IDD_SUB_BLENDER_ARMOR, this, new CSubFormBlenderArmor()); _subFormList.ShowSubForm (0); // prepare tool tips if (_toolTipCtrl.Create(this, TTS_USEVISUALSTYLE | TTS_BALLOON)) { for (short i(0); glToolTiplist[i]._uid != -1; ++i) { _toolTipCtrl.AddTool(GetDlgItem(glToolTiplist[i]._uid), CString(glToolTiplist[i]._text.c_str())); } _toolTipCtrl.SetMaxTipWidth(260); _toolTipCtrl.Activate(Configuration::getInstance()->_showToolTipps); } // set settings from configuration BroadcastEvent(IBCE_CHANGED_SETTINGS); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { TRACE("CMainFrame::OnCreate"); if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; OnAppLook (m_nAppLook); CMFCToolBar::EnableQuickCustomization (); UpdateMDITabs (FALSE); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); // Prevent the menu bar from taking the focus on activation CMFCPopupMenu::SetForceMenuFocus(FALSE); // Detect color depth. 256 color toolbars can be used in the // high or true color modes only (bits per pixel is > 8): CClientDC dc (this); BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndToolBarTheme.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_THEME_TOOLBAR) || !m_wndToolBarTheme.LoadToolBar (IDR_THEME, 0, 0, TRUE /* Locked */)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } CImageList imagesWorkspace; imagesWorkspace.Create (IDB_WORKSPACE, 16, 0, RGB (255, 0, 255)); if (!m_wndWorkSpace.Create (_T("MDI Tabs Options"), this, CRect (0, 0, 300, 300), TRUE, ID_VIEW_WORKSPACE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create Workspace bar\n"); return FALSE; // fail to create } m_wndWorkSpace.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); if (!m_wndWorkSpace2.Create (_T("My Second Tab Options"), this, CRect (0, 0, 300, 300), TRUE, ID_VIEW_WORKSPACE2, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create Workspace bar\n"); return FALSE; // fail to create } m_wndWorkSpace2.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); m_wndToolBar.SetWindowText (_T("Standard")); m_wndToolBarTheme.SetWindowText (_T("Visual Style")); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBarTheme.EnableDocking(CBRS_ALIGN_ANY); m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY); m_wndWorkSpace2.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); EnableAutoHidePanes(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); DockPane(&m_wndToolBarTheme); DockPane (&m_wndWorkSpace); DockPane (&m_wndWorkSpace2); m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); m_wndToolBarTheme.EnableCustomizeButton (TRUE, -1, _T("")); // Enable windows manager: EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); return 0; }
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) ); } } } }
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); } } } }
//------------------------------------------------------------------------// HICON CBCGPGlobalUtils::GetWndIcon (CWnd* pWnd, BOOL* bDestroyIcon, BOOL bNoDefault) { #ifdef _BCGSUITE_ UNREFERENCED_PARAMETER(bNoDefault); #endif ASSERT_VALID (pWnd); if (pWnd->GetSafeHwnd () == NULL) { return NULL; } if (bDestroyIcon != NULL) { *bDestroyIcon = FALSE; } HICON hIcon = pWnd->GetIcon (FALSE); if (hIcon == NULL) { hIcon = pWnd->GetIcon (TRUE); if (hIcon != NULL) { CImageList il; il.Create (16, 16, ILC_COLOR32 | ILC_MASK, 0, 1); il.Add (hIcon); if (il.GetImageCount () == 1) { hIcon = il.ExtractIcon (0); if (bDestroyIcon != NULL) { *bDestroyIcon = hIcon != NULL; } } } } if (hIcon == NULL) { hIcon = (HICON)(LONG_PTR)::GetClassLongPtr(pWnd->GetSafeHwnd (), GCLP_HICONSM); } if (hIcon == NULL) { hIcon = (HICON)(LONG_PTR)::GetClassLongPtr(pWnd->GetSafeHwnd (), GCLP_HICON); } #ifndef _BCGSUITE_ if (hIcon == NULL && !bNoDefault && !pWnd->IsKindOf (RUNTIME_CLASS(CDialog)) && !pWnd->IsKindOf (RUNTIME_CLASS(CPropertySheet))) { hIcon = globalData.m_hiconApp; if (bDestroyIcon != NULL) { *bDestroyIcon = FALSE; } } #endif return hIcon; }
void CBCGPFileDialog::OnInitDone() { const int iBorderWidth = 20; const int iBorderHeight = 40; CWnd* pFD = GetParent(); ASSERT (pFD != NULL); CRect rectClient; pFD->GetClientRect (rectClient); int nNewDlgWidth = rectClient.Width () + iBorderWidth * 2 + m_iExtraWidth; if (m_pBmpLogo != NULL) { BITMAP bmp; m_pBmpLogo->GetBitmap (&bmp); m_rectLogo = CRect (CPoint (max (0, (nNewDlgWidth - bmp.bmWidth) / 2), 8), CSize (bmp.bmWidth, bmp.bmHeight)); m_iLogoAreaHeight = bmp.bmHeight + 20; } //--------------------------- // Adjust parent window size: //--------------------------- pFD->ModifyStyle (WS_THICKFRAME, WS_DLGFRAME | WS_BORDER); pFD->ModifyStyleEx (WS_EX_WINDOWEDGE, 0); pFD->SetWindowPos (NULL, -1, -1, nNewDlgWidth, rectClient.Height () + iBorderHeight * 2 + m_iLogoAreaHeight + m_iExtraHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); //------------------- // Move all controls: //------------------- CWnd* pWndChild = pFD->GetWindow (GW_CHILD); while (pWndChild != NULL) { CRect rectCtl; pWndChild->GetClientRect (rectCtl); pWndChild->MapWindowPoints (pFD, rectCtl); pWndChild->SetWindowPos (NULL, rectCtl.left + iBorderWidth, rectCtl.top + iBorderHeight + m_iLogoAreaHeight, rectCtl.Width (), rectCtl.Height (), SWP_NOZORDER | SWP_NOACTIVATE); pWndChild = pWndChild->GetNextWindow (); } //------------------------------------------ // Create new and recent file list controls: //------------------------------------------ CRect rectList (0, 0, 0, 0); m_wndNewList.Create (WS_VISIBLE | WS_BORDER | WS_TABSTOP | WS_CHILD | LVS_ICON | LVS_AUTOARRANGE | LVS_SINGLESEL, rectList, pFD, iNewListCtrlId); m_wndNewList.ModifyStyleEx (0, WS_EX_CLIENTEDGE); if (m_pImagesNew != NULL) { m_wndNewList.SetImageList (m_pImagesNew, LVSIL_NORMAL); } int i = 0; for (POSITION pos = m_lstNewItems.GetHeadPosition (); pos != NULL; i ++) { CNewItemInfo* pInfo = (CNewItemInfo*) m_lstNewItems.GetNext (pos); ASSERT_VALID (pInfo); m_wndNewList.InsertItem (i, pInfo->m_strName, pInfo->m_iIconIndex); } m_wndRecentList.Create (WS_TABSTOP | WS_CHILD | WS_BORDER | LVS_SINGLESEL | LVS_REPORT, rectList, pFD, iRecentListCtrlId); m_wndRecentList.ModifyStyleEx (0, WS_EX_CLIENTEDGE); m_ImagesRecent.Create ( globalData.m_sizeSmallIcon.cx, globalData.m_sizeSmallIcon.cy, ILC_COLOR, 0, 10); m_wndRecentList.SetImageList (&m_ImagesRecent, LVSIL_SMALL); { CBCGPLocalResource locaRes; CString strFile; strFile.LoadString (IDS_BCGBARRES_FILE); m_wndRecentList.InsertColumn (0, strFile, LVCFMT_LEFT, 100); CString strFolder; strFolder.LoadString (IDS_BCGBARRES_FOLDER); m_wndRecentList.InsertColumn (1, strFolder); } CRecentFileList* pMRUFiles = ((CBCGApp*) AfxGetApp ())->m_pRecentFileList; if (pMRUFiles != NULL) { TCHAR szCurDir [_MAX_PATH + 1]; ::GetCurrentDirectory (_MAX_PATH, szCurDir); int nCurDir = lstrlen (szCurDir); ASSERT (nCurDir >= 0); szCurDir [nCurDir] = _T('\\'); szCurDir [++ nCurDir] = _T('\0'); //--------------- // Add MRU files: //--------------- int iNumOfFiles = 0; // Actual added to menu for (int i = 0; i < pMRUFiles->GetSize (); i ++) { CString strFile = (*pMRUFiles) [i]; if (!strFile.IsEmpty ()) { CString strPath; CString strName; int iImage = -1; int iIndex = strFile.ReverseFind (_T('\\')); if (iIndex != -1) { strPath = strFile.Left (iIndex); strName = strFile.Mid (iIndex + 1); } else { strName = strFile; } SHFILEINFO sfi; HIMAGELIST himlSmall = (HIMAGELIST) SHGetFileInfo (strFile, 0, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); if (himlSmall != NULL) { CImageList* pImages = CImageList::FromHandle (himlSmall); ASSERT (pImages != NULL); HICON hIcon = pImages->ExtractIcon (sfi.iIcon); iImage = m_ImagesRecent.Add (hIcon); if (hIcon != NULL) { ::DestroyIcon (hIcon); } } iIndex = m_wndRecentList.InsertItem (iNumOfFiles ++, strName, iImage); m_wndRecentList.SetItemText (iIndex, 1, strPath); int iPathWidth = m_wndRecentList.GetStringWidth (strPath) + 20; if (iPathWidth > m_wndRecentList.GetColumnWidth (1)) { m_wndRecentList.SetColumnWidth (1, iPathWidth); } } } } //--------------------- // Create tabs control: //--------------------- CRect rectTabs; pFD->GetClientRect (rectTabs); rectTabs.DeflateRect (4, 4); rectTabs.top += m_iLogoAreaHeight; m_wndTab.Create (CBCGPTabWnd::STYLE_3D, rectTabs, pFD, iTabCtrlId, CBCGPTabWnd::LOCATION_TOP); m_wndTab.m_pParent = this; m_wndTab.SetActiveTabBoldFont (); m_wndTab.SetFont (GetFont ()); m_wndTab.SetOwner (this); m_wndDummy.Create (_T(""), WS_CHILD, CRect (0, 0, 0, 0), this); { CBCGPLocalResource locaRes; CString strTab; if (m_bNewPage) { m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_NEW_FILE, (UINT)-1, FALSE); } m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_EXISTING, (UINT)-1, FALSE); m_wndTab.AddTab (&m_wndDummy, IDS_BCGBARRES_RECENT, (UINT)-1, FALSE); } pFD->CenterWindow (); pFD->SetWindowText (m_strCaption); //------------------ // Set dilaog icons: //------------------ if (m_hIconSmall != NULL) { pFD->SetIcon (m_hIconSmall, FALSE); } if (m_hIconBig != NULL) { pFD->SetIcon (m_hIconBig, TRUE); } //-------------------------- // Setup parent window proc: //-------------------------- m_wndProc = (WNDPROC)SetWindowLongPtr(pFD->m_hWnd, GWLP_WNDPROC, (LONG_PTR) CBCGPFileDialog::WindowProcNew); }
void CvIpmLeft::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) { IPMUPDATEPARAMS ups; NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; CdIpmDoc* pDoc = (CdIpmDoc *)GetDocument(); try { ASSERT(pDoc); if (!pDoc) return; if (pDoc->GetLockDisplayRightPane()) return; CfIpmFrame* pFrame = (CfIpmFrame*)GetParentFrame(); ASSERT (pFrame); if (!pFrame) return; if (!pFrame->IsAllViewCreated()) return; CuDlgIpmTabCtrl* pTabDlg = (CuDlgIpmTabCtrl*)pFrame->GetTabDialog(); if (!pTabDlg) return; CWaitCursor doWaitCursor ; // // Notify the container of sel change: CIpmCtrl* pIpmCtrl = (CIpmCtrl*)pFrame->GetParent(); if (pIpmCtrl) pIpmCtrl->ContainerNotifySelChange(); memset (&ups, 0, sizeof (ups)); CTreeCtrl& treeCtrl = GetTreeCtrl(); CTreeItem* pItem = (CTreeItem*)treeCtrl.GetItemData (pNMTreeView->itemNew.hItem); if (pItem->IsNoItem() || pItem->IsErrorItem()) { pTabDlg->DisplayPage (NULL); *pResult = 0; return; } if (pItem->ItemDisplaysNoPage()) { CString caption = pItem->ItemNoPageCaption(); pTabDlg->DisplayPage (NULL, caption); *pResult = 0; return; } if (pItem->HasReplicMonitor()) { pDoc->InitializeReplicator(pItem->GetDBName()); } int nImage = -1, nSelectedImage = -1; CImageList* pImageList = treeCtrl.GetImageList (TVSIL_NORMAL); HICON hIcon = NULL; int nImageCount = pImageList? pImageList->GetImageCount(): 0; if (pImageList && treeCtrl.GetItemImage(pNMTreeView->itemNew.hItem, nImage, nSelectedImage)) { if (nImage < nImageCount) hIcon = pImageList->ExtractIcon(nImage); } CuPageInformation* pPageInfo = pItem->GetPageInformation(); CString strItem = pItem->GetRightPaneTitle(); pItem->UpdateDataWhenSelChange(); // Has an effect only if the class has specialied the method. ups.nType = pItem->GetType(); ups.pStruct = pItem->GetPTreeItemData()? pItem->GetPTreeItemData()->GetDataPtr(): NULL; ups.pSFilter= pDoc->GetPTreeGD()->GetPSFilter(); pPageInfo->SetUpdateParam (&ups); pPageInfo->SetTitle ((LPCTSTR)strItem, pItem, pDoc); pPageInfo->SetImage (hIcon); pTabDlg->DisplayPage (pPageInfo); } catch(CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch(CResourceException* e) { AfxMessageBox (IDS_E_LOAD_DLG); e->Delete(); } catch(...) { AfxMessageBox (IDS_E_CONSTRUCT_PROPERTY); } *pResult = 0; }