📄 minimule.cpp
字号:
//this file is part of eMule
//Copyright (C)2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "stdafx.h"
#include <io.h>
#include <wininet.h>
#include "emule.h"
#include "emuledlg.h"
#include "MiniMule.h"
#include "OtherFunctions.h"
#include "Preferences.h"
#include "MenuCmds.h"
#include "IESecurity.h"
#include "UserMsgs.h"
#if (WINVER < 0x0500)
/* AnimateWindow() Commands */
#define AW_HOR_POSITIVE 0x00000001
#define AW_HOR_NEGATIVE 0x00000002
#define AW_VER_POSITIVE 0x00000004
#define AW_VER_NEGATIVE 0x00000008
#define AW_CENTER 0x00000010
#define AW_HIDE 0x00010000
#define AW_ACTIVATE 0x00020000
#define AW_SLIDE 0x00040000
#define AW_BLEND 0x00080000
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
class CCounter {
public:
CCounter(int& ri)
: m_ri(ri) {
ASSERT( ri == 0 );
m_ri++;
}
~CCounter() {
m_ri--;
ASSERT( m_ri == 0 );
}
int& m_ri;
};
// CMiniMule dialog
IMPLEMENT_DYNCREATE(CMiniMule, CDHtmlDialog)
BEGIN_MESSAGE_MAP(CMiniMule, CDHtmlDialog)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_WM_TIMER()
END_MESSAGE_MAP()
BEGIN_EVENTSINK_MAP(CMiniMule, CDHtmlDialog)
ON_EVENT(CDHtmlDialog, AFX_IDC_BROWSER, 250 /* BeforeNavigate2 */, _OnBeforeNavigate2, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
END_EVENTSINK_MAP()
BEGIN_DHTML_EVENT_MAP(CMiniMule)
DHTML_EVENT_ONCLICK(_T("restoreWndLink"), OnRestoreMainWindow)
DHTML_EVENT_ONKEYPRESS(_T("restoreWndLink"), OnRestoreMainWindow)
DHTML_EVENT_ONCLICK(_T("restoreWndImg"), OnRestoreMainWindow)
DHTML_EVENT_ONKEYPRESS(_T("restoreWndImg"), OnRestoreMainWindow)
DHTML_EVENT_ONCLICK(_T("openIncomingLink"), OnOpenIncomingFolder)
DHTML_EVENT_ONKEYPRESS(_T("openIncomingLink"), OnOpenIncomingFolder)
DHTML_EVENT_ONCLICK(_T("openIncomingImg"), OnOpenIncomingFolder)
DHTML_EVENT_ONKEYPRESS(_T("openIncomingImg"), OnOpenIncomingFolder)
DHTML_EVENT_ONCLICK(_T("optionsLink"), OnOptions)
DHTML_EVENT_ONKEYPRESS(_T("optionsLink"), OnOptions)
DHTML_EVENT_ONCLICK(_T("optionsImg"), OnOptions)
DHTML_EVENT_ONKEYPRESS(_T("optionsImg"), OnOptions)
END_DHTML_EVENT_MAP()
CMiniMule::CMiniMule(CWnd* pParent /*=NULL*/)
: CDHtmlDialog(CMiniMule::IDD, CMiniMule::IDH, pParent)
{
m_iInCallback = 0;
m_bResolveImages = true;
m_bRestoreMainWnd = false;
m_uAutoCloseTimer = 0;
m_bAutoClose = theApp.GetProfileInt(_T("eMule"), _T("MiniMuleAutoClose"), 0);
m_uWndTransparency = theApp.GetProfileInt(_T("eMule"), _T("MiniMuleTransparency"), 0);
SetHostFlags(m_dwHostFlags
| DOCHOSTUIFLAG_DIALOG // MSHTML does not enable selection of the text in the form
| DOCHOSTUIFLAG_DISABLE_HELP_MENU // MSHTML does not add the Help menu item to the container's menu.
);
}
CMiniMule::~CMiniMule()
{
}
STDMETHODIMP CMiniMule::GetOptionKeyPath(LPOLESTR* pchKey, DWORD dw)
{
TRACE(_T("%hs\n"), __FUNCTION__);
//OpenKey HKCU\Software\eMule\IE
//QueryValue HKCU\Software\eMule\IE\Show_FullURL
//QueryValue HKCU\Software\eMule\IE\SmartDithering
//QueryValue HKCU\Software\eMule\IE\RtfConverterFlags
//OpenKey HKCU\Software\eMule\IE\Main
//QueryValue HKCU\Software\eMule\IE\Main\Page_Transitions
//QueryValue HKCU\Software\eMule\IE\Main\Use_DlgBox_Colors
//QueryValue HKCU\Software\eMule\IE\Main\Anchor Underline
//QueryValue HKCU\Software\eMule\IE\Main\CSS_Compat
//QueryValue HKCU\Software\eMule\IE\Main\Expand Alt Text
//QueryValue HKCU\Software\eMule\IE\Main\Display Inline Images
//QueryValue HKCU\Software\eMule\IE\Main\Display Inline Videos
//QueryValue HKCU\Software\eMule\IE\Main\Play_Background_Sounds
//QueryValue HKCU\Software\eMule\IE\Main\Play_Animations
//QueryValue HKCU\Software\eMule\IE\Main\Print_Background
//QueryValue HKCU\Software\eMule\IE\Main\Use Stylesheets
//QueryValue HKCU\Software\eMule\IE\Main\SmoothScroll
//QueryValue HKCU\Software\eMule\IE\Main\Show image placeholders
//QueryValue HKCU\Software\eMule\IE\Main\Disable Script Debugger
//QueryValue HKCU\Software\eMule\IE\Main\DisableScriptDebuggerIE
//QueryValue HKCU\Software\eMule\IE\Main\Move System Caret
//QueryValue HKCU\Software\eMule\IE\Main\Force Offscreen Composition
//QueryValue HKCU\Software\eMule\IE\Main\Enable AutoImageResize
//QueryValue HKCU\Software\eMule\IE\Main\Q051873
//QueryValue HKCU\Software\eMule\IE\Main\UseThemes
//QueryValue HKCU\Software\eMule\IE\Main\UseHR
//QueryValue HKCU\Software\eMule\IE\Main\Q300829
//QueryValue HKCU\Software\eMule\IE\Main\Disable_Local_Machine_Navigate
//QueryValue HKCU\Software\eMule\IE\Main\Cleanup HTCs
//QueryValue HKCU\Software\eMule\IE\Main\Q331869
//QueryValue HKCU\Software\eMule\IE\Main\AlwaysAllowExecCommand
//OpenKey HKCU\Software\eMule\IE\Settings
//QueryValue HKCU\Software\eMule\IE\Settings\Anchor Color
//QueryValue HKCU\Software\eMule\IE\Settings\Anchor Color Visited
//QueryValue HKCU\Software\eMule\IE\Settings\Anchor Color Hover
//QueryValue HKCU\Software\eMule\IE\Settings\Always Use My Colors
//QueryValue HKCU\Software\eMule\IE\Settings\Always Use My Font Size
//QueryValue HKCU\Software\eMule\IE\Settings\Always Use My Font Face
//QueryValue HKCU\Software\eMule\IE\Settings\Use Anchor Hover Color
//QueryValue HKCU\Software\eMule\IE\Settings\MiscFlags
//OpenKey HKCU\Software\eMule\IE\Styles
//OpenKey HKCU\Software\eMule\IE\International
//OpenKey HKCU\Software\eMule\IE\International\Scripts
//OpenKey HKCU\Software\eMule\IE\International\Scripts\3
return E_NOTIMPL;
}
void CMiniMule::DoDataExchange(CDataExchange* pDX)
{
CDHtmlDialog::DoDataExchange(pDX);
}
BOOL CMiniMule::CreateControlSite(COleControlContainer* pContainer, COleControlSite** ppSite, UINT nID, REFCLSID clsid)
{
CMuleBrowserControlSite *pBrowserSite = new CMuleBrowserControlSite(pContainer, this);
if (!pBrowserSite)
return FALSE;
*ppSite = pBrowserSite;
return TRUE;
}
BOOL CMiniMule::OnInitDialog()
{
ASSERT( m_iInCallback == 0 );
CString strHtmlFile = theApp.GetSkinFileItem(_T("MiniMule"), _T("HTML"));
if (!strHtmlFile.IsEmpty())
{
if (_taccess(strHtmlFile, 0) == 0)
{
m_strCurrentUrl = _T("file://") + strHtmlFile;
m_nHtmlResID = 0;
m_szHtmlResID = NULL;
m_bResolveImages = false;
}
}
// TODO: Only in debug build: Check the size of the dialog resource right before 'OnInitDialog'
// to ensure the window is small enough!
CDHtmlDialog::OnInitDialog();
if (m_uWndTransparency)
{
m_layeredWnd.AddLayeredStyle(m_hWnd);
m_layeredWnd.SetTransparentPercentage(m_hWnd, m_uWndTransparency);
}
SetWindowText(_T("eMule v") + theApp.m_strCurVersionLong);
return TRUE; // return TRUE unless you set the focus to a control
}
void CMiniMule::OnClose()
{
ASSERT( m_iInCallback == 0 );
KillAutoCloseTimer();
if (GetAutoClose())
{
BOOL (WINAPI *pfnAnimateWindow)(HWND hWnd, DWORD dwTime, DWORD dwFlags);
(FARPROC&)pfnAnimateWindow = GetProcAddress(GetModuleHandle(_T("user32")), "AnimateWindow");
if (pfnAnimateWindow)
(*pfnAnimateWindow)(m_hWnd, 200, AW_HIDE | AW_BLEND | AW_CENTER);
}
CDHtmlDialog::OnClose();
theApp.emuledlg->PostMessage(UM_CLOSE_MINIMULE, (WPARAM)m_bRestoreMainWnd);
}
void CMiniMule::OnDestroy()
{
ASSERT( m_iInCallback == 0 );
KillAutoCloseTimer();
CDHtmlDialog::OnDestroy();
}
void CMiniMule::Localize()
{
SetElementHtml(_T("connectedLabel"), CComBSTR(GetResString(IDS_CONNECTED)));
SetElementHtml(_T("upRateLabel"), CComBSTR(GetResString(IDS_PW_CON_UPLBL)));
SetElementHtml(_T("downRateLabel"), CComBSTR(GetResString(IDS_PW_CON_DOWNLBL)));
SetElementHtml(_T("completedLabel"), CComBSTR(GetResString(IDS_DL_TRANSFCOMPL)));
SetElementHtml(_T("freeSpaceLabel"), CComBSTR(GetResString(IDS_STATS_FREESPACE)));
CComPtr<IHTMLElement> a;
GetElementInterface(_T("openIncomingLink"), &a);
if (a) {
a->put_title(CComBSTR(RemoveAmbersand(GetResString(IDS_OPENINC))));
a.Release();
}
GetElementInterface(_T("optionsLink"), &a);
if (a) {
a->put_title(CComBSTR(RemoveAmbersand(GetResString(IDS_EM_PREFS))));
a.Release();
}
GetElementInterface(_T("restoreWndLink"), &a);
if (a) {
a->put_title(CComBSTR(RemoveAmbersand(GetResString(IDS_MAIN_POPUP_RESTORE))));
a.Release();
}
CComPtr<IHTMLImgElement> img;
GetElementInterface(_T("openIncomingImg"), &img);
if (img) {
img->put_alt(CComBSTR(RemoveAmbersand(GetResString(IDS_OPENINC))));
img.Release();
}
GetElementInterface(_T("optionsImg"), &img);
if (img) {
img->put_alt(CComBSTR(RemoveAmbersand(GetResString(IDS_EM_PREFS))));
img.Release();
}
GetElementInterface(_T("restoreWndImg"), &img);
if (img) {
img->put_alt(CComBSTR(RemoveAmbersand(GetResString(IDS_MAIN_POPUP_RESTORE))));
img.Release();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -