📄 addressbarex.cpp
字号:
// AddressBarEx.cpp : implementation file
//
#include "stdafx.h"
#include "myie.h"
#include "AddressBarEx.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAddressBarEx
CAddressBarEx::CAddressBarEx()
{
HKEY hKey;
TCHAR sz[MAX_PATH];
DWORD dwSize = MAX_PATH;
ShowGoButton = TRUE;
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Main"), &hKey) != ERROR_SUCCESS)
{
TRACE0("Main setting not found\n");
}
else
{
dwSize = sizeof(sz);
RegQueryValueEx(hKey, _T("ShowGoButton"), NULL, NULL, (LPBYTE)sz, &dwSize);
if(strcmp(sz, "no")==0)
ShowGoButton = FALSE;
}
}
CAddressBarEx::~CAddressBarEx()
{
}
BEGIN_MESSAGE_MAP(CAddressBarEx, CToolBar)
//{{AFX_MSG_MAP(CAddressBarEx)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAddressBarEx message handlers
void CAddressBarEx::OnSize(UINT nType, int cx, int cy)
{
CToolBar::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
//===
CRect rect2;
GetItemRect(1, rect2);
int w;
if(ShowGoButton)
w= cx-rect2.Width()-2;
else
w = cx;
SetButtonInfo(0, 0, TBBS_SEPARATOR, w);
m_wndAddress.SetWindowPos(NULL, 0, 0, w, cy, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS);
if(!m_wndAddress.IsWindowVisible())
m_wndAddress.ShowWindow(SW_SHOW);
//====
}
CComboBoxEx* CAddressBarEx::GetAddressBox()
{
return &m_wndAddress;
}
void CAddressBarEx::Init()
{
// TODO: Add your specialized creation code here
// create a combo box for the address bar
if (!m_wndAddress.Create(CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_CHILD, CRect(0, 0, 200, 180), this, AFX_IDW_TOOLBAR + 1))
{
TRACE0("Failed to create combobox\n");
return ; // fail to create
}
m_wndAddress.SetExtendedStyle(0, m_wndAddress.GetExtendedStyle()|CBES_EX_NOSIZELIMIT);
CBitmap bitmap;
CImageList img;
bitmap.LoadBitmap(IDB_BITMAP1);
img.Create(16, 16, ILC_COLORDDB|ILC_MASK, 7, 1);
img.Add(&bitmap, RGB(255,0,255));
m_wndAddress.SetImageList(&img);
img.Detach();
bitmap.Detach();
return;
}
void CAddressBarEx::GetSelText(int index, CString & str)
{
if(index<0)
return;
TCHAR sz[MAX_PATH];
COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT;
item.pszText = (LPTSTR)sz;
item.cchTextMax = MAX_PATH;
item.iItem = index;
m_wndAddress.GetItem(&item);
str = sz;
}
int CAddressBarEx::FindStringExact(int start, CString & str)
{
TCHAR sz[MAX_PATH];
COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT;
item.pszText = (LPTSTR)sz;
item.cchTextMax = MAX_PATH;
int nc = m_wndAddress.SendMessage(CB_GETCOUNT, 0, 0);
for(register int i=start+1;i<nc;i++)
{
item.iItem = i;
m_wndAddress.GetItem(&item);
if(str == sz)
return i;
}
return CB_ERR;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -