积累的VC编程小技巧之打印相关

1.修改打印预览的ToolBar

为AFX_IDD_PREVIEW_TOOLBAR这个ID创建一个DialogBar。则系统就会用新创建的DialogBar代替系统默认的那个

2.关于打印

1.要打印哪个视就 
((CMainFrame*)AfxGetMainWnd())->m_wndSplitter.SetActivePane(...)

//要打印的那个视对应的Pane

2.有一个单文档工程,文档窗口被切分:左视图由CTreeView 的派生类管理,右视图由CListView 的派生类CMyListView(其为风格为LVS_REPORT)管理,我想为右视图添加打印和打印预览,我在MyListView.cpp中添加了
    ON_COMMAND(ID_FILE_PRINT,CListView::OnFilePrint) 
    ON_COMMAND(ID_FILE_PRINT_PREVIEW,CListView::OnFilePrintPreview)还有 
    BOOL CMyListView::OnPreparePrinting(CPrintInfo* pInfo) 
    { 
         // TODO: call DoPreparePrinting to invoke the Print dialog box 
         // return CListView::OnPreparePrinting(pInfo); 
         pInfo->SetMaxPage(2); 
         BOOL bret=DoPreparePrinting(pInfo); 
         pInfo->m_nNumPreviewPages=2; 
         return bret; 
    }

3. 下面是从MSDN中摘出来的一段,是用来改变消息路由的。用了这段代码之后,CView中的消息(菜单,控件,子窗口)将先被CMyShape类来处理。不知道你要的是不是这样的效果。 
    // This example illustrates extending the framework's standard command 
    // route from the view to objects managed by the view.  This example 
    // is from an object-oriented drawing application, similar to the 
    // DRAWCLI sample application, which draws and edits "shapes". 
    BOOL CMyView::OnCmdMsg(UINT nID, int nCode, void* pExtra, 
       AFX_CMDHANDLERINFO* pHandlerInfo) 
    { 
           // Extend the framework's command route from the view to 
           // the application-specific CMyShape that is currently selected 
           // in the view. m_pActiveShape is NULL if no shape object 
           // is currently selected in the view. 
           if ((m_pActiveShape != NULL) 
                && m_pActiveShape->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) 
             return TRUE; 
           // If the object(s) in the extended command route don't handle 
            // the command, then let the base class OnCmdMsg handle it. 
            return CView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); 
          } 
          // The command handler for ID_SHAPE_COLOR (menu command to change 
          // the color of the currently selected shape) was added to 
          // the message map of CMyShape (note, not CMyView) using ClassWizard.   
          // The menu item will be automatically enabled or disabled, depending 
          // on whether a CMyShape is currently selected in the view, that is, 
          // depending on whether CMyView::m_pActiveView is NULL.  It is not 
          // necessary to implement an ON_UPDATE_COMMAND_UI handler to enable 
          // or disable the menu item.   
      BEGIN_MESSAGE_MAP(CMyShape, CCmdTarget) 
       //{{AFX_MSG_MAP(CMyShape) 
       ON_COMMAND(ID_SHAPE_COLOR, OnShapeColor) 
       //}}AFX_MSG_MAP 
      END_MESSAGE_MAP() 
如果你只是想调用OnFilePrint( )函数,可以试一试下面的代码,就和调用其它类中的函数一样。 
CMDIFrameWnd *pFrame = 
             (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; 
// Get the active MDI child window. 
CMDIChildWnd *pChild = 
             (CMDIChildWnd *) pFrame->GetActiveFrame(); 
// or CMDIChildWnd *pChild = pFrame->MDIGetActive(); 
// Get the active view attached to the active MDI child 
// window. 
CMyView *pView = (CMyView *) pChild->GetActiveView(); 
pView->OnFilePrint( );

4.

void CMyReportView::OnFileOpen() 

char Filter[] = "Crystal Report files(*.rpt)|*.rpt|All files(*.*)|*.*||"; 
CRect rect; 
CFileDialog OpenDlg(TRUE,0,0,OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,(LPCTSTR)Filter,NULL); 
if(OpenDlg.DoModal()!=IDOK) ///显示文件对话框 
return; 
CString m_fName=OpenDlg.GetPathName(); ///取得文件名 
if(m_CrystalReport) 
m_CrystalReport.DestroyWindow(); 
GetClientRect(rect); 
///////////////////创建控件/////////////// 
if (!m_CrystalReport.Create(AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),WS_CHILD|WS_VISIBLE,rect,this,IDC_CRYSTALREPORT1)) 

AfxMessageBox("控件创建失败!"); 
return ; 

m_CrystalReport.SetWindowParentHandle((long)(this->m_hWnd));///设置父窗口 
m_CrystalReport.SetWindowBorderStyle(0); ///设置为没有边框 
m_CrystalReport.SetWindowLeft(0); ///左空间 
m_CrystalReport.SetWindowTop(0); ///顶部空间 
m_CrystalReport.SetWindowControls(FALSE); ///不显示工具条 
m_CrystalReport.SetReportFileName(m_fName); ///设置报表文件 
m_CrystalReport.SetWindowWidth(rect.Width()); ///设置窗口宽度 
m_CrystalReport.SetWindowHeight(rect.Height()); ///设置窗口高度 
m_CrystalReport.SetFormulas(0, "Company=\"VC知识库\""); ///将报表中的Company变量的值设置为VC知识库 
m_CrystalReport.SetDestination(0); ///设置输出对象是屏幕 
m_CrystalReport.PrintReport(); ///显示报表 

void CMyReportView::OnFilePrint() 

if(m_CrystalReport && m_CrystalReport.GetReportFileName() != "") 

m_CrystalReport.SetDestination(1); ///设置输出对象是打印机 
m_CrystalReport.PrintReport(); ///打印

}

代码转载自:https://pan.quark.cn/s/8ce4326d996e 对于在 CentOS 7 系统中修改网卡配置文件后无法使设置生效的情况,经过实践验证,可以通过使用 nmcli 命令来进行调整。完成修改之后,需要重新启动虚拟机以使更改生效,这样操作流程即告完成。如果设置仍然无法生效,则表明虚拟机在启动过程中所获取的 IP 地址配置并非针对 eth0,此时可以对其它网卡的配置文件进行修改或将其移除。在 CentOS 7 系统中,网络配置的管理机制与早期版本存在差异,主要体现为采用了 Network Manager 服务来负责网络接口的管理。在某些情形下,尽管修改了 `/etc/sysconfig/network-scripts` 目录下的 `ifcfg-eth0` 文件,但网络配置却未能即时生效。此类问题的发生通常源于 CentOS 7 采用了不同于以往的配置读取方法。接下来将具体阐述如何借助 nmcli 命令来处理这一挑战。 以 root 用户身份登录系统并打开终端界面。nmcli 是 Network Manager 提供的命令行界面工具,它支持在命令行环境下执行网络连接的建立、编辑、查询及管理任务。针对修改 eth0 网卡配置的需求,可以遵循以下步骤进行操作: 1. 导航至 `/etc/sysconfig/network-scripts` 目录: ``` cd /etc/sysconfig/network-scripts ``` 2. 检查该目录内是否存在 `ifcfg-eth0.bak` 文件,该备份文件可能是先前调整配置时遗留下来的,若存在可能造成冲突。若发现该文件,可以选择将其删除: ``` [root@localhost netw...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值