📄 myie.cpp
字号:
strURL = cmdInfo.m_strFileName;
TCHAR buf[2048];
// strURL.MakeLower();
if(strURL.Right(4).CompareNoCase(".url") == 0)
{
// an .URL file is formatted just like an .INI file, so we can
// use GetPrivateProfileString() to get the information we want
::GetPrivateProfileString(_T("InternetShortcut"), _T("URL"),
_T(""), buf, 2048,
strURL);
strURL = buf;
}
pMainFrame->NewChildWindow(1, nOpenType, strURL);
}
else
{
//continue last error session
if(run)
{ pMainFrame->UpdateWindow();
if(AfxMessageBox(IDS_RESUME, MB_YESNO)==IDYES)
run = TRUE;
else
run = FALSE;
}
//enable go home
nOpenType = bGoHome;
if(bGoHome == 2|| run)//
{
//load last visit
UINT len;
char *tmp = NULL;
BOOL r = GetProfileBinary("Settings","lastvisit", (LPBYTE*)(&tmp), &len);
if(r)
{
//load pop list
char *token;
char seps[] = "\n";
token = strtok( tmp, seps);
while( token != NULL )
{
BOOL bnext = ((CMainFrame*)m_pMainWnd)->m_bNextTab;
((CMainFrame*)m_pMainWnd)->m_bNextTab = FALSE;
/* While there are tokens in "string" */
((CMainFrame*)m_pMainWnd)->NewChildWindow(1, 2, token);
/* Get next token: */
token = strtok( NULL, seps );
((CMainFrame*)m_pMainWnd)->m_bNextTab = bnext;
}
delete[] tmp;
}
}
else if(bGoHome == 3)
{
pMainFrame->OpenAllFavs(((CMainFrame*)m_pMainWnd)->m_strStartFavFolder);
}
else if(bGoHome == 4)
{
pMainFrame->OpenAllFavs(((CMainFrame*)m_pMainWnd)->m_strStartFavFolder, TRUE);
}
else if(bGoHome == 5)
{
//start group
pMainFrame->OpenGroup(pMainFrame->m_strStartGroup);
}
else
pMainFrame->NewChildWindow(1, nOpenType, strURL, NULL, TRUE);
}
//full screen
BOOL bFullScreenMode = GetProfileInt("Settings", "FullScreen", 0);
if(bFullScreenMode)
{
((CMainFrame*)m_pMainWnd)->FullScreenModeOn();
}
//go my homepage when first run
if(bFirst)
{
CString strURL = "http://changyou.mainpage.net/";
((CMainFrame*)m_pMainWnd)->NewChildWindow(1,2,strURL);
}
WriteProfileInt("Settings", "Running", 1);
pMainFrame->UpdateWindow();
return TRUE;
}
//#pragma optimize( "s", on )
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CMyIEApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CMyIEApp message handlers
/*CDocument* CMyIEApp::OpenDocumentFile(LPCTSTR lpszFileName)
{
// TODO: Add your specialized code here and/or call the base class
//load file to the empty doc which is opend when initializing.
// ASSERT(m_pDocManager != NULL);
POSITION pos=m_pDocManager->GetFirstDocTemplatePosition();
if(pos!=NULL)
{
CDocTemplate* pTemplate = m_pDocManager->GetNextDocTemplate(pos);
POSITION pos2 = pTemplate->GetFirstDocPosition();
if(pos2!=NULL)
{
CMyIEDoc * pDoc = (CMyIEDoc*)pTemplate->GetNextDoc(pos2);
if(pDoc!=NULL && pDoc->m_bEmpty)
{
pDoc->m_bEmpty=false;
POSITION dpos = pDoc->GetFirstViewPosition();
CFixedHtmlView* pv =((CFixedHtmlView*)(pDoc->GetNextView(dpos)));
pv->Navigate2(lpszFileName,NULL,NULL);
pDoc->SetPathName(lpszFileName);
//bring the MDI child window to the top,
//we should bring the frame to top, not the view itself.
//a view has no title bar and border.
pv->GetParentFrame()->BringWindowToTop();
return pDoc;
}
}
}
return CWinApp::OpenDocumentFile(lpszFileName);
}*/
BOOL CMyIEApp::FirstRun()
{
int ver = 300; //3.x
int oldver = GetProfileInt("Settings", "Version", 0);
if(ver!=oldver)
{
//the first time run this version
WriteProfileInt("Settings", "Version", ver);
//add the code to initialize
#ifdef WEST_VER
WriteProfileString("Settings", "Background", "dhxu1.bmp");
#endif
return TRUE;
}
return FALSE;
}
//#pragma optimize( "", on )
int CMyIEApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
try{
//2.2
if(bSockInied)
WSACleanup();
if(m_pDispOM)
delete m_pDispOM;
if(m_pDropTarget)
delete m_pDropTarget;
CoUninitialize();
//delete agent
HKEY hKey;
// TCHAR sz[MAX_PATH];
if(RegOpenKey(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\User Agent\\Post Platform"), &hKey) != ERROR_SUCCESS)
{
TRACE0("Main setting not found\n");
}
else
{
RegDeleteValue(hKey, _T(MyIEVer));
RegCloseKey(hKey);
}
// CloseHandle(m_hMutex);
}
catch(...)
{
}
try{
return CWinApp::ExitInstance();
}catch(...)
{
return -1;
}
}
void CMyIEApp::LoadConfg()
{
//get pop list
UINT len;
char *tmp = NULL;
BOOL r;
//enable popup
EnablePopupFilter = GetProfileInt("Settings", "EnablePop", 1);
if(EnablePopupFilter)
((CMainFrame*)m_pMainWnd)->GetMenu()->CheckMenuItem(ID_TOOLS_EABLEPOPUPFILTER,MF_CHECKED);
else
((CMainFrame*)m_pMainWnd)->GetMenu()->CheckMenuItem(ID_TOOLS_EABLEPOPUPFILTER,MF_UNCHECKED);
EnableDupFilter = GetProfileInt("Settings", "EnableDupFilter", 0);
EnableAutoFilter = GetProfileInt("Settings", "EnableAutoFilter", 1);
//window pos
int top = GetProfileInt("Settings", "top", 100);
int left = GetProfileInt("Settings", "left", 100);
int width = GetProfileInt("Settings", "width", 500);
int height = GetProfileInt("Settings", "height", 400);
if( width!=0 && top<2000 && top>=-20)
m_pMainWnd->SetWindowPos(&CWnd::wndTop, left, top, width, height,SWP_HIDEWINDOW);
if( GetProfileInt("Settings", "Zoomed", 0))
m_nCmdShow = SW_SHOWMAXIMIZED;
((CMainFrame*)m_pMainWnd)->m_nTitleLen = GetProfileInt("Settings", "TabSize", 11);
//======================================Proxy==========================================
//load defaul proxy
((CMainFrame*)m_pMainWnd)->m_strCurProxy = GetProfileString("Settings", "DefaultProxy", NULL);
((CMainFrame*)m_pMainWnd)->m_strCurProxyName = ((CMainFrame*)m_pMainWnd)->GetProxyName(((CMainFrame*)m_pMainWnd)->m_strCurProxy);
//load proxy by pass
((CMainFrame*)m_pMainWnd)->m_strProxyByPass = GetProfileString("Settings", "ProxyByPass", "<local>");
//load proxy list number
((CMainFrame*)m_pMainWnd)->m_nCurProxyList = GetProfileInt("Settings", "ProxyList", 1);
((CMainFrame*)m_pMainWnd)->m_aProxyCategories.LoadProxies();
//load defaul web proxy
((CMainFrame*)m_pMainWnd)->m_strDefaultWebProxy = GetProfileString("Settings", "DefaultWebProxy", NULL);
/* if(((CMainFrame*)m_pMainWnd)->m_strDefaultWebProxy.IsEmpty())
{
((CMainFrame*)m_pMainWnd)->m_strDefaultWebProxy.LoadString(IDS_DEFAULT_WEB_PROXY);
((CMainFrame*)m_pMainWnd)->m_astrWebProxy.AddTail(((CMainFrame*)m_pMainWnd)->m_strDefaultWebProxy);
((CMainFrame*)m_pMainWnd)->m_aWebProxySpeed.AddTail(3);
}*/
//load proxy servers
/*2.3 CString wp = GetProfileString("Proxy", "p1", NULL);
if(wp == "" || wp.IsEmpty())
{
tmp = NULL;
r = GetProfileBinary("Settings","Proxy", (LPBYTE*)(&tmp), &len);
if(r)
{
//load pop list
char *token;
char seps[] = "\n";
token = strtok( tmp, seps);
while( token != NULL )
{
/* While there are tokens in "string" * /
((CMainFrame*)m_pMainWnd)->m_astrProxy.AddTail(token);
((CMainFrame*)m_pMainWnd)->m_astrProxyName.AddTail(token);
/* Get next token: * /
token = strtok( NULL, seps );
}
delete[] tmp;
}
*/
// int pn = ((CMainFrame*)m_pMainWnd)->m_astrProxy.GetCount();
//load proxy user name
/* tmp = NULL;
r = GetProfileBinary("Settings","ProxyUser", (LPBYTE*)(&tmp), &len);
if(r)
{
//load pop list
char *token;
char seps[] = "\n";
token = strtok( tmp, seps);
while( token != NULL )
{
// While there are tokens in "string"
((CMainFrame*)m_pMainWnd)->m_astrProxyUser.AddTail(token);
// Get next token:
token = strtok( NULL, seps );
}
delete[] tmp;
}
//load proxy password
tmp = NULL;
r = GetProfileBinary("Settings","ProxyPwd", (LPBYTE*)(&tmp), &len);
if(r)
{
//load pop list
char *token;
char seps[] = "\n";
token = strtok( tmp, seps);
while( token != NULL )
{
// While there are tokens in "string"
((CMainFrame*)m_pMainWnd)->m_astrProxyPwd.AddTail(token);
// Get next token:
token = strtok( NULL, seps );
}
delete[] tmp;
}
*/
//load proxy speed
/*2.3 tmp = NULL;
r = GetProfileBinary("Settings","ProxySP", (LPBYTE*)(&tmp), &len);
if(r)
{
//load pop list
for( UINT i=0;i<len;i++ )
{
((CMainFrame*)m_pMainWnd)->m_aProxySpeed.AddTail(tmp[i]);
}
delete[] tmp;
}
}
else
{
//new format
char Keyname1[6] = "p", Keyname2[7] = "ps", Keyname3[7] = "pn";
int sp, i=1;
sp = GetProfileInt("Proxy", "ps1", 3);
CString wpn = GetProfileString("Proxy", "pn1", wp);
while(wp != "" && !wp.IsEmpty())
{
((CMainFrame*)m_pMainWnd)->m_astrProxy.AddTail(wp);
((CMainFrame*)m_pMainWnd)->m_aProxySpeed.AddTail(sp);
((CMainFrame*)m_pMainWnd)->m_astrProxyName.AddTail(wpn);
i++;
itoa(i, Keyname1+1, 10);
itoa(i, Keyname2+2, 10);
itoa(i, Keyname3+2, 10);
wp = GetProfileString("Proxy", Keyname1, NULL);
sp = GetProfileInt("Proxy", Keyname2, 3);
wpn = GetProfileString("Proxy", Keyname3, wp);
}
}
*/
//adjust number of proxy list
/* if(pn!=((CMainFrame*)m_pMainWnd)->m_astrProxyUser.GetCount())
{
((CMainFrame*)m_pMainWnd)->m_astrProxyUser.RemoveAll();
for(int i=0; i<pn;i++)
((CMainFrame*)m_pMainWnd)->m_astrProxyUser.AddHead("");
}
if(pn!=((CMainFrame*)m_pMainWnd)->m_astrProxyPwd.GetCount())
{
((CMainFrame*)m_pMainWnd)->m_astrProxyPwd.RemoveAll();
for(int i=0; i<pn;i++)
((CMainFrame*)m_pMainWnd)->m_astrProxyPwd.AddHead("");
}*/
/*v2.0 delete
if(pn>((CMainFrame*)m_pMainWnd)->m_aProxySpeed.GetCount())
{
((CMainFrame*)m_pMainWnd)->m_aProxySpeed.RemoveAll();
for(int i=0; i<pn;i++)
((CMainFrame*)m_pMainWnd)->m_aProxySpeed.AddHead(3);
}
pn=((CMainFrame*)m_pMainWnd)->m_astrWebProxy.GetCount();
if(pn>((CMainFrame*)m_pMainWnd)->m_aWebProxySpeed.GetCount())
{
((CMainFrame*)m_pMainWnd)->m_aWebProxySpeed.RemoveAll();
for(int i=0; i<pn;i++)
((CMainFrame*)m_pMainWnd)->m_aWebProxySpeed.AddHead(3);
}
*/
//=================================================================================================
//active new window
((CMainFrame*)m_pMainWnd)->m_bActiveNewWindow = GetProfileInt("Settings", "ActiveNew", 0);
//always new window
bAddressInNewWindow = GetProfileInt("Settings", "AddressInNewWindow", 0);
bLinkInNewWindow = GetProfileInt("Settings", "LinkInNewWindow", 0);
bFavInNewWindow = GetProfileInt("Settings", "FavInNewWindow", TRUE);
bHisInNewWindow = GetProfileInt("Settings", "HisInNewWindow", TRUE);
bFileInNewWindow = GetProfileInt("Settings", "FileInNewWindow", TRUE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -