大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
1、修改左上角圆形按图标。可以将要显示的图标放在资源中加载,也可以将图标文件放在程序目录下加载。
创新互联建站是专业的恩阳网站建设公司,恩阳接单;提供成都做网站、成都网站设计,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行恩阳网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
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中执行。
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、在一个按钮点击事件中创建新的视图
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;//防止重复创建视图
4、通过工具栏隐藏和显示面板
BOOL CScale3DCMainFrame::OnCloseDockingPane(CDockablePane* pWnd)//虚函数 { // TODO: 在此添加专用代码和/或调用基类 m_bVideoShow = TRUE; m_bDataGridShow = TRUE; return CMDIFrameWndEx::OnCloseDockingPane(pWnd); } //虚函数 BOOL CScale3DCMainFrame::OnCloseMiniFrame(CPaneFrameWnd* pWnd) { // TODO: 在此添加专用代码和/或调用基类 CWnd* pwnd = pWnd->GetPane(); if (pwnd->IsKindOf(RUNTIME_CLASS(CTabbedPane)))//多个窗口 { CTabbedPane* tabpane = (CTabbedPane *)pwnd; CMFCBaseTabCtrl* pTabWnd = tabpane->GetUnderlyingWindow(); //关闭所有的面板 for (int i = 0; i < pTabWnd->GetTabsNum(); i++) { CDockablePane* pBar = DYNAMIC_DOWNCAST(CDockablePane, pTabWnd->GetTabWnd(i)); if (pBar != NULL) { ASSERT_VALID(pBar); //将关闭消息加入该DockPane队列,等待完成本函数后关闭 ::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))) { //将关闭消息加入该DockPane队列,等待完成本函数后关闭 ::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("未能创建%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("未能创建%s窗口\n", strPropertiesWnd); return; } m_wndDataGridPanel.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndDataGridPanel); m_bDataGridShow = FALSE; } RecalcLayout(); }
5、设置视图的标签标题文字
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("称重数据区")); // TODO: 在此添加专用代码和/或调用基类 }
6、改变视图的背景颜色
BOOL CScale3DCScaleWeightView::OnEraseBkgnd(CDC* pDC) { // TODO: 在此添加消息处理程序代码和/或调用默认值 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、在一个视图中创建另一个视图
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("主控界面区") == strCaption) { CView * pView= pChildFrame->GetActiveView(); //消息发向主控视图 pView->SendMessage(WM_STARTSCALEWEIGHTVIEW, 0, 0); return; } pFrame->MDINext(); pChildFrame = pFrame->MDIGetActive(); } while (pChildFrame != pOldChildFrame); } } }