#include "CustomTabCtrl.h"
//////////////////////////////////////////////////////////////////////////
CCustomTabItem::CCustomTabItem(CString sText, LPARAM lParam) :
m_sText(sText),
m_lParam(lParam),
m_bShape(TAB_INVISIBLE),
m_fSelected(FALSE),
m_fHighlighted(FALSE),
m_fHighlightChanged(FALSE)
{
}
//////////////////////////////////////////////////////////////////////////
void CCustomTabItem::operator=(const CCustomTabItem &other)
{
m_sText = other.m_sText;
m_lParam = other.m_lParam;
}
//////////////////////////////////////////////////////////////////////////
void CCustomTabItem::Draw(CDC& dc, CFont& font, TabItemColors *pColors, BOOL fOnTop, BOOL fNoLines)
{
COLORREF bgColor, fgColor;
if(m_fSelected || m_fHighlighted)
{
bgColor=pColors->crBkgActive;
fgColor=pColors->crTxtActive;
}
else
{
bgColor=pColors->crBkgInactive;
fgColor=pColors->crTxtInactive;
}
CBrush brush(bgColor);
CPen blackPen(PS_SOLID, 1, pColors->crDarkLine);
CPen shadowPen(PS_SOLID, 1, pColors->crLightLine);
CRect rc = m_rect;
// Paint item background
dc.FillRect(&m_rect, &brush);
CPen* pOldPen = dc.SelectObject(&blackPen);
if(!fNoLines)
{
if(fOnTop)
{
dc.MoveTo(rc.left, rc.bottom);
dc.LineTo(rc.left, rc.top);
dc.LineTo(rc.right, rc.top);
dc.LineTo(rc.right, rc.bottom);
}
else
{
dc.MoveTo(rc.left, rc.top);
dc.LineTo(rc.left, rc.bottom-1);
dc.LineTo(rc.right, rc.bottom-1);
dc.LineTo(rc.right, rc.top);
}
}
// draw item text
COLORREF bgOldColor = dc.SetBkColor(bgColor);
COLORREF fgOldColor = dc.SetTextColor(fgColor);
rc.DeflateRect(rc.Height()/2, 2, rc.Height()/2, 2);
CFont* pOldFont = dc.SelectObject(&font);
dc.DrawText(m_sText, &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
dc.SelectObject(pOldFont);
dc.SetTextColor(fgOldColor);
dc.SetBkColor(bgOldColor);
dc.SelectObject(pOldPen);
}
//////////////////////////////////////////////////////////////////////////
#ifdef _WIN32_WCE
LOGFONT CCustomTabCtrl::lf_default = {12, 0, 0, 0, FW_NORMAL, 0, 0, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Tahoma") };
LOGFONT CCustomTabCtrl::lf_default_vga = {24, 0, 0, 0, FW_NORMAL, 0, 0, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Tahoma") };
#else
LOGFONT CCustomTabCtrl::lf_default = {12, 0, 0, 0, FW_NORMAL, 0, 0, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Microsoft Sans Serif") };
#endif
BYTE CCustomTabCtrl::m_bBitsGlyphs[] = {
0xBD,0xFB,0xDF,0xBD,0x3C,0x00,
0xB9,0xF3,0xCF,0x9D,0x99,0x00,
0xB1,0xE3,0xC7,0x8D,0xC3,0x00,
0xA3,0xC7,0xE3,0xC5,0xE7,0x00,
0xB1,0xE3,0xC7,0x8D,0xC3,0x00,
0xB9,0xF3,0xCF,0x9D,0x99,0x00,
0xBD,0xFB,0xDF,0xBD,0x3C,0x00
};
IMPLEMENT_DYNAMIC(CCustomTabCtrl, CWnd)
//////////////////////////////////////////////////////////////////////////
CCustomTabCtrl::CCustomTabCtrl() :
m_nButtonIDDown(CTCID_NOBUTTON),
m_nPrevState(BNST_INVISIBLE),
m_nNextState(BNST_INVISIBLE),
m_nFirstState(BNST_INVISIBLE),
m_nLastState(BNST_INVISIBLE),
m_nCloseState(BNST_INVISIBLE),
m_nItemSelected(-1),
m_nFirstVisibleItem(0),
m_dwLastRepeatTime(0),
m_nItemDragDest(0)
{
RegisterWindowClass();
m_bmpGlyphsMono.CreateBitmap(48, 7, 1, 1, m_bBitsGlyphs);
//initialize tab/tabitem colors
m_ticColors.crBkgInactive=GetSysColor(COLOR_3DFACE);
m_ticColors.crBkgActive=GetSysColor(COLOR_WINDOW);
m_ticColors.crTxtInactive=GetSysColor(COLOR_BTNTEXT);
m_ticColors.crTxtActive=GetSysColor(COLOR_WINDOWTEXT);
m_ticColors.crDarkLine=GetSysColor(COLOR_BTNTEXT);
m_ticColors.crLightLine=GetSysColor(COLOR_3DSHADOW);
m_ticColors.crWndBkg=GetSysColor(COLOR_WINDOW);
if(GetSystemMetrics(SM_CYSCREEN) > 320 || GetSystemMetrics(SM_CXSCREEN) > 320)
{
//vga device?
m_nTabsHeight=50;
SetControlFont(lf_default_vga);
}
else
{
m_nTabsHeight=25;
SetControlFont(lf_default);
}
}
// Register the window class if it has not already been registered.
//////////////////////////////////////////////////////////////////////////
BOOL CCustomTabCtrl::RegisterWindowClass()
{
WNDCLASS wndcls;
HINSTANCE hInst;
hInst = AfxGetInstanceHandle();
if(!(::GetClassInfo(hInst, CustomTabCtrl_CLASSNAME, &wndcls)))
{
wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
wndcls.lpfnWndProc = ::DefWindowProc;
wndcls.cbClsExtra = wndcls.cbWndExtra = 0;
wndcls.hInstance = hInst;
wndcls.hIcon = NULL;
wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1);
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = CustomTabCtrl_CLASSNAME;
if(!AfxRegisterClass(&wndcls))
{
AfxThrowResourceException();
return FALSE;
}
}
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
CCustomTabCtrl::~CCustomTabCtrl()
{
int i;
for(i=0; i< m_aItems.GetSize(); i++)
{
delete m_aItems[i];
}
m_aItems.RemoveAll();
}
BEGIN_MESSAGE_MAP(CCustomTabCtrl, CWnd)
//{{AFX_MSG_MAP(CCustomTabCtrl)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_PAINT()
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_LBUTTONDBLCLK()
ON_WM_TIMER()
ON_EN_UPDATE(CTCID_EDITCTRL, OnUpdateEdit)
#ifndef _WIN32_WCE
ON_WM_RBUTTONDBLCLK()
ON_WM_RBUTTONDOWN()
#endif
ON_MESSAGE(TCM_ADJUSTRECT, OnTcmAdjustRect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//////////////////////////////////////////////////////////////////////////
void CCustomTabCtrl::AdjustRect(BOOL bLarger, LPRECT lpRect)
{
if(IsWindow(m_hWnd))
{
::SendMessage(m_hWnd, TCM_ADJUSTRECT, bLarger, (LPARAM)lpRect);
}
}
//////////////////////////////////////////////////////////////////////////
LRESULT CCustomTabCtrl::OnTcmAdjustRect(WPARAM wParam, LPARAM lParam)
{
LPRECT pRect;
pRect=(LPRECT)lParam;
if(pRect == NULL)
{
return 0;
}
if(IsContainer())
{
if(wParam)
{
//return entire window rect
GetWindowRect(pRect);
}
else
{
if(GetStyle() & CTCS_TOP)
{
pRect->top = m_nTabsHeight;
}
else
{
pRect->bottom -= m_nTabsHeight;
}
}
}
else
{
//not a container, AdjustRect not supported
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
//get tabs height (makes sense if has container style)
int CCustomTabCtrl::GetTabsHeight()
{
CRect rc;
if(IsContainer())
{
return m_nTabsHeight;
}
else
{
GetClientRect(&rc);
if(IsVertical())
{
return rc.Width();
}
else
{
return rc.Height();
}
}
}
//////////////////////////////////////////////////////////////////////////
//set tabs height (makes sense if has container style)
void CCustomTabCtrl::SetTabsHeight(int nHeight)
{
m_nTabsHeight=nHeight;
RecalcLayout(RECALC_RESIZED, m_nItemSelected);
}
//////////////////////////////////////////////////////////////////////////
//set control colors, and optionally redraw.
void CCustomTabCtrl::SetColors(TabItemColors *pColorsIn, BOOL fRedraw)
{
if(pColorsIn != NULL)
{
m_ticColors.crBkgActive = pColorsIn->crBkgActive;
m_ticColors.crBkgInactive = pColorsIn->crBkgInactive;
m_ticColors.crDarkLine = pColorsIn->crDarkLine;
m_ticColors.crLightLine = pColorsIn->crLightLine;
m_ticColors.crTxtActive = pColorsIn->crTxtActive;
m_ticColors.crTxtInactive = pColorsIn->crTxtInactive;
m_ticColors.crWndBkg = pColorsIn->crWn
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
PeekPocket.rar (61个子文件)
PeekPocket
ListCtrlEx.h 680B
CustomButton.cpp 38KB
PeekPocket.suo 98KB
CustomTabCtrl.cpp 58KB
PeekPocket.vcproj 9KB
stdafx.h 2KB
PeekPocket.h 3KB
ScannerDlg.cpp 14KB
CustomButton.h 4KB
CustomSlider.h 2KB
PeekPocketppc.aps 53KB
PeekPocket.ncb 12.23MB
PeekPocketppc.rc 7KB
resourceppc.h 2KB
OptionsDlg.h 1KB
ScannerDlg.h 1KB
ColoredDlg.cpp 2KB
Pocket PC 2003 (ARMV4)
Debug
PeekPocket.pch 9.44MB
CustomTabCtrl.obj 326KB
OptionsDlg.obj 119KB
vc80.pdb 324KB
stdafx.obj 124KB
PeekPocket.exe 1.62MB
PeekPocket.obj 29KB
BuildLog.htm 7KB
CustomButton.obj 188KB
ListCtrlEx.obj 22KB
ColoredDlg.obj 24KB
ScannerDlg.obj 134KB
vc80.idb 699KB
PPDlg.obj 198KB
PeekPocketppc.res 41KB
WifiPeek.obj 20KB
CustomSlider.obj 86KB
PeekPocket.pdb 4.67MB
stdafx.cpp 210B
CustomSlider.cpp 14KB
PeekPocket.sln 1KB
PeekPocket.cpp 1KB
CustomTabCtrl.h 9KB
ColoredDlg.h 904B
WifiPeek.h 939B
OptionsDlg.cpp 9KB
res
ap.ico 4KB
channel.bmp 7KB
peer1_16x16x8.bmp 1KB
peer1_16x16x8_2.bmp 1KB
thumbi.bmp 2KB
PeekPocketppc.rc2 653B
vol1_16x16x8.bmp 822B
Thumbs.db 15KB
thumba.bmp 2KB
sonar.wav 14KB
lock1_16x16x8_2.bmp 822B
vol1_16x16x8_2.bmp 822B
lock1_16x16x8.bmp 822B
WifiPeek.cpp 6KB
ListCtrlEx.cpp 787B
PPDlg.h 2KB
PPDlg.cpp 11KB
PeekPocket.vcproj.WANGWENHAO.Administrator.user 2KB
共 61 条
- 1
资源评论
- szhzfzh2013-01-07不错,可以借鉴下
- cxixi2012-12-26有一定的参考价值
yonghengwwh
- 粉丝: 2
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功