1、修改左上角圓形按圖標(biāo)。可以將要顯示的圖標(biāo)放在資源中加載,也可以將圖標(biāo)文件放在程序目錄下加載。
成都創(chuàng)新互聯(lián)公司長期為數(shù)千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為圖木舒克企業(yè)提供專業(yè)的成都網(wǎng)站制作、成都做網(wǎng)站,圖木舒克網(wǎng)站改版等技術(shù)服務(wù)。擁有十多年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。CRect rt1; m_wndRibbonBar.GetClientRect(&rt1); CMFCRibbonApplicationButton * pAppButton = m_wndRibbonBar.GetApplicationButton(); HBITMAP hBitmap = (HBITMAP)::LoadImage(NULL, CScale3DCGlobal::GetAppllicationPath()+ _T("\\user\\admin.bmp"), IMAGE_BITMAP, 0, 0, //原始大小 LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_LOADFROMFILE); pAppButton->SetImage(hBitmap);
以上代碼放在MainFrame.cpp的OnCreate中執(zhí)行。
2、在Ribbon中加載自己的控件
CRect rt(10, rt1.bottom+3, 460, rt1.bottom + 3+107); m_LedString.Create(_T("000000"), 0, rt, &m_wndRibbonBar, IDC_LED1); m_LedString.SetStringPost(25, 21); m_LedString.SetStringAmp(0.3); m_LedString.SetTip(_T("COM4:9600 XK3190A9 COM2:YH-5大屏幕")); m_LedString.SetUnit(_T("公斤"));
3、在一個按鈕點(diǎn)擊事件中創(chuàng)建新的視圖
if (m_bIsScaleWeightView) { m_pScaleWeightChildFrame->ActivateFrame();//激活已存在的視圖 m_pScaleWeightChildFrame->SetFocus(); return; } m_pScaleWeightChildFrame = new CScale3DCChildFrame; CCreateContext context; context.m_pNewViewClass = RUNTIME_CLASS(CScale3DCScaleWeightView); if (!m_pScaleWeightChildFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_PREFIXTITLE, AfxGetMainWnd(), &context)) return; m_pScaleWeightChildFrame->InitialUpdateFrame(NULL, TRUE); m_bIsScaleWeightView = TRUE;//防止重復(fù)創(chuàng)建視圖
4、通過工具欄隱藏和顯示面板
BOOL CScale3DCMainFrame::OnCloseDockingPane(CDockablePane* pWnd)//虛函數(shù) { // TODO: 在此添加專用代碼和/或調(diào)用基類 m_bVideoShow = TRUE; m_bDataGridShow = TRUE; return CMDIFrameWndEx::OnCloseDockingPane(pWnd); } //虛函數(shù) BOOL CScale3DCMainFrame::OnCloseMiniFrame(CPaneFrameWnd* pWnd) { // TODO: 在此添加專用代碼和/或調(diào)用基類 CWnd* pwnd = pWnd->GetPane(); if (pwnd->IsKindOf(RUNTIME_CLASS(CTabbedPane)))//多個窗口 { CTabbedPane* tabpane = (CTabbedPane *)pwnd; CMFCBaseTabCtrl* pTabWnd = tabpane->GetUnderlyingWindow(); //關(guān)閉所有的面板 for (int i = 0; i < pTabWnd->GetTabsNum(); i++) { CDockablePane* pBar = DYNAMIC_DOWNCAST(CDockablePane, pTabWnd->GetTabWnd(i)); if (pBar != NULL) { ASSERT_VALID(pBar); //將關(guān)閉消息加入該DockPane隊(duì)列,等待完成本函數(shù)后關(guān)閉 ::PostMessageA(pBar->m_hWnd, WM_CLOSE, 0, 0); } } } else { //單個窗口 CDockablePane* pane = (CDockablePane *)pwnd; if (pane->IsKindOf(RUNTIME_CLASS(CDockablePane)) || pane->IsKindOf(RUNTIME_CLASS(CPane)) && pane->IsKindOf(RUNTIME_CLASS(CPaneFrameWnd))) { //將關(guān)閉消息加入該DockPane隊(duì)列,等待完成本函數(shù)后關(guān)閉 ::PostMessageA(pWnd->GetPane()->m_hWnd, WM_CLOSE, 0, 0); } } m_bVideoShow = TRUE; m_bDataGridShow = TRUE; return TRUE; //return CMDIFrameWndEx::OnCloseMiniFrame(pWnd); } void CScale3DCMainFrame::OnButtonVideo() { if (!m_bVideoShow) { m_bVideoShow = TRUE; m_wndVideoPanel.ShowPane(FALSE, FALSE, FALSE); } else if (m_wndVideoPanel.GetSafeHwnd()) { m_bVideoShow = FALSE; m_wndVideoPanel.ShowPane(TRUE, FALSE, TRUE); } else { BOOL bNameValid; CString strPropertiesWnd; bNameValid = strPropertiesWnd.LoadString(IDS_PROPERTIES_WND); ASSERT(bNameValid); if (!m_wndVideoPanel.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) { TRACE("未能創(chuàng)建%s窗口\n", strPropertiesWnd); return; } m_wndVideoPanel.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndVideoPanel); m_bVideoShow = FALSE; } RecalcLayout(); } void CScale3DCMainFrame::OnButtonDatagrid() { // TODO: 在此添加命令處理程序代碼 if (!m_bDataGridShow) { m_bDataGridShow = TRUE; m_wndDataGridPanel.ShowPane(FALSE, FALSE, FALSE); } else if (m_wndDataGridPanel.GetSafeHwnd()) { m_bDataGridShow = FALSE; m_wndDataGridPanel.ShowPane(TRUE, FALSE, TRUE); } else { BOOL bNameValid; CString strPropertiesWnd; bNameValid = strPropertiesWnd.LoadString(IDS_OUTPUT_WND); ASSERT(bNameValid); if (!m_wndDataGridPanel.Create(strPropertiesWnd, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI)) { TRACE("未能創(chuàng)建%s窗口\n", strPropertiesWnd); return; } m_wndDataGridPanel.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndDataGridPanel); m_bDataGridShow = FALSE; } RecalcLayout(); }
5、設(shè)置視圖的標(biāo)簽標(biāo)題文字
BOOL CScale3DCChildFrame::PreCreateWindow(CREATESTRUCT& cs) { // TODO: 在此處通過修改 CREATESTRUCT cs 來修改窗口類或樣式 cs.style &= ~(LONG)FWS_ADDTOTITLE; if( !CMDIChildWndEx::PreCreateWindow(cs) ) return FALSE; return TRUE; }
void CScale3DCScaleWeightView::OnInitialUpdate() { CFormView::OnInitialUpdate(); CMDIChildWndEx * pFrame = (CMDIChildWndEx*)this->GetParentFrame(); CScale3DCChildFrame * pMidFrame = (CScale3DCChildFrame*)pFrame; pMidFrame->SetWindowText(_T("稱重數(shù)據(jù)區(qū)")); // TODO: 在此添加專用代碼和/或調(diào)用基類 }
6、改變視圖的背景顏色
BOOL CScale3DCScaleWeightView::OnEraseBkgnd(CDC* pDC) { // TODO: 在此添加消息處理程序代碼和/或調(diào)用默認(rèn)值 CRect rt; GetClientRect(&rt); CBrush brush; brush.CreateSolidBrush(RGB(255, 255, 255)); CBrush * pOldBrush = pDC->SelectObject(&brush); pDC->FillRect(&rt, &brush); pDC->SelectObject(pOldBrush); return TRUE; //return CFormView::OnEraseBkgnd(pDC); }
7、在一個視圖中創(chuàng)建另一個視圖
CScale3DCMainFrame * pMainFrame = (CScale3DCMainFrame*)AfxGetMainWnd(); CScale3DCMainControlPanel2 * pPanel = &pMainFrame->m_wndMainControlPanel; pPanel->m_wndMainToolbarDlg->CreateScaleWeightView();
8、遍歷主框架中的子框架
void CScale3DCMainFrame::SearchAllMDIFrame() { CMDIFrameWnd *pFrame = (CMDIFrameWnd*)::AfxGetMainWnd(); if (pFrame) { CMDIChildWnd *pOldChildFrame = pFrame->MDIGetActive(); CMDIChildWnd *pChildFrame = pOldChildFrame; if (pChildFrame) { do { CString strCaption; pChildFrame->GetWindowText(strCaption); if (_T("主控界面區(qū)") == strCaption) { CView * pView= pChildFrame->GetActiveView(); //消息發(fā)向主控視圖 pView->SendMessage(WM_STARTSCALEWEIGHTVIEW, 0, 0); return; } pFrame->MDINext(); pChildFrame = pFrame->MDIGetActive(); } while (pChildFrame != pOldChildFrame); } } }
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。