📄 historywnd.cpp
字号:
// HistoryWnd.cpp : implementation file
//
#include "stdafx.h"
#include "..\benbenBrowser.h"
#include "HistoryWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHistoryWnd
IMPLEMENT_DYNCREATE(CHistoryWnd, CWnd)
CHistoryWnd::CHistoryWnd()
{
}
CHistoryWnd::~CHistoryWnd()
{
}
BEGIN_MESSAGE_MAP(CHistoryWnd, CWnd)
//{{AFX_MSG_MAP(CHistoryWnd)
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHistoryWnd message handlers
int CHistoryWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_histytree.Create(WS_CHILD|WS_VISIBLE|TVS_SHOWSELALWAYS|TVS_LINESATROOT|
TVS_FULLROWSELECT |TVS_TRACKSELECT|TVS_SINGLEEXPAND |TVS_HASLINES ,
CRect(0,0,0,0), this, 100);
m_histytree.ModifyStyleEx(0, WS_EX_STATICEDGE);
m_histytree.InitSystemImageLists();
RefreshHistoryTree();
if (!m_ToolBar.CreateEx(this))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// set up toolbar properties
m_ToolBar.GetToolBarCtrl().SetButtonWidth(16, 100);
// img.Create(IDB_BITMAP7, 16, 0, RGB(255, 0, 255));
// m_ToolBar.GetToolBarCtrl().SetHotImageList(&img);
// img.Detach();
CImageList img;
img.Create(16, 16, ILC_COLORDDB|ILC_MASK, 3, 1);
HBITMAP hbmp = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP7));
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
m_ToolBar.GetToolBarCtrl().SetImageList(&img);
img.Detach();
m_ToolBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_LIST|TBSTYLE_TOOLTIPS);
m_ToolBar.SetButtons(NULL, 2);
// set up each toolbar button
//m_ToolBar.SetButtonInfo(0);
m_ToolBar.SetButtonInfo(0, ID_ADDTOFAVORITES_FAVORITE, TBSTYLE_BUTTON|TBSTYLE_AUTOSIZE,0);
m_ToolBar.SetButtonInfo(1, ID_ORGANIZE_FAVORITES, TBSTYLE_BUTTON|TBSTYLE_AUTOSIZE, 0);
// str="hot";
// m_ToolBar.SetButtonInfo(2, ID_FAVORITES_BEST, TBSTYLE_BUTTON|TBSTYLE_AUTOSIZE, 2);
// m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_FAVORITES_BEST);
m_ToolBar.SetBarStyle(m_ToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
CRect rectToolBar;
// set up toolbar button sizes
m_ToolBar.GetItemRect(1, &rectToolBar);
m_ToolBar.SetSizes(rectToolBar.Size(), CSize(16,16));
if (!m_rebar.Create(this,RBS_BANDBORDERS|RBS_DBLCLKTOGGLE | RBS_REGISTERDROP |RBS_VARHEIGHT ,CCS_NODIVIDER |CCS_NOPARENTALIGN |WS_BORDER |WS_CHILD |WS_CLIPCHILDREN |WS_CLIPSIBLINGS |WS_VISIBLE | CBRS_TOP))
{
return -1; // fail to create
}
m_rebar.AddBar(&m_ToolBar);
REBARBANDINFO rbbi;
rbbi.cbSize = sizeof(rbbi);
rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE|RBBIM_STYLE;
rbbi.fStyle = RBBS_NOGRIPPER;
rbbi.cxMinChild = rectToolBar.Width();
rbbi.cyMinChild = rectToolBar.Height();
rbbi.cx = rbbi.cxIdeal = rectToolBar.Width()*2;
m_rebar.GetReBarCtrl().SetBandInfo(0, &rbbi);
return 0;
}
void CHistoryWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
m_rebar.MoveWindow(0,0, cx,26);
m_histytree.MoveWindow(0,26,cx,cy-26);
}
void CHistoryWnd::RefreshHistoryTree()
{
TCHAR szPath[MAX_PATH];
SHGetSpecialFolderPath(NULL,szPath,CSIDL_HISTORY,0);
m_histytree.PopulateTree2(szPath);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -