📄 mainfrm.cpp
字号:
//主框架
#include "stdafx.h"
#include "resource.h"
#include "aboutdlg.h"
#include "MainFrm.h"
#include "windows.h"
#include <atlframe.h>
#include <atlctrls.h>
#include <atldlgs.h>
#include <atlmisc.h>
#include <atlsplit.h>
#include <atlctrlx.h>
#include "mainfrm.h"
#include "NEWMAILDIALOG.h"
#include "xmldata.h"
#include ".\mainfrm.h"
#include <stdlib.h>
#include ".\UploadDialog.h"
#include ".\encodedialog.h"
#include ".\AlterDialog.h"
using namespace WTL;
using namespace std;
//
extern CXMLDATA XmlData;
//
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
return CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg);
}
BOOL CMainFrame::OnIdle()
{
return FALSE;
}
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CreateSimpleStatusBar();
UISetCheck(ID_VIEW_TOOLBAR, 1);
UISetCheck(ID_VIEW_STATUS_BAR, 1);
// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
//
m_hWndClient = CreateClient();
CenterWindow();
//
::SetWindowText (m_edit.m_hWnd ,"请到论坛 http://biqiong.bbs.fangwen.com/ 获取共享信息。");
//
return 0;
}
LRESULT CMainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
PostMessage(WM_CLOSE);
return 0;
}
LRESULT CMainFrame::OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: add code to initialize document
return 0;
}
LRESULT CMainFrame::OnViewToolBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
BOOL bVisible = !::IsWindowVisible(m_hWndToolBar);
::ShowWindow(m_hWndToolBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE);
UISetCheck(ID_VIEW_TOOLBAR, bVisible);
UpdateLayout();
return 0;
}
LRESULT CMainFrame::OnViewStatusBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
BOOL bVisible = !::IsWindowVisible(m_hWndStatusBar);
::ShowWindow(m_hWndStatusBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE);
UISetCheck(ID_VIEW_STATUS_BAR, bVisible);
UpdateLayout();
return 0;
}
LRESULT CMainFrame::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CAboutDlg dlg;
dlg.DoModal();
return 0;
}
HWND CMainFrame::CreateClient()
{
// vertical splitter setup
// client rect for vertical splitter
WTL::CRect rcVert;
GetClientRect(&rcVert);
// create the vertical splitter
m_vSplit.Create(m_hWnd, rcVert, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
//将全部的客户区域分隔成左右两部分
// set the vertical splitter parameters
m_vSplit.m_cxyMin = 35; // minimum size
m_vSplit.SetSplitterPos(200); // from left
m_vSplit.m_bFullDrag = false; // ghost bar enabled
// horizontal splitter setup
// client rect for horizontal splitter
WTL::CRect rcHorz;
GetClientRect(&rcHorz);
// create the horizontal splitter. Note that vSplit is parent of hzSplit
m_hzSplit.Create(m_vSplit.m_hWnd, rcHorz, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
// set the horizontal splitter parameters
m_hzSplit.m_cxyMin = 35; // minimum size
m_hzSplit.SetSplitterPos(400); // from top
m_hzSplit.m_bFullDrag = false; // ghost bar enabled
// add the horizontal splitter to right pane of vertical splitter
m_vSplit.SetSplitterPane(1, m_hzSplit);
// left pane container setup
// create the left container
m_lPane.Create(m_vSplit.m_hWnd);
m_lPane.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON);
// add container to left pane (0) of vertical splitter
m_vSplit.SetSplitterPane(0, m_lPane);
// set the left pane title
m_lPane.SetTitle("请选择要登陆的邮箱");
// top pane container setup
// create the top container. Note use of hzSplit as parent
m_tPane.Create(m_hzSplit.m_hWnd);
// add container to top pane (0) of horizontal splitter
m_hzSplit.SetSplitterPane(0, m_tPane);
// set the top pane title
m_tPane.SetTitle("请选择要下载的文件");
// remove the close button from the top container
m_tPane.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON);
// bottom pane container setup
// create the bottom container. Note hzSplit is parent
m_bPane.Create(m_hzSplit.m_hWnd);
m_bPane.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON);
m_bPane.SetTitle("程序信息");
// add container to bottom pane (1) of horizontal splitter
m_hzSplit.SetSplitterPane(1, m_bPane);
// set the bottom container's header style to vertical
//m_bPane.SetPaneContainerExtendedStyle(PANECNT_VERTICAL);
// create an edit. Note that m_bPane is the parent. Set
// the edit's font and place text in it
m_edit.Create(m_bPane.m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
m_edit.SetFont((HFONT)GetStockObject(DEFAULT_GUI_FONT), TRUE);
//m_edit.SetWindowText(" Bottom Pane -- with vertical header and edit as child");
// assign the edit to the bottom container
m_bPane.SetClient(m_edit.m_hWnd);
m_lListView.Create (m_lPane.m_hWnd ,rcDefault);
m_lPane.SetClient (HWND(m_lListView));
m_tListView.Create (m_tPane.m_hWnd ,rcDefault);
m_tPane.SetClient (HWND(m_tListView));
m_lListView.Init();
m_tListView.Init();
m_lListView.hwndDownLoadFileList=(HWND)m_tListView;
m_lListView.hwndEdit=m_edit.m_hWnd ;
m_lListView.hwndMain=this->m_hWnd ;
m_tListView.hwndMain=this->m_hWnd ;
m_tListView.hwndEdit=m_edit.m_hWnd ;
return m_vSplit.m_hWnd;
}
LRESULT CMainFrame::OnLogInItem(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
if(::GetFocus ()==(HWND)m_lListView)
{
::SendMessage ((HWND)m_lListView,WM_LBUTTONDBLCLK,NULL,NULL);
}
return 0;
}
LRESULT CMainFrame::OnDownloadItem(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
if(::GetFocus ()==(HWND)m_tListView)
{
::SendMessage ((HWND)m_tListView,WM_LBUTTONDBLCLK,NULL,NULL);
}
return 0;
}
LRESULT CMainFrame::OnAddNewYahooEmail(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加命令处理程序代码
int len=XmlData.VName .size ();
CNewMailDialog newmail;
newmail.DoModal ();
if(len==XmlData.VName .size ())
{
::SetWindowText (m_edit.m_hWnd ,"添加新邮箱失败");
}
else
{
::SetWindowText (m_edit.m_hWnd ,"添加新邮箱成功");
}
XmlData.WriteData ();
m_lListView.LoadXmlData();
return 0;
}
LRESULT CMainFrame::OnToolEncode(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加命令处理程序代码
CEncodeDialog ed;
ed.DoModal ();
return 0;
}
LRESULT CMainFrame::OnToolDescribe(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加命令处理程序代码
CUploadDialog ud;
ud.DoModal ();
return 0;
}
LRESULT CMainFrame::OnDeleteYahooMailByItem(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加命令处理程序代码
if(::GetFocus ()==(HWND)m_lListView)
{
m_lListView.DeleteTheItem();
m_lListView.LoadXmlData();
}
return 0;
}
LRESULT CMainFrame::OnDownloadAllitem(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: 在此添加命令处理程序代码
m_tListView.DownLoadAllFile();
return 0;
}
LRESULT CMainFrame::OnContextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam/*lParam*/, BOOL& /*bHandled*/)
{
//::MessageBox (NULL,NULL,NULL,NULL);
//开始添加快捷菜单
return 0;
}
LRESULT CMainFrame::OnToolAlter(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CAlterDialog ad;
ad.DoModal ();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -