📄 bmptoolbar.cpp
字号:
// BmpToolBar.cpp : implementation file
//
#include "stdafx.h"
#include "BitmapToolBarResrch.h"
#include "BmpToolBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBmpToolBar
CBmpToolBar::CBmpToolBar()
{
CBitmap tmp;
tmp.LoadBitmap(IDB_BITMAP1);
brush.CreatePatternBrush(&tmp);
}
CBmpToolBar::~CBmpToolBar()
{
}
BEGIN_MESSAGE_MAP(CBmpToolBar, CToolBar)
//{{AFX_MSG_MAP(CBmpToolBar)
ON_MESSAGE(TB_ADDBITMAP, OnSetMyBitmap)
ON_MESSAGE(TB_REPLACEBITMAP, OnSetMyBitmap)
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBmpToolBar message handlers
BOOL CBmpToolBar::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBitmap tmp;
tmp.LoadBitmap(IDB_BITMAP1);
RECT rect;
GetWindowRect(&rect);
ScreenToClient(&rect);
pDC->FillRect(&rect,&brush);
return TRUE;
return CToolBar::OnEraseBkgnd(pDC);
}
HBRUSH CBmpToolBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CToolBar::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_BTN)
{
pDC->SetBkMode(TRANSPARENT);
return brush;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
LRESULT CBmpToolBar::OnSetMyBitmap(WPARAM wParam, LPARAM lParam)
{
BITMAP bitmap;
CBitmap tmp;
tmp.LoadBitmap(IDB_BITMAP1);
VERIFY(::GetObject((HBITMAP)tmp, sizeof(BITMAP), &bitmap));
// add the bitmap to the common control toolbar
TBADDBITMAP addBitmap;
addBitmap.hInst = NULL; // makes TBADDBITMAP::nID behave a HBITMAP
addBitmap.nID = (UINT)(HBITMAP)tmp;
DefWindowProc(TB_ADDBITMAP,
bitmap.bmWidth / 32, (LPARAM)&addBitmap);
return 0L;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -