📄 wordglxtdlg.cpp
字号:
// WordGLXTDlg.cpp : implementation file
//
#include "stdafx.h"
#include "WordGLXT.h"
#include "WordGLXTDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWordGLXTDlg dialog
CWordGLXTDlg::CWordGLXTDlg(CWnd* pParent /*=NULL*/)
: CDialog(CWordGLXTDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CWordGLXTDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDI_CHILDICON4);
}
void CWordGLXTDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWordGLXTDlg)
DDX_Control(pDX, IDC_RICHEDIT1, m_richedit);
DDX_Control(pDX, IDC_TREE1, m_tree);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWordGLXTDlg, CDialog)
//{{AFX_MSG_MAP(CWordGLXTDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_MENUDWDAN, OnMenudwdan)
ON_COMMAND(ID_MENUWDLB, OnMenuwdlb)
ON_NOTIFY(NM_DBLCLK, IDC_TREE1, OnDblclkTree1)
ON_COMMAND(ID_MENULIULWD, OnMenuliulwd)
ON_COMMAND(ID_MENUYHGL, OnMenuyhgl)
ON_COMMAND(ID_MENUMODPWD, OnMenumodpwd)
ON_COMMAND(ID_MENUADDWD, OnMenuaddwd)
ON_COMMAND(ID_MENUDELWD, OnMenudelwd)
ON_COMMAND(ID_MENUMODWD, OnMenumodwd)
ON_COMMAND(ID_MENURZGL, OnMenurzgl)
ON_COMMAND(ID_EXIT, OnExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWordGLXTDlg message handlers
BOOL CWordGLXTDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CDialogin gin;
if(gin.DoModal()!=IDOK)
OnOK();
dwb.Load_dep();
mlb.Load_dep();
xxb.Load_dep();
m_treeImageList.Create(16,16,ILC_MASK,4,1);
m_treeImageList.Add(theApp.LoadIcon(IDI_ROOTICON));
m_treeImageList.Add(theApp.LoadIcon(IDI_CHILDICON1));
m_treeImageList.Add(theApp.LoadIcon(IDI_CHILDICON2));
m_treeImageList.Add(theApp.LoadIcon(IDI_CHILDICON4));
m_tree.SetImageList(&m_treeImageList,LVSIL_NORMAL);
m_root=m_tree.InsertItem("基本信息管理",0,0);
AddtoTree(m_root);
m_tree.Expand(m_root,TVE_EXPAND);
m_StatusBar.EnableAutomation();
m_StatusBar.Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0),this,0);
int width[]={200,400};
m_StatusBar.SetParts(4, &width[0]);
m_StatusBar.SetText("吉林省明日科技有限公司",0,0);
CString StatusText;
StatusText.Format("当前用户:%s",user.GetUsername());
m_StatusBar.SetText(StatusText,0,1);
t=CTime::GetCurrentTime();
CString strdate;
strdate.Format("当前日期:%s",t.Format("%y-%m-%d"));
m_StatusBar.SetText(strdate,0,2);
return TRUE; // return TRUE unless you set the focus to a control
}
void CWordGLXTDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CWordGLXTDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CWordGLXTDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CWordGLXTDlg::AddtoTree(HTREEITEM m_node)
{
int i,j;
for(i=0;i<dwb.a_DWbh.GetSize();i++)
{
arrays[i]=m_tree.InsertItem(dwb.a_DWmc.GetAt(i),1,1,m_node);
for(j=0;j<mlb.a_DWbh.GetSize();j++)
{
if(atoi(dwb.a_DWbh.GetAt(i))==atoi(mlb.a_DWbh.GetAt(j)))
{
brrays[j]=m_tree.InsertItem(mlb.a_LBmc.GetAt(j),2,2,arrays[i]);
}
}
}
for(i=0;i<xxb.a_WDbh.GetSize();i++)
{
for(j=0;j<mlb.a_DWbh.GetSize();j++)
{
if(atoi(xxb.a_DWbh.GetAt(i))==atoi(mlb.a_DWbh.GetAt(j))&&atoi(xxb.a_LBbh.GetAt(i))==atoi(mlb.a_LBbh.GetAt(j)))
{
CString str = xxb.a_WDmc.GetAt(i);
hitem[i]=m_tree.InsertItem(xxb.a_WDmc.GetAt(i),3,3,brrays[j]);
}
}
}
m_tree.SetRedraw();
}
void CWordGLXTDlg::OnMenudwdan()
{
// TODO: Add your command handler code here
CDwdandlg dlg;
if(dlg.DoModal()==IDOK)
{
m_tree.DeleteAllItems();
dwb.Load_dep();
mlb.Load_dep();
xxb.Load_dep();
m_root=m_tree.InsertItem("基本信息管理",0,0);
AddtoTree(m_root);
}
}
void CWordGLXTDlg::OnMenuwdlb()
{
// TODO: Add your command handler code here
CWdlbiedlg dlg;
if(dlg.DoModal()==IDOK)
{
m_tree.DeleteAllItems();
dwb.Load_dep();
mlb.Load_dep();
xxb.Load_dep();
m_root=m_tree.InsertItem("基本信息管理",0,0);
AddtoTree(m_root);
}
}
void CWordGLXTDlg::OnDblclkTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString strWjian="";
//读取当前节点
temp = m_tree.GetSelectedItem();
//将当前节点子节点付给temp
temp = m_tree.GetChildItem(temp);
if (temp != NULL)
{
while (temp!= NULL)
{
//取出temp中的文本
strText = m_tree.GetItemText(temp);
strWjian+=strText+"\n";
//RichEdit控件显示数据
m_richedit.SetWindowText(strWjian);
//将temp的兄弟节点付给temp
temp = m_tree.GetNextItem(temp,TVGN_NEXT);
}
}
else
{
temp = m_tree.GetSelectedItem();
for(int i=0;i<xxb.a_WDbh.GetSize();i++)
{
if(temp==hitem[i])
{
//取出temp对应的文档路径
strWord=xxb.a_WJlj.GetAt(i);
}
}
//word应用程序
_Application app;
//初始化连接
app.CreateDispatch("word.Application");
Documents doc;
CComVariant a (_T(strWord)),b(false),c(0),d(true),aa(0),bb(1);
_Document doc1;
doc.AttachDispatch( app.GetDocuments());
doc1.AttachDispatch(doc.Add(&a,&b,&c,&d));
Range range;
//求出文档的所选区域
range = doc1.GetContent();//取出文件内容
str = range.GetText();
m_richedit.SetWindowText(str);
//关闭
app.Quit(&b,&c,&c);
//释放环境
app.ReleaseDispatch();
}
*pResult = 0;
}
void CWordGLXTDlg::OnMenuliulwd()
{
// TODO: Add your command handler code here
CString strd,strs;
xxb.Load_dep();
for(int i=0;i<xxb.a_WDbh.GetSize();i++)
{
strd=xxb.a_WDmc.GetAt(i);
strs+=strd+"\n";
m_richedit.SetWindowText(strs);
}
}
void CWordGLXTDlg::OnMenuyhgl()
{
// TODO: Add your command handler code here
if(user.GetJB()=="1")
{
CYHgldlg dlg;
dlg.DoModal();
}
else
{
MessageBox("没有权限","文档管理系统");
return;
}
}
void CWordGLXTDlg::OnMenumodpwd()
{
// TODO: Add your command handler code here
CKLxgdlg dlg;
dlg.DoModal();
}
void CWordGLXTDlg::OnMenuaddwd()
{
// TODO: Add your command handler code here
CWDgldlg dlg;
dlg.str = 0;
if(dlg.DoModal()==IDOK)
{
m_tree.DeleteAllItems();
dwb.Load_dep();
mlb.Load_dep();
xxb.Load_dep();
m_root=m_tree.InsertItem("基本信息管理",0,0);
AddtoTree(m_root);
}
}
void CWordGLXTDlg::OnMenudelwd()
{
// TODO: Add your command handler code here
CWDgldlg dlg;
dlg.tabindex = 1;
if(dlg.DoModal()==IDOK)
{
m_tree.DeleteAllItems();
dwb.Load_dep();
mlb.Load_dep();
xxb.Load_dep();
m_root=m_tree.InsertItem("基本信息管理",0,0);
AddtoTree(m_root);
}
}
void CWordGLXTDlg::OnMenumodwd()
{
// TODO: Add your command handler code here
CWDgldlg dlg;
dlg.str = 1;
if(dlg.DoModal()==IDOK)
{
m_tree.DeleteAllItems();
dwb.Load_dep();
mlb.Load_dep();
xxb.Load_dep();
m_root=m_tree.InsertItem("基本信息管理",0,0);
AddtoTree(m_root);
}
}
void CWordGLXTDlg::OnMenurzgl()
{
// TODO: Add your command handler code here
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
CString sql,sqlzd="用户名 \t登录时间\t动作\n";
sql.Format("select* from Rizhib");
m_AdoConn.GetRecordSet((_bstr_t)sql);
while(m_AdoConn.m_pRecordset->adoEOF==0)
{
sqlzd+=(char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("name");
sqlzd+=" \t";
sqlzd+=(char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("DLsj");
sqlzd+="\t";
sqlzd+=(char*)(_bstr_t)m_AdoConn.m_pRecordset->GetCollect("dz");
sqlzd+="\n";
m_AdoConn.m_pRecordset->MoveNext();
m_richedit.SetWindowText(sqlzd);
}
m_AdoConn.ExitConnect();
}
void CWordGLXTDlg::OnExit()
{
// TODO: Add your command handler code here
OnOK();
}
BOOL CWordGLXTDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==13)
pMsg->wParam=9;
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -