📄 donut.cpp
字号:
// Donut.cpp : main source file for Donut.exe
//
#include "stdafx.h"
#include "WtlFixed/atlmisc.h"
#include <atlframe.h>
#include <atlctrls.h>
#include <atlctrlw.h>
#include "WtlFixed/atlsplit.h"
#include <atldlgs.h>
#include <atlctrlx.h>
#include <atlcrack.h>
#include <atlddx.h>
#include <wininet.h>
static bool _bMozilla = false;
static bool _bNaviLock = false;
static const CLSID CLSID_MozillaBrowser =
{ 0x1339B54C, 0x3453, 0x11D2, { 0x93, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } };
static const CLSID DONUT_CGID_DocHostCommandHandler =
{ 0xf38bc242, 0xb950, 0x11d1, { 0x89, 0x18, 0x00, 0xc0, 0x4f, 0xc2, 0xc8, 0x36 } };
#include "ScriptErrorCommandTargetImpl.h"
#include "AtlifaceEx.h"
#include "AtlifaceEx_i.c"
#include "AtlhostEx.h"
#include "resource.h"
/*
int _arrToolBarCmdID[] = {
ID_FILE_NEW, 0, ID_VIEW_BACK, ID_VIEW_FORWARD, 0,
ID_VIEW_REFRESH, ID_VIEW_HOME, ID_VIEW_STOP, 0,
ID_DLCTL_DLIMAGES, ID_DLCTL_SCRIPTS, ID_DLCTL_JAVA,
ID_DLCTL_RUNACTIVEXCTLS, ID_DLCTL_DLACTIVEXCTLS, ID_DLCTL_BGSOUNDS, ID_DLCTL_VIDEOS, 0,
ID_MAIN_EX_NEWWINDOW, ID_MAIN_EX_NOACTIVATE, 0,
ID_EDIT_CUT, ID_EDIT_COPY, ID_EDIT_PASTE, 0,
ID_FILE_PRINT, ID_EDIT_PASTE_URL, ID_DOCHOSTUI_OPENNEWWIN, 0,
ID_VIEW_REFRESH_ALL, ID_VIEW_STOP_ALL, 0,
ID_FILE_CLOSE, ID_WINDOW_CLOSE_ALL, ID_WINDOW_CLOSE_EXCEPT, 0,
ATL_IDS_SCPREVWINDOW, ATL_IDS_SCNEXTWINDOW, 0,
ID_WINDOW_CASCADE, ID_WINDOW_TILE_HORZ, ID_WINDOW_TILE_VERT, 0,
ID_TAB_LEFT, ID_TAB_RIGHT, 0,
ID_VIEW_CLIPBOARDBAR, ID_VIEW_TABBAR_MULTI, ID_VIEW_FULLSCREEN, ID_OPTION_CLOSEPOPUP,
ID_MAIN_EX_NOACTIVATE_NEWWIN, ID_VIEW_FAVEXPBAR
};
*/
// Don't change for saving rebar state
#define IDC_ADDRESSBAR 101
#define IDC_GOBUTTON 102
#define IDC_MDITAB 103
#define IDC_LINKBAR 104
#define IDC_PROGRESS 105
// #define DONUT_HAS_CMDBAR
// Dev studio doesn't know BEGIN_MSG_MAP_EX
#undef BEGIN_MSG_MAP
#define BEGIN_MSG_MAP BEGIN_MSG_MAP_EX
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif
#include "ItemIDList.h"
#include "mtl.h"
// drafts
#include "DialogKiller.h"
#include "ReBarVerticalBorder.h"
#include "FileNotification.h"
#include "FlatComboBox.h"
// Ini file name
TCHAR _szIniFileName[MAX_PATH];
// to emulate DDE.
#define WM_NEWINSTANCE WM_USER + 16
#define USER_MSG_WM_NEWINSTANCE(func) \
if (uMsg == WM_NEWINSTANCE) \
{ \
SetMsgHandled(TRUE); \
func((ATOM)wParam); \
lResult = 0; \
if(IsMsgHandled()) \
return TRUE; \
}
// to save child window options
#define WM_SAVE_OPTION WM_USER + 20
#define USER_MSG_WM_SAVE_OPTION(func) \
if (uMsg == WM_SAVE_OPTION) \
{ \
SetMsgHandled(TRUE); \
func((LPCTSTR)wParam, (int)lParam); \
lResult = 0; \
if(IsMsgHandled()) \
return TRUE; \
}
#include "DonutFavoritesMenu.h"
#include "DonutOptions.h"
#include "DonutExecutablePropertyPage.h"
#include "DonutConfirmOption.h"
#include "DonutSecurityZone.h"
#include "Donut.h"
#include "DonutClipboardBar.h"
#include "FavTreeViewCtrl.h"
#include "DonutExplorerBar.h"
#include "DonutLinksBarCtrl.h"
#include "DonutToolBar.h"
#include "AddressBar.h"
#include "FavoriteMenu.h"
#include "CloseTitle.h"
#include "DonutView.h"
#include "aboutdlg.h"
#include "ChildFrm.h"
#include "MainFrm.h"
bool _PrivateInit(const CString& strCmdLine)
{
MtlIniFileNameInit(_szIniFileName, _MAX_PATH);
CMainOption::GetProfile();
CDLControlOption::GetProfile();
CIgnoredURLsOption::GetProfile();
CCloseTitlesOption::GetProfile();
CFileNewOption::GetProfile();
CStartUpOption::GetProfile();
CDonutConfirmOption::GetProfile();
CFavoritesMenuOption::Init();
if (CMainOption::s_dwMainExtendedStyle & MAIN_EX_ONEINSTANCE) {// guarantee one instance
HWND hWnd = ::FindWindow(_T("WTL:Donut"), NULL);
if (hWnd) {
if (!strCmdLine.IsEmpty()) {
ATOM nAtom = ::GlobalAddAtom(strCmdLine);
::PostMessage(hWnd, WM_NEWINSTANCE, (WPARAM)nAtom, 0);
}
return false;
}
}
return true;
}
void _PrivateTerm()
{
CMainOption::WriteProfile();
CDLControlOption::WriteProfile();
CIgnoredURLsOption::WriteProfile();
CCloseTitlesOption::WriteProfile();
CFileNewOption::WriteProfile();
CStartUpOption::WriteProfile();
CDonutConfirmOption::WriteProfile();
CFavoritesMenuOption::Term();
// don't forget
CHlinkDataObject::Term();
}
CAppModule _Module;
int Run(LPTSTR lpstrCmdLine = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
CMainFrame wndMain;
if(wndMain.CreateEx() == NULL)
{
ATLTRACE(_T("Main window creation failed!\n"));
return 0;
}
// load windowplacement
CIniSection pr;
pr.Open(_szIniFileName, _T("Main"));
MtlGetProfileMainFrameState_Chance(pr, wndMain, nCmdShow, CMainFrame::_Function_FullScreen(wndMain));
pr.Close();
CString strCmdLine(lpstrCmdLine);
// if (strCmdLine.Left(1) == _T('\"') && strCmdLine.Right(1) == _T('\"'))
// strCmdLine = strCmdLine.Mid(1, strCmdLine.GetLength() - 2);
if (strCmdLine.IsEmpty()) {// no command line param
CStartUpOption::StartUp(wndMain);
}
else {
if (strCmdLine.CompareNoCase(_T("/dde")) != 0) {// it's not from dde. (if dde, do nothing.)
ATLTRACE(_T("it's not from dde!(%s)\n"), strCmdLine);
wndMain.OnUserOpenFile(strCmdLine, DonutGetStdOpenFlag());
}
}
int nRet = theLoop.Run();
_Module.RemoveMessageLoop();
return nRet;
}
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
#ifdef _DEBUG
int tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
tmpDbgFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag(tmpDbgFlag);
#endif
HRESULT hRes = ::CoInitialize(NULL);
hRes = ::OleInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to
// make the EXE free threaded. This means that calls come in on a random RPC thread.
// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
ATLASSERT(SUCCEEDED(hRes));
ATLTRACE(_T("tWinMain : \n"), lpstrCmdLine);
#if (_WIN32_IE >= 0x0300)
INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof(iccx);
// Register extensional window classes
iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_USEREX_CLASSES;
BOOL bRet = ::InitCommonControlsEx(&iccx);
bRet;
ATLASSERT(bRet);
#else
::InitCommonControls();
#endif
hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
if (!_PrivateInit(lpstrCmdLine))
return 0;
AtlAxWinInit();
int nRet = Run(lpstrCmdLine, nCmdShow);
_PrivateTerm();
_Module.Term();
::OleUninitialize();
::CoUninitialize();
return nRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -