📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "MyInsaneBT.h"
#include "MainFrm.h"
#include "TaskDlg.h"
#include <MMSystem.h>
#include "SetProxyDlg.h"
#include "DataBase.h"
#include "CustomDlg.h"
#include "GeoHttpDown.h"
#include "MyInsaneBTView.h"
#include "BreakPointDown.h"
#pragma comment(lib, "winmm.lib")
#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_WM_SIZE()
ON_COMMAND(ID_MENU_ABOUT, OnMenuAbout)
ON_COMMAND(ID_MENU_ID_PORXY, OnMenuIdPorxy)
ON_COMMAND(ID_MENU_SET_PROXY, OnMenuSetProxy)
ON_UPDATE_COMMAND_UI(ID_MENU_ID_PORXY, OnUpdateMenuIdPorxy)
ON_WM_TIMER()
ON_COMMAND(ID_MENU_SETTING, OnMenuSetting)
ON_COMMAND(ID_MENU_PULS, OnMenuPuls)
ON_COMMAND(ID_EDIT_STOP, OnEditStop)
ON_COMMAND(ID_EDIT_START, OnEditStart)
ON_WM_CLOSE()
ON_COMMAND(ID_MENU_HIDE_SHOW, OnMenuHideShow)
ON_COMMAND(ID_MENU_EXIT, OnMenuExit)
ON_COMMAND(ID_MENU_XP, OnMenuXp)
ON_COMMAND(ID_MENU_Office2003, OnMENUOffice2003)
ON_COMMAND(ID_MENU_Luna, OnMENULuna)
ON_COMMAND(ID_MENU_SILVER, OnMenuSilver)
ON_COMMAND(ID_MENU_OBSIDIAN, OnMenuObsidian)
ON_UPDATE_COMMAND_UI(ID_MENU_XP, OnUpdateMenuXp)
ON_UPDATE_COMMAND_UI(ID_MENU_Office2003, OnUpdateMENUOffice2003)
ON_COMMAND(ID_MENU_START, OnMenuStart)
ON_UPDATE_COMMAND_UI(ID_MENU_START, OnUpdateMenuStart)
ON_COMMAND(ID_MENUEXIT, OnMenuexit)
ON_COMMAND(ID_MENU_DELETE_DOWN, OnMenuDeleteDown)
//}}AFX_MSG_MAP
ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize)
ON_REGISTERED_MESSAGE(BCGM_RESETTOOLBAR, OnToolbarReset)
ON_REGISTERED_MESSAGE(BCGM_TOOLBARMENU, OnToolbarContextMenu)
ON_MESSAGE(WM_STASRTDOWN,set_down_info)
ON_MESSAGE(WM_PALYSOUND,Play_Sound)
ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
ON_MESSAGE(WM_UPDATAPROGRESS,OnUpdataProgress)
ON_MESSAGE(MYWM_NOTIFYICON,OnMyIconNotify)
ON_MESSAGE(WM_DOWNLOAD_FINISH,OnDownLoadFinish)
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()
{
// TODO: add member initialization code here
m_ie_state = false;
m_is_user_porxy = false; //默认不用代理
m_default_proxy = NULL;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_Hide = true;
//获得配置文件路局
GetConfigPath();
ReadConfig();
m_MenuXP=false;
m_MenuOffice2003=false;
m_MenuOffiec2007_Laun=true;
m_MenuOffice2007_Silver=false;
m_MenuOffice2007_Obsidian=false;
m_AutoStart=false;
}
CMainFrame::~CMainFrame()
{
delete m_dropWnd;
m_dropWnd = NULL;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
CBCGPDockManager::SetDockMode (DT_STANDARD);
CBCGPToolBar::EnableQuickCustomization ();
CBCGPVisualManager::SetDefaultManager(RUNTIME_CLASS (CBCGPVisualManager2007));
//CBCGPVisualManager2007::SetStyle (CBCGPVisualManager2007::VS2007_ObsidianBlack);
//CBCGPVisualManager2007::SetStyle (CBCGPVisualManager2007::VS2007_Aqua);
//CBCGPVisualManager2007::SetStyle (CBCGPVisualManager2007::VS2007_Silver);
EnableAutoHideBars(CBRS_ALIGN_ANY);
CBCGPToolBar::EnableQuickCustomization ();
// TODO: Define your own basic commands. Be sure, that each pulldown
// menu have at least one basic command.
CList<UINT, UINT> lstBasicCommands;
lstBasicCommands.AddTail (ID_VIEW_TOOLBARS);
lstBasicCommands.AddTail (ID_FILE_NEW);
lstBasicCommands.AddTail (ID_FILE_OPEN);
lstBasicCommands.AddTail (ID_FILE_SAVE);
lstBasicCommands.AddTail (ID_FILE_PRINT);
lstBasicCommands.AddTail (ID_APP_EXIT);
lstBasicCommands.AddTail (ID_EDIT_CUT);
lstBasicCommands.AddTail (ID_EDIT_PASTE);
lstBasicCommands.AddTail (ID_EDIT_UNDO);
lstBasicCommands.AddTail (ID_APP_ABOUT);
lstBasicCommands.AddTail (ID_VIEW_TOOLBAR);
lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE);
CBCGPToolBar::SetBasicCommands (lstBasicCommands);
if (!m_wndMenuBar.Create (this))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC);
// 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_MAIN_TOOLBAR))
// {
// TRACE0("Failed to create toolbar\n");
// return -1; // fail to create
// }
//创建剪切版监视类
CRect rect(0,0,0,0);
if(!m_ClipBoard.Create("","",WS_CHILD,rect,this,36667))
{
TRACE0("Failed to create ClipBoard\n");
}
//m_wndToolBar.LoadTrueColorToolBar(32, IDB_BITMAP_TOOLBAR_HOT, IDB_BITMAP_TOOLBAR_NOR, IDB_BITMAP_TOOLBAR_DIS);
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
if (!m_workspace.Create (_T(""), this, CSize (200, 200),
TRUE /* Has gripper */, ID_VIEW_WORKSPACE,
WS_CHILD | WS_VISIBLE | CBRS_LEFT))
{
TRACE0("Failed to create workspace bar\n");
return -1; // fail to create
}
if (!m_outworkspace.Create (_T(""), this,CSize (100, 150),
TRUE, ID_VIEW_WORKSPACE+3,
WS_CHILD | WS_VISIBLE | CBRS_LEFT))
{
TRACE0("Failed to create workspace bar\n");
return -1; // fail to create
}
if (!m_Logworkspace.Create (_T(""), this, CSize (100, 150),
TRUE, ID_VIEW_WORKSPACE+2,
WS_CHILD | WS_VISIBLE | CBRS_LEFT))
{
TRACE0("Failed to create workspace bar\n");
return -1; // fail to create
}
//m_wndToolBar.SetWindowText (_T("标准"));
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
// m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_outworkspace.EnableDocking(CBRS_ALIGN_ANY);
m_Logworkspace.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndMenuBar);
//DockControlBar(&m_wndToolBar);
DockControlBar(&m_Logworkspace);
DockControlBar(&m_outworkspace,AFX_IDW_DOCKBAR_BOTTOM);
DockControlBar(&m_Logworkspace,AFX_IDW_DOCKBAR_BOTTOM);
m_Logworkspace.DockToWindow(&m_outworkspace,CBRS_ALIGN_RIGHT);
m_workspace.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_workspace);
//m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."));
CRect nRect;
nRect.left=382;
nRect.top=240;
nRect.right=38;
nRect.bottom=35;
m_dropWnd = new CGeoDropWin();
ASSERT_VALID(m_dropWnd);
m_dropWnd->CreateNew(nRect,this,0,0);
m_dropWnd->SetWindowPos(NULL,900,30,0,0,SWP_NOSIZE|SWP_NOACTIVATE);
m_dropWnd->ShowWindow(SW_HIDE);
m_dropWnd->CreateView();
m_dropWnd->ShowWindow(SW_SHOW);
//创建托盘
CreateNotifyIcon();
//获得代理信息
GetProxyInfo();
SetConfig();
return 0;
}
LRESULT CMainFrame::OnTrayNotification(WPARAM wParam,LPARAM lParam)
{
return m_TrayIcon.OnTrayNotification(wParam,lParam);
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
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
void CMainFrame::OnViewCustomize()
{
//------------------------------------
// Create a customize toolbars dialog:
//------------------------------------
CBCGPToolbarCustomize* pDlgCust = new CBCGPToolbarCustomize (this,
TRUE /* Automatic menus scaning */
);
pDlgCust->Create ();
}
LRESULT CMainFrame::OnToolbarContextMenu(WPARAM,LPARAM lp)
{
CPoint point (BCG_GET_X_LPARAM(lp), BCG_GET_Y_LPARAM(lp));
CMenu menu;
VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CBCGPPopupMenu* pPopupMenu = new CBCGPPopupMenu;
pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ());
return 0;
}
afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM /*wp*/,LPARAM)
{
// TODO: reset toolbar with id = (UINT) wp to its initial state:
//
// UINT uiToolBarId = (UINT) wp;
// if (uiToolBarId == IDR_MAINFRAME)
// {
// do something with m_wndToolBar
// }
return 0;
}
BOOL CMainFrame::OnShowPopupMenu (CBCGPPopupMenu* pMenuPopup)
{
//---------------------------------------------------------
// Replace ID_VIEW_TOOLBARS menu item to the toolbars list:
//---------------------------------------------------------
CFrameWnd::OnShowPopupMenu (pMenuPopup);
if (pMenuPopup != NULL &&
pMenuPopup->GetMenuBar ()->CommandToIndex (ID_VIEW_TOOLBARS) >= 0)
{
if (CBCGPToolBar::IsCustomizeMode ())
{
//----------------------------------------------------
// Don't show toolbars list in the cuztomization mode!
//----------------------------------------------------
return FALSE;
}
pMenuPopup->RemoveAllItems ();
CMenu menu;
VERIFY(menu.LoadMenu (IDR_POPUP_TOOLBAR));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pMenuPopup->GetMenuBar ()->ImportFromMenu (*pPopup, TRUE);
}
return TRUE;
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType,cx,cy);
RecalcLayout();
}
void CMainFrame::OnMenuAbout()
{
CAboutDlg dlg;
dlg.DoModal();
}
void CMainFrame::set_down_info(WPARAM wParam,LPARAM lParam)
{
//ShowWindow(SW_SHOWMAXIMIZED);
url = (PURL)lParam;
CTaskDlg dlg;
dlg.DoModal();
}
//播放下载完毕声音文件
void CMainFrame::Play_Sound(WPARAM wParam,LPARAM lParam)
{
//播放接受信息声音 ,
HINSTANCE hInstance = AfxGetInstanceHandle();
HRSRC hrsrc = FindResource(hInstance,"IDR_WAVE_SX","WAVE");
HGLOBAL hg = LoadResource(hInstance,hrsrc);
LPSTR path =(LPSTR)LockResource(hg);
sndPlaySound(path,SND_ASYNC | SND_MEMORY);
FreeResource(hg);
}
//**********************************************************************************
//** 函数名称: CMainFrame::OnMenuIdPorxy
//** 输 入:
//** 输 出: 启用IE代理
//** 功能描述:
//** 作 者: shuyi
//** 创建日期: 2007-7-10
//**************修改记录************************************************************
//** 修 改 者: shuyi
//** 修改日期: 2007-7-10
//** 修改描述:
//** 版 本: V1.0
//**********************************************************************************
void CMainFrame::OnMenuIdPorxy()
{
if(!m_ie_state)
{
CString Proxyaddr;
int port;
GetHttpProxy(Proxyaddr,port);
//SetHttpProxy(Proxyaddr,port);
LPProxyInfo proxy = new ProxyInfo;
proxy->Name = "IE代理";
proxy->ProxyAddr = Proxyaddr;
proxy->port = port;
proxy->type = "HTTP";
proxy->Default = 1;
//m_proxy_list.push_back(proxy);
//写入数据库
WriteProxyInfo(proxy);
m_default_proxy = proxy;
m_ie_state = true;
}
else
{
CString Proxyaddr;
int port;
GetHttpProxy(Proxyaddr,port);
LPProxyInfo proxy = new ProxyInfo;
proxy->Name = "IE代理";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -