MainFrm.cpp
上传用户:szcysw
上传日期:2013-03-11
资源大小:6752k
文件大小:11k
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "TaxExpert.h"
- #include "resource.h"
- #include "TaxExpertView.h"
- #include "Splash.h"
- #include "MainFrm.h"
- #include "FolderListView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_CREATE()
- ON_COMMAND(ID_PREVIEW_PANE, OnPreviewPane)
- ON_UPDATE_COMMAND_UI(ID_PREVIEW_PANE, OnUpdatePreviewPane)
- ON_WM_DESTROY()
- ON_MESSAGE(WM_INTERACTIVE_WITH_FRAME,InteractiveWithViews)
- ON_COMMAND(ID_UPDATE, update)
- ON_COMMAND(ID_USER, UserDefine)
- ON_COMMAND(ID_OUTPUTWORD, InputIntoWord)
- ON_COMMAND(ID_FILE_PRINT_FRAME, PrintDoc)
- ON_MESSAGE(WM_OUTBAR_NOTIFY, OnOutbarNotify)
- //ON_MESSAGE(CBN_SELCHANGE, ID_PLACEHOLDER, OnComboTextChanged)
- ON_COMMAND(CBN_SELCHANGE,OnComboTextChanged)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
-
- m_bPreview = 1;
-
-
-
- }
- //处理从子窗口收到的信息
- #include "ContainerView.h"
- #include "top1.h"
- void CMainFrame::InteractiveWithViews(WPARAM FromWhere,LPARAM detail)
- {
- //如果是从树形视图送来的消息,表明需要进行分类查找
- if(FromWhere==ID_FROM_FOLDERVIEW)
- {
- //调用CTop完成查询
- CTop* view=(CTop*)(GetMainView()->m_wndSplitter2.GetPane(0,0));
- ::SendMessage(view->m_hWnd,WM_RECONSTRUCT,0,(LPARAM)(LPCSTR)detail);
- return;
- }
-
- //如果是从列表视图送过来的消息,直接调用CContainerView进行显示
- if(FromWhere==ID_FROM_LIST)
- {
- //确认CContainerView已经打开
- if(!(m_bPreview))
-
- {
- GetMainView()->m_wndSplitter2.ShowRow();
- m_bPreview = !m_bPreview;
- }
- CString strURL((LPSTR)(LPCSTR)detail);
- //查找出CContainerView,进行strURL文件的显示
- CContainerView* htmlview=(CContainerView*)(GetMainView()->m_wndSplitter2.GetPane(1,0));
- htmlview->Navigate(strURL);
-
- }
- return;
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
-
- lpCreateStruct->hMenu=NULL;
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1; // fail to create
- }
-
- // 在工具条中插入组合列表框
- m_pComboBox = (CCJFlatComboBox*)m_wndToolBar.InsertControl(RUNTIME_CLASS(CCJFlatComboBox),
- NULL, CRect(0,0,200,150), ID_PLACEHOLDER, CBS_DROPDOWN );
- m_pComboBox->AddString(_T("请在此输入查询内容"));
- m_pComboBox->SetCurSel(0);
- m_pComboBox->EnableAutoCompletion();
-
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- // CG: The following line was added by the Splash Screen component.
CSplashWnd::ShowSplashScreen(this);
- //设置当前窗口的标记,避免同一窗口同时运行
- ::SetProp(m_hWnd,"660E72B2-6BF7-4897-8EF2-9C33FBC49564", (HANDLE)1);
- CenterWindow();
- ShowWindow(SW_MAXIMIZE);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- //禁用菜单
- cs.hMenu=NULL;
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- CString shortcut[6]={
- "税收政策",
- "税务征管",
- "财政法规",
- "涉税法规",
- "纳税辅导",
- "用户自定义"};
- CString tax[20]={
- "增值税",
- "消费税",
- "营业税",
- "企业所得税(内资)",
- "企业所得税(外资)",
- "个人所得税",
- "资源税",
- "城建税",
- "印花税",
- "车船使用税",
- "屠宰税",
- "城镇土地使用税",
- "房产税",
- "土地增值税",
- "农业税",
- "农业特产税",
- "契税",
- "车辆购置税",
- "车船牌照使用税",
- "固定资产投资方向调节税(停征)"
- };
- CString swgl[8]={
- " 税收征收管理",
- "税务检查",
- "税务代理",
- "出口退税",
- "进出口税收",
- "涉外税收",
- "税收协定",
- "其他杂项",
- };
- //创建切切窗口、初始化快捷方式列表框
- BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
- {
- // 将窗口切分成1行一两列
- if (!m_wndSplitter.CreateStatic(this, 1, 2))
- {
- TRACE0("Failed to create splitter windown");
- return FALSE;
- }
- // 第二列窗口的类视图为CTaxExpertView
- if (!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CTaxExpertView),
- CSize(0, 0), pContext))
- {
- TRACE0("Failed to create CTaxExpertViewn");
- return FALSE;
- }
- //设置建立m_wndOutlookBar外观
- DWORD dwStyle =
- CGfxOutBarCtrl::fDragItems |
- CGfxOutBarCtrl::fEditGroups |
- CGfxOutBarCtrl::fEditItems |
- CGfxOutBarCtrl::fRemoveGroups |
- CGfxOutBarCtrl::fRemoveItems |
- CGfxOutBarCtrl::fAddGroups |
- CGfxOutBarCtrl::fAnimation;
-
- // 建立m_wndOutlookBar控件
- if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0),
- &m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 0), dwStyle))
- {
- TRACE0("Failed to create outlook bar.");
- return FALSE;
- }
-
- // m_wndOutlookBar控件的父窗口设置成窗口框架
- m_wndOutlookBar.SetOwner(this);
-
- // 为列表控件装入图像列表:大图标和小图标
- m_ImageSmall.Create (16, 16, TRUE, 2, 1);
- m_ImageLarge.Create (32, 32, TRUE, 2, 1);
-
- for( int nIcon = IDI_ICON_OUTLOOK; nIcon <= IDI_ICON_PUBLIC; ++nIcon )
- {
- HICON hIcon = AfxGetApp()->LoadIcon(nIcon);
- ASSERT(hIcon);
- m_ImageSmall.Add(hIcon);
- m_ImageLarge.Add(hIcon);
- }
-
- //设置m_wndOutlookBar控件的图像列表
- m_wndOutlookBar.SetImageList(&m_ImageLarge, CGfxOutBarCtrl::fLargeIcon);
- m_wndOutlookBar.SetImageList(&m_ImageSmall, CGfxOutBarCtrl::fSmallIcon);
- //设置列表项滑动速度
- m_wndOutlookBar.SetAnimationTickCount(20);
- m_wndOutlookBar.SetAnimSelHighlight(200);
-
- //添加快捷方式
- m_wndOutlookBar.AddFolder(shortcut[0], FOLDER_0);
- m_wndOutlookBar.AddFolder(shortcut[1], FOLDER_1);
- m_wndOutlookBar.AddFolder(shortcut[1], FOLDER_2);
- m_wndOutlookBar.AddFolder(shortcut[3], FOLDER_3);
- m_wndOutlookBar.AddFolder(shortcut[4], FOLDER_4);
- m_wndOutlookBar.AddFolder(shortcut[5], FOLDER_5);
-
- //添加快捷方式的子项:往“税收政策”项加入二十个税种
- for (int i=0;i<20;i++)
- //5:图标在图像列表中的索引值
- m_wndOutlookBar.InsertItem(FOLDER_0, CMD_00+i,tax[i], 5, i);
- for (i=0;i<8;i++)
- m_wndOutlookBar.InsertItem(FOLDER_1, CMD_00+i, swgl[i], 6, i);
- //当前选择项为1
- m_wndOutlookBar.SetSelFolder(0);
- CRect r;
- GetClientRect(&r);
- int w1 = r.Width()/7;
- int w2 = r.Width()/5;
- //设置m_wndOutlookBar大小
- m_wndSplitter.SetColumnInfo( 0, w1, 0 );
- m_wndSplitter.SetColumnInfo( 1, w2, 0 );
- m_wndSplitter.RecalcLayout();
- return TRUE;
- }
- /*OnOutbarNotify:负责响应来自m_wndOutlookBar控件的信息
- 当在m_wndOutlookBar上的选择发生变化是时,通知
- CFolderListView进行前选择项在更改
- */
- long CMainFrame::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
- {
- CTaxExpertView* view=(CTaxExpertView*)GetMainView();
- CFolderListView* TreeView=(CFolderListView* )(view->m_wndSplitter.GetPane(0,0));
- CWnd* wndTop=GetMainView()->m_wndSplitter2.GetPane( 0, 0);
-
- switch (wParam)
- {
- case NM_OB_ITEMCLICK:
- {
- // 得到当前选择的快捷方式
- int nFolder = m_wndOutlookBar.GetSelFolder();
- // 得到当前选择的子项
- int nIndex = (int)lParam;
- //得到CFolderListView的树形控件
- CCJTreeCtrl* pTreeCtrl = GetMainView()->GetFolderTreeCtrl();
- //可以对不同的快捷方式进行处理,这里只处理两个
- switch (nFolder)
- {
- case FOLDER_0:
- //让树形控件对应的子节点被选中
- pTreeCtrl->SelectItem(pTreeCtrl
- ->FindItem(tax[CMD_00+nIndex],0,0,1,TreeView->hti[0]));
- break;
- case FOLDER_1:
- pTreeCtrl->SelectItem(pTreeCtrl
- ->FindItem(swgl[CMD_00+nIndex],0,1,1,TreeView->hti[1]));
- break;
- }
- }
- return 0;
- }
- return 0;
- }
- void CMainFrame::OnGfxLargeicon()
- {
- m_wndOutlookBar.SetSmallIconView(false);
- }
- void CMainFrame::OnUpdateGfxLargeicon(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(!m_wndOutlookBar.IsSmallIconView());
- }
- void CMainFrame::OnGfxSmallicon()
- {
- m_wndOutlookBar.SetSmallIconView(true);
- }
- void CMainFrame::OnUpdateGfxSmallicon(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_wndOutlookBar.IsSmallIconView());
- }
- CTaxExpertView* CMainFrame::GetMainView()
- {
- CTaxExpertView* pView = DYNAMIC_DOWNCAST(CTaxExpertView, m_wndSplitter.GetPane(0,1));
- ASSERT_KINDOF(CTaxExpertView, pView);
- return pView;
- }
- void CMainFrame::OnPreviewPane()
- {
- if(m_bPreview) {
- GetMainView()->m_wndSplitter2.HideRow(1);
- }
- else {
- GetMainView()->m_wndSplitter2.ShowRow();
- }
- m_bPreview = !m_bPreview;
- }
- void CMainFrame::OnUpdatePreviewPane(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_bPreview);
- }
- void CMainFrame::OnDestroy()
- {
- CFrameWnd::OnDestroy();
- }
- /*
- 在编辑框中输入的关键词发生变化时的响应函数
- 根据输入的关键词,向CTop以送信息
- */
- void CMainFrame::OnComboTextChanged()
- {
- CString str;
- m_pComboBox->GetWindowText(str);
- //如果关键词内容没有发生变动
- if(str.Find("查询内容")!=-1)
- return;
- //将输入的关键词记录下来,作为列表的备选项
- m_pComboBox->AddString(str);
- //修改标题栏
- CTaxExpertView* pView= (CTaxExpertView*)(GetMainView());
- CString cap;
- cap="全文模糊查询,关键词:";
- cap+=""";
-
- //如果未在树形视图中指定查找的税种
- if(pView->current_sel_sub.IsEmpty())
- cap+=str+"""+"在所有类中";
- else
- cap+=str+"""+"在"+pView->current_sel_sub+"类之中";
- pView->m_Caption.UpdateCaption(cap,0);
-
- //如果查询内容包含有+号,将之转换成SQL语句
- CString tmp=str;
- tmp.Replace("+","*' AND content like'*");
- CString filter;
- filter="content like'*"+tmp+"*'";
- //如果选择有子类。则将查询范围限制在子类中
- if(!(pView->current_sel_sub.IsEmpty()))
- {
- filter+="AND [cata]=";
- filter+="'"+pView->current_sel_sub+"'";
- }
-
- if((m_bPreview))
-
- { //隐藏 CContainerView
- GetMainView()->m_wndSplitter2.HideRow(1);
- m_bPreview = !m_bPreview;
- }
-
- //查找出CTOP的窗口
- CWnd* CTOP=GetMainView()->m_wndSplitter2.GetPane(0,0);
- //向列表窗口发出重建命令
- ::SendMessage(CTOP->m_hWnd,WM_RECONSTRUCT,
- ID_FUZZY_FIND,(LPARAM)(LPCSTR)(filter));
- }
- #include "Splash.h"
- void CMainFrame::UserDefine()
- {
- MessageBox("为了你的法规库的稳定及超级链引用的正确,建议不要使用此功能!rnrn如果非要使用,请与作者联系,我会告诉你具体的办法!","抱歉",MB_ICONEXCLAMATION|MB_OK);
- }
- void CMainFrame::update()
- {
- MessageBox("请与作者联系升级事宜。请在电子邮件注明你的注册号!","提示",MB_ICONEXCLAMATION|MB_OK);
- }
- void CMainFrame::InputIntoWord()
- {
- MessageBox("请在文档中单击右键将文档全部选中,复制文档rnrn之后在WORD中进行粘贴即可。","提示",MB_ICONEXCLAMATION|MB_OK);
- }
- void CMainFrame::PrintDoc()
- {
- MessageBox("请在文档中单击右键,选择"打印"即可","提示",MB_ICONEXCLAMATION|MB_OK);
- }