-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomToolBar.cpp
More file actions
executable file
·75 lines (62 loc) · 1.55 KB
/
CustomToolBar.cpp
File metadata and controls
executable file
·75 lines (62 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// CustomToolBar.cpp : implementation file
//
#include "stdafx.h"
#include "xitong.h"
#include "CustomToolBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCustomToolBar
CCustomToolBar::CCustomToolBar()
{
}
CCustomToolBar::~CCustomToolBar()
{
}
BEGIN_MESSAGE_MAP(CCustomToolBar, CToolBarCtrl)
//{{AFX_MSG_MAP(CCustomToolBar)
//}}AFX_MSG_MAP
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnOwnerDraw)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCustomToolBar message handlers
void CCustomToolBar::OnOwnerDraw(NMHDR *pNotifyStruct, LRESULT *pResult)
{
NMTBCUSTOMDRAW *pCustomDraw = (NMTBCUSTOMDRAW *)pNotifyStruct;
CDC dc;
dc.Attach(pCustomDraw->nmcd.hdc);
pCustomDraw->clrText = RGB(0,0,255);
switch (pCustomDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
DrawButton(&dc, pCustomDraw->nmcd.rc, pCustomDraw->nmcd.uItemState);
*pResult = TBCDRF_NOEDGES; //不绘按钮边框
break;
}
dc.Detach();
}
void CCustomToolBar::DrawButton(CDC *pDC, const RECT &rect, UINT uState)
{
CPoint pt;
GetCursorPos(&pt);
ScreenToClient(&pt);
CRect rc;
GetClientRect(rc);
if(rc.PtInRect(pt))
{
if(uState & CDIS_HOT)
{
CBrush Brush(RGB(220, 220, 220));
pDC->SelectObject(&Brush);
pDC->Rectangle(&rect);
pDC->DrawEdge(CRect(rect),BDR_RAISEDINNER|BDR_RAISEDOUTER,
BF_BOTTOMLEFT|BF_TOPRIGHT); //绘制立体效果
}
}
}