📄 fengmiandlg.cpp
字号:
// FengmianDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Yornik1.h"
#include "FengmianDlg.h"
#include "msword9.h"
#include"excel9.h"
#include <AtlBase.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFengmianDlg dialog
extern CString combo[8];
CFengmianDlg::CFengmianDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFengmianDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFengmianDlg)
m_id = _T("");
m_danwei = _T("");
m_name = _T("");
m_address = _T("");
m_datetime = _T("");
//}}AFX_DATA_INIT
}
void CFengmianDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFengmianDlg)
DDX_Text(pDX, IDC_EDIT1, m_id);
DDX_Text(pDX, IDC_EDIT2, m_danwei);
DDX_Text(pDX, IDC_EDIT3, m_name);
DDX_Text(pDX, IDC_EDIT4, m_address);
DDX_Text(pDX, IDC_EDIT5, m_datetime);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFengmianDlg, CDialog)
//{{AFX_MSG_MAP(CFengmianDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFengmianDlg message handlers
void CFengmianDlg::OnButton1()
{
UpdateData(true);
CString datetime;
m_datetime.Empty();
COleDateTime dt=COleDateTime::GetCurrentTime();
CString strDT=dt.Format("%Y年%m月%d日");
COleDateTime dt1=COleDateTime::GetCurrentTime();
CString strDT1=dt1.Format("YORNIK-%m%d-%H%S");
m_datetime=strDT;
m_id=strDT1;
_Applications app;
COleVariant vTrue((short)TRUE), vFalse((short)FALSE);
COleVariant vtOpn(DISP_E_PARAMNOTFOUND, VT_ERROR);
COleVariant varstrNull("");
COleVariant varFilePath("d:\\Yornik2\\输出文件\\封面1");
app.CreateDispatch(_T("Word.Application"));
app.SetVisible(true);
//Create New Doc
Documents docs=app.GetDocuments();
CComVariant tpl(_T("")),Visble,DocType(0),NewTemplate(false);
//docs.Open(varFilePath,vFalse,vFalse,COleVariant(""),vFalse, COleVariant(""),vFalse,vFalse,vFalse,vFalse,vFalse);
docs.Add(&tpl,&NewTemplate,&DocType,&Visble);
//Add Content:Text
Selection sel=app.GetSelection();
_Font font;
/*font=sel.GetFont();
font.SetName("黑体");
font.SetBold(false);
font.SetSize(28);*/
sel.TypeText(_T("\n\n\t\t"));
InlineShapes lineShapes1 = sel.GetInlineShapes();
InlineShape lineShape1 = lineShapes1.AddPicture("D:\\Yornik2\\res\\b.bmp", &vFalse, &vTrue, &vtOpn);
sel.TypeText(_T("\n"));
//sel.SetFont(font);
font=sel.GetFont();
font.SetName("黑体");
font.SetBold(false);
font.SetSize(28);
//sel.TypeText(_T("\t\t\t约能热泵集中供热水系统\r\n"));
sel.TypeText(_T("\t\t\tYornik Heat Pump System\n"));
sel.TypeText(_T("\t\t\t\t\t\t"));
InlineShapes lineShapes = sel.GetInlineShapes();
InlineShape lineShape = lineShapes.AddPicture("D:\\Yornik2\\res\\a.bmp", &vFalse, &vTrue, &vtOpn);
font=sel.GetFont();
font.SetName("宋体");
font.SetBold(false);
font.SetSize(15);
sel.TypeText(_T("\n\n"));
sel.TypeText(_T("项目编号:"));
sel.TypeText(m_id);
sel.TypeText(_T("\n"));
sel.TypeText(_T("建设单位:"));
sel.TypeText(m_danwei);
sel.TypeText(_T("\n"));
sel.TypeText(_T("项目名称:"));
sel.TypeText(m_name);
sel.TypeText(_T("\n"));
sel.TypeText(_T("项目地址:"));
sel.TypeText(m_address);
sel.TypeText(_T("\n\n\n\n\n\n\n"));
sel.TypeText(_T("热泵制造商:广州市约能热能技术有限公司"));
sel.TypeText(_T("\n"));
sel.TypeText(_T("系统制集成:广州市约能热能技术有限公司"));
sel.TypeText(_T("\n"));
sel.TypeText(_T("地 址:广州新港西路135号中山大学海珠科技园1102室"));
sel.TypeText(_T("\n"));
sel.TypeText(_T("日 期:"));
sel.TypeText(m_datetime);
sel.TypeText(_T("\n"));
//combo[5]=m_name;
_Document doc;
doc = app.GetActiveDocument();
doc.SaveAs(varFilePath,vFalse,vFalse,COleVariant(""),vFalse, COleVariant(""),vFalse,vFalse,vFalse,vFalse,vFalse);
//doc.Close();
//docs.Close();
app.Quit(vtOpn,vtOpn,vtOpn);
//保存word文档
/*docs = app.GetActiveDocument();
docs.SaveAs(COleVariant("d:\\Yornik2\\EXCEL文件\\封面.doc"),
COleVariant((short)0),
vFalse, COleVariant(""), vTrue, COleVariant(""),
vFalse, vFalse, vFalse, vFalse, vFalse);*/
//doc.ReleaseDispatch();//断开关联;
//app.SetVisible(TRUE);
//sel.ReleaseDispatch();
//docs.ReleaseDispatch();
//app.SetVisible(TRUE);
//app.ReleaseDispatch();
UpdateData(FALSE);
}
void CFengmianDlg::OnTimer(UINT nIDEvent)
{
UpdateData(true);
combo[5]=m_name;
CDialog::OnTimer(nIDEvent);
}
BOOL CFengmianDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_tooltip3.Create(this);
m_tooltip3.AddTool(GetDlgItem(IDC_BUTTON1), _T("<b><ct=0x0000FF><al_c>文件存放在D:\\Yornik2\\输出文件 目录下</b>"));
SetTimer(1,100,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFengmianDlg::fengmian()
{
UpdateData(true);
CString datetime;
m_datetime.Empty();
COleDateTime dt=COleDateTime::GetCurrentTime();
CString strDT=dt.Format("%Y年%m月%d日");
COleDateTime dt1=COleDateTime::GetCurrentTime();
CString strDT1=dt1.Format("yornik-%Y%m%d-%H%S号");
m_datetime=strDT;
m_id=strDT1;
_Applications app;
COleVariant vTrue((short)TRUE), vFalse((short)FALSE);
COleVariant vtOpn(DISP_E_PARAMNOTFOUND, VT_ERROR);
COleVariant varstrNull("");
COleVariant varFilePath("d:\\Yornik2\\EXCEL文件\\封面");
app.CreateDispatch(_T("Word.Application"));
app.SetVisible(true);
//Create New Doc
Documents docs=app.GetDocuments();
CComVariant tpl(_T("")),Visble,DocType(0),NewTemplate(false);
//docs.Open(varFilePath,vFalse,vFalse,COleVariant(""),vFalse, COleVariant(""),vFalse,vFalse,vFalse,vFalse,vFalse);
docs.Add(&tpl,&NewTemplate,&DocType,&Visble);
//Add Content:Text
Selection sel=app.GetSelection();
_Font font;
/*font=sel.GetFont();
font.SetName("黑体");
font.SetBold(false);
font.SetSize(28);*/
sel.TypeText(_T("\t\t"));
InlineShapes lineShapes1 = sel.GetInlineShapes();
InlineShape lineShape1 = lineShapes1.AddPicture("D:\\Yornik2\\res\\b.bmp", &vFalse, &vTrue, &vtOpn);
sel.TypeText(_T("\n\n"));
//sel.SetFont(font);
font=sel.GetFont();
font.SetName("黑体");
font.SetBold(false);
font.SetSize(28);
//sel.TypeText(_T("\t\t\t约能热泵集中供热水系统\r\n"));
sel.TypeText(_T("\t\t\tYornik Heat Pump System\n"));
sel.TypeText(_T("\t\t\t\t\t\t"));
InlineShapes lineShapes = sel.GetInlineShapes();
InlineShape lineShape = lineShapes.AddPicture("D:\\Yornik2\\res\\a.bmp", &vFalse, &vTrue, &vtOpn);
font=sel.GetFont();
font.SetName("宋体");
font.SetBold(false);
font.SetSize(15);
sel.TypeText(_T("\n\n"));
sel.TypeText(_T("项目编号:"));
sel.TypeText(m_id);
sel.TypeText(_T("\n"));
sel.TypeText(_T("建设单位:"));
sel.TypeText(m_danwei);
sel.TypeText(_T("\n"));
sel.TypeText(_T("项目名称:"));
sel.TypeText(m_name);
sel.TypeText(_T("\n"));
sel.TypeText(_T("项目地址:"));
sel.TypeText(m_address);
sel.TypeText(_T("\n\n\n\n\n\n"));
sel.TypeText(_T("热泵制造商:广州市约能热能技术有限公司"));
sel.TypeText(_T("\n"));
sel.TypeText(_T("系统制集成:广州市约能热能技术有限公司"));
sel.TypeText(_T("\n"));
sel.TypeText(_T("地 址:广州新港西路135号中山大学海珠科技园1102室"));
sel.TypeText(_T("\n"));
sel.TypeText(_T("日 期:"));
sel.TypeText(m_datetime);
sel.TypeText(_T("\n"));
//combo[5]=m_name;
_Document doc;
doc = app.GetActiveDocument();
doc.SaveAs(varFilePath,vFalse,vFalse,COleVariant(""),vFalse, COleVariant(""),vFalse,vFalse,vFalse,vFalse,vFalse);
//doc.Close();
//docs.Close();
app.Quit(vtOpn,vtOpn,vtOpn);
//保存word文档
/*docs = app.GetActiveDocument();
docs.SaveAs(COleVariant("d:\\Yornik2\\EXCEL文件\\封面.doc"),
COleVariant((short)0),
vFalse, COleVariant(""), vTrue, COleVariant(""),
vFalse, vFalse, vFalse, vFalse, vFalse);*/
//doc.ReleaseDispatch();//断开关联;
//app.SetVisible(TRUE);
//sel.ReleaseDispatch();
//docs.ReleaseDispatch();
//app.SetVisible(TRUE);
//app.ReleaseDispatch();
UpdateData(FALSE);
}
BOOL CFengmianDlg::PreTranslateMessage(MSG* pMsg)
{
m_tooltip3.RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -