📄 mainfrm.cpp
字号:
rect.bottom += 5;
else if (m_nTabStyle == 1)
rect.bottom += 4;
DWORD dwStyle = TCS_BUTTONS|TCS_FLATBUTTONS|TCS_RAGGEDRIGHT;
if(m_nTabStyle!=2)
{
if(!m_bTopTab)
dwStyle = TCS_BOTTOM|WS_CHILD|TCS_OWNERDRAWFIXED;
else
dwStyle = WS_CHILD|TCS_OWNERDRAWFIXED;
}
if(m_bMultiLineTab)
{
if(!m_bAutoTab)
m_wndTab.Create(WS_VISIBLE|dwStyle|TCS_FOCUSNEVER|TCS_FORCELABELLEFT|TCS_TOOLTIPS|TCS_MULTILINE, rect,this, ID_TOOLBAR_TAB);
else
m_wndTab.Create(WS_VISIBLE|dwStyle|TCS_FOCUSNEVER|TCS_FORCELABELLEFT|TCS_TOOLTIPS|TCS_MULTILINE|TCS_FIXEDWIDTH, rect,this, ID_TOOLBAR_TAB);
GetMenu()->CheckMenuItem(ID_OPTION_MULTI_TAB, MF_CHECKED);
}
else if(!m_bAutoTab)
m_wndTab.Create(WS_VISIBLE|dwStyle|TCS_FOCUSNEVER|TCS_FORCELABELLEFT|TCS_TOOLTIPS, rect,this, ID_TOOLBAR_TAB);
else
m_wndTab.Create(WS_VISIBLE|dwStyle|TCS_FOCUSNEVER|TCS_FORCELABELLEFT|TCS_TOOLTIPS|TCS_FIXEDWIDTH , rect,this, ID_TOOLBAR_TAB);
DWORD dwExStyle= m_wndTab.GetExtendedStyle();
m_wndTab.SetExtendedStyle(dwExStyle | TCS_EX_FLATSEPARATORS);
InitTaskBarImage();
CSize size;
if(m_nTabStyle==2)
{
size.cx = FBPADDINGX;
size.cy = FBPADDINGY;
m_wndTab.SetPadding( size );
}
GetMenu()->CheckMenuItem(ID_VIEW_TASKBAR, MF_CHECKED);
m_wndTab.SetFonts();
//add tab to top or bottom
REBARBANDINFO rbbi;
if(m_bTopTab)
m_wndTab.ModifyStyle(0, CCS_NORESIZE);
else
{
rbbi.cbSize = sizeof(rbbi);
rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE |RBBIM_ID;
rbbi.wID = ID_VIEW_TASKBAR;
rbbi.cxMinChild = 0;
CRect rectAddress;
m_wndTab.GetWindowRect(&rectAddress);
rbbi.cyMinChild = rectAddress.Height();
rbbi.cxIdeal = 200;
//
m_wndReBar2.AddBar(&m_wndTab);
if(m_nTabStyle!=2)
{
rbbi.fMask |= RBBIM_STYLE;
rbbi.fStyle = RBBS_FIXEDBMP | RBBS_NOGRIPPER;
}
m_wndReBar2.GetReBarCtrl().SetBandInfo(0, &rbbi);
}
//create rebar
GetProfileReBarBandsState();
if(m_bLockToolbar)
FixToolbar(TRUE);
//
m_bDisableBackground = app->GetProfileInt("Settings", "DisableBackground", FALSE);
if (m_bDisableBackground==FALSE)
ShowBackground(m_bDisableBackground);
//bottom bar
if(app->GetProfileInt("Bands", "bandb0", 1)==0)
{
m_wndReBar2.GetReBarCtrl().ShowBand(0, FALSE);
GetMenu()->CheckMenuItem(ID_VIEW_TASKBAR, MF_UNCHECKED);
}
//auto complete
HINSTANCE hIns = LoadLibrary("shlwapi.dll");
if(hIns != NULL)
{
LPFNDLLFUNC1 lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hIns, "SHAutoComplete");
if(lpfnDllFunc1!=NULL)
lpfnDllFunc1(m_wndAddress->GetEditCtrl()->m_hWnd, 0xe);
FreeLibrary(hIns);
}
m_hResInst = LoadLibrary("RSRC32.dll");
g_pGetRes = (GETRES) GetProcAddress(m_hResInst, "_MyGetFreeSystemResources32@4");
m_wndTab.ModifyStyle(CCS_NORESIZE, 0);
m_wndTab.SetTabStyle(m_nTabStyle);
m_crUnSelColor = app->GetProfileInt("TabStyle", "UnSelColor", -1);
m_crUnSelFontColor = app->GetProfileInt("TabStyle", "UnSelFontColor", -1);
m_crSelFontColor = app->GetProfileInt("TabStyle", "SelFontColor", -1);
m_crSepColor = app->GetProfileInt("TabStyle", "SepColor", -1);
m_wndTab.SetUnSelColor(m_crUnSelColor);
m_wndTab.SetUnSelFontColor(m_crUnSelFontColor);
m_wndTab.SetSelFontColor(m_crSelFontColor);
m_wndTab.SetSepColor(m_crSepColor);
//
UINT Modifiers = app->GetProfileInt("Settings", "ShowHideModifiers", MOD_CONTROL);
UINT Key = app->GetProfileInt("Settings", "ShowHideKey", 192);
g_bRegisterHotKeyOk = FALSE;
if (Key)
g_bRegisterHotKeyOk = RegisterHotKey (m_hWnd, 0, Modifiers , Key);
//
m_bMenuLoadLastClose = app->GetProfileInt("Settings", "MenuLoadLastClose", 1);
if (m_bMenuLoadLastClose)
OpenLastClose();
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::SetAddress(LPCTSTR lpszUrl)
{
// This is called when the browser has completely loaded the new location,
// so make sure the text in the address bar is up to date and stop the
try{
m_wndAddress->SetWindowText(lpszUrl);
COMBOBOXEXITEM item;
item.mask = CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
item.iItem = -1;
item.iImage = 1;
item.iSelectedImage = 1;
m_wndAddress->SetItem(&item);
}catch(...){}
}
void CMainFrame::OnNewAddress()
{
// gets called when an item in the Address combo box is selected
// just navigate to the newly selected location.
CString str;
try{
int i = m_AddressBar.m_wndAddress.GetCurSel();
if(i<0)
return;
m_AddressBar.GetSelText(i, str);
//
if (DoSpecialUrl(str))
return;
//better to place here, for that set address new text
if (IS_RES_URL(str))
{
DO_RES_URL(str)
m_wndAddress->GetEditCtrl()->SetWindowText(str);
}
CChildFrame* tcf = (CChildFrame*)MDIGetActive();
short ks=GetKeyState(VK_CONTROL), ss=GetKeyState(VK_SHIFT);
//create new if not exist
if(tcf==NULL || g_bAddressInNewWindow)
{
CString strProxy;
strProxy.Empty();
if (VALID_TCF(tcf) && tcf->m_pView->m_bEnWebProxy)
{
strProxy = tcf->m_pView->m_strWebProxy;
}
tcf = NewChildWindow(0);
if (VALID_TCF(tcf) && strProxy.GetLength()>0)
{
tcf->m_pView->m_bEnWebProxy = 1;
tcf->m_pView->m_strWebProxy = strProxy;
}
if (m_bActiveNewAddress)
tcf->m_bForceActive = TRUE;
}
//web proxy
if (VALID_TCF(tcf))
{
tcf->m_pView->ToNavigate(str, 0, NULL);
//
tcf = (CChildFrame*)MDIGetActive();
tcf->ViewSetFocus();//must use post
}
}catch(...){}
}
void CMainFrame::OnNewAddressEnter()
{
// gets called when an item is entered manually into the edit box portion
// of the Address combo box.
// navigate to the newly selected location and also add this address to the
// list of addresses in the combo box.
CString oldstr, url;
CString str, str2;
COMBOBOXEXITEM item;
try{
if ( (CWnd*)m_wndSearch->GetEditCtrl() == GetFocus() )
{
OnNewSearchEnter();
return;
}
//
m_wndAddress->GetEditCtrl()->GetWindowText(str2);
str2.TrimLeft();str2.TrimRight();
if (str2.GetLength()<=0)
return;
//focus
m_wndAddress->SetFocus();
//
if (DoSpecialUrl(str2))
return;
if (IS_RES_URL(str2))
{
DO_RES_URL(str2)
m_wndAddress->GetEditCtrl()->SetWindowText(str2);
}
CChildFrame* tcf = (CChildFrame*)MDIGetActive();
//GetKeyState return >0 means press the key
short ks=GetKeyState(VK_CONTROL), ss=GetKeyState(VK_SHIFT), as=GetKeyState(VK_MENU);
if(ks>=0 && ss>=0) // only Enter need to expand alias and other shortcuts
{
//alisa
if(m_bUseAlias && m_mapAlias.Lookup(str2, url))
{
str2 = url;
m_wndAddress->GetEditCtrl()->SetWindowText(str2);
}
//use quick search
else if(str2.Find(' ')>0)
{
int i = str2.Find(' ');
CString qs = str2.Left(i);
CString keyw = str2.Mid(i+1);
keyw.TrimLeft();
qs.TrimLeft();qs.TrimRight();
if(m_SearchList.Lookup(qs, url)!=-1)
{
DO_SEARCH_STR(url,keyw)
str2 = url;
m_wndAddress->GetEditCtrl()->SetWindowText(str2);
}
}
}
oldstr = str2;
item.mask = CBEIF_TEXT|CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
item.iItem = 0;
str2.TrimLeft();
str2.TrimRight();
//javascript:void(document.bgColor='#FFFFFF')
//books://www.
if (str2.Find(':')>0)
str2.Replace('\\','/');
else
{
if(ks<0 && ss>=0 && as>=0)
str2 = m_strCE1+str2+m_strCE2;
else if(ks>=0 && ss<0 && as>=0)
str2 = m_strSE1+str2+m_strSE2;
else if(ks<0 && ss<0 && as>=0)
str2 = m_strCSE1 + str2 + m_strCSE2;
else if (str2=="localhost")
str2 = "http://"+str2;
else if (str2.Left(4)=="ftp.")
str2 = "ftp://"+str2;
else if (NOT_SEARCH_STR(str2))
{
if (str2.Left(2)!="\\\\") // \\server1
str2 = "http://"+str2;
}
else//search
{
SEARCH_STR(str2)
return;
}
oldstr = str2;
m_wndAddress->GetEditCtrl()->SetWindowText(str2);
}
str =str2;
//create new if not exist and always new
if(tcf==NULL || g_bAddressInNewWindow || as<0)
{
CString strProxy;
strProxy.Empty();
if (VALID_TCF(tcf) && tcf->m_pView->m_bEnWebProxy)
{
strProxy = tcf->m_pView->m_strWebProxy;
}
tcf = NewChildWindow(0);
if (VALID_TCF(tcf) && strProxy.GetLength()>0)
{
tcf->m_pView->m_bEnWebProxy = 1;
tcf->m_pView->m_strWebProxy = strProxy;
}
if (m_bActiveNewAddress)
tcf->m_bForceActive = TRUE;
}
//web proxy
if (VALID_TCF(tcf))
{
tcf->m_pView->ToNavigate(oldstr, 0, NULL);
//
tcf = (CChildFrame*)MDIGetActive();
tcf->ViewSetFocus();
}
if(m_AddressBar.FindStringExact(-1,str) == CB_ERR)
{
if (str.Right(1)=='/')
str = str.Left(str.GetLength()-1);
else
str += '/';
if(m_AddressBar.FindStringExact(-1, str) == CB_ERR)
{
//the URL is new
item.pszText = (LPTSTR)(LPCTSTR)str2;
item.iImage = 1;
item.iSelectedImage = 1;
m_wndAddress->InsertItem(&item);
}
}
}catch(...){}
}
void CMainFrame::DoNothing()
{
// this is here only so that the toolbar buttons for the dropdown menus
// will have a callback, and thus will not be disabled.
}
int CMainFrame::BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu,int nFixMenu, int FirstLevel, int& nFavs)
{
CString strPath;
CString strPath2;
CString str, str2;
WIN32_FIND_DATA wfd;
HANDLE h;
int nPos;
int nEndPos;
int nLastDir;
CStringArray astrFavorites;
CArray<int,int> anFavID;
CStringArray astrDirs;
BOOL isLink = FALSE;
static CString strOpenAll, strAddFav;
int nSubFavs = 0;
try{
strPath = pszPath;
nFavs = 0;
LOADSTR(strOpenAll ,IDS_OPEN_ALL_FAV);
LOADSTR(strAddFav ,IDS_ADDFAV);
// make sure there's a trailing backslash
if(strPath[strPath.GetLength() - 1] != _T('\\'))
strPath += _T('\\');
//for relative path
CString strLinkPath = m_strLinkPath;
DO_RELATIVE_URL(strLinkPath);
if(strPath==strLinkPath)
isLink = TRUE;
strPath2 = strPath;
strPath += "*.*";
nLastDir = 0;
// now scan the directory, first for .URL files and then for subdirectories
// that may also contain .URL files
h = FindFirstFile(strPath, &wfd);
DWORD fileattr;
if(m_bShowHiddenFav == 1)
fileattr = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_SYSTEM;
else
fileattr = FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM;
if(h != INVALID_HANDLE_VALUE)
{
nEndPos = nStartPos;
do
{
if((wfd.dwFileAttributes & fileattr)==0)
{
str = wfd.cFileName; str2= str;
if (IS_FAVURL(str))
{
nPos = nEndPos;
astrFavorites.Add( str2);
anFavID.Add(nPos);
++nEndPos;
nFavs ++;
}
else if(str.Right(4) == _T(".lnk"))
{
nPos = nEndPos;
astrFavorites.Add(str2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -