// HmVerticalTab.h: interface for the CHmTab class.
|
//
|
//////////////////////////////////////////////////////////////////////
|
|
#if !defined(AFX_HMVERTICALTAB_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_)
|
#define AFX_HMVERTICALTAB_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_
|
|
|
#pragma comment(lib, "Msimg32.lib") // TransparentBlt
|
#include <vector>
|
|
|
|
//====== HmTab =====================================================
|
|
#ifndef NOHMVERTICALTAB
|
|
#ifdef _WIN32
|
|
#define HMVERTICALTAB_CLASSA "HmVerticalTab"
|
#define HMVERTICALTAB_CLASSW L"HmVerticalTab"
|
|
#ifdef UNICODE
|
#define HMVERTICALTAB_CLASS HMVERTICALTAB_CLASSW
|
#else
|
#define HMVERTICALTAB_CLASS HMVERTICALTAB_CLASSA
|
#endif
|
|
#else
|
#define HMVERTICALTAB_CLASS "HmVerticalTab"
|
#endif
|
|
|
#define TAG_HMVERTICALTAB _T("IsHmVerticalTab")
|
|
|
//====== WM_NOTIFY codes (NMHDR.code values) ==================================
|
#define HMVERTICALTAB_FIRST (0U-3370U) //
|
#define HMVERTICALTAB_LAST (0U-3350U)
|
#define HMVERTICALTAB_SEL_CHANGED (HMVERTICALTAB_FIRST - 1)
|
|
|
|
typedef struct tagHMVERTICALTAB_NMHDR
|
{
|
NMHDR nmhdr;
|
DWORD_PTR dwData;
|
DWORD_PTR dwData1;
|
DWORD_PTR dwData2;
|
} HMVERTICALTAB_NMHDR;
|
|
#define HMVERTICALTAB_ITEM_TEXT_MAX 64
|
|
typedef struct tagHMVERTICALTABITEM
|
{
|
int id;
|
char szText[HMVERTICALTAB_ITEM_TEXT_MAX];
|
RECT rect;
|
void* context;
|
} HMVERTICALTABITEM;
|
|
#define HMTAB_HITCODETEST _T("HitCode")
|
#define HMTAB_HT_NOWHERE 0x1
|
#define HMTAB_HT_ITEM 0x2
|
#define HMTAB_HT_HIGT_ITEM 0x4
|
|
|
#endif
|
|
|
|
|
#if _MSC_VER > 1000
|
#pragma once
|
#endif // _MSC_VER > 1000
|
|
|
class CHmVerticalTab
|
{
|
public:
|
CHmVerticalTab();
|
virtual ~CHmVerticalTab();
|
|
public:
|
static BOOL RegisterWndClass();
|
static CHmVerticalTab* Hook(HWND hWnd);
|
void Notify(int nCode, DWORD_PTR dwData, DWORD_PTR dwData1 = 0, DWORD_PTR dwData2 = 0);
|
void Release();
|
void SetBkgndColor(COLORREF cr);
|
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
static LRESULT OnNcCreate(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
LRESULT OnDestroy(WPARAM wParam, LPARAM lParam);
|
LRESULT OnTimer(WPARAM wParam, LPARAM lParam);
|
LRESULT OnPaint(WPARAM wParam, LPARAM lParam);
|
LRESULT OnSetCursor(WPARAM wParam, LPARAM lParam);
|
LRESULT OnSize(WPARAM wParam, LPARAM lParam);
|
LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam);
|
LRESULT OnMouseMove(WPARAM wParam, LPARAM lParam);
|
|
|
public:
|
void SetPaddingTop(int value);
|
void SetItemMarginTop(int value);
|
void SetTextColor(COLORREF color1, COLORREF color2);
|
void SetItemBkgndColor(COLORREF color1, COLORREF color2);
|
void SetHightLineVisible(BOOL bVisible);
|
int AddItem(const char* pszText, void* pContext = nullptr, BOOL bUpdate = TRUE);
|
int DeleteItem(const char* pszText, BOOL bUpdate = TRUE);
|
void* GetContext(unsigned int index);
|
int HighTest(POINT pt, OUT HMVERTICALTABITEM*& pItem, int* pnIndex);
|
int GetCurSel();
|
void SetCurSel(int index);
|
int GetItemCount();
|
|
|
private:
|
HWND m_hWnd;
|
COLORREF m_crBkgnd;
|
|
private:
|
int m_nCurSel;
|
int m_nItemHeight;
|
std::vector< HMVERTICALTABITEM > m_items;
|
HMVERTICALTABITEM* m_pHighItem;
|
HMVERTICALTABITEM* m_pPressItem;
|
int m_nPaddingTop;
|
int m_nItemMarginTop;
|
COLORREF m_crText[2];
|
COLORREF m_crItemBkgnd[2]; // ×ÓÏî±³¾°É«£¬0£ºÑ¡ÖУ¬1£º¸ßÁÁ
|
HBRUSH m_hbrItemBkgnd[2]; // ÉÏÊöÁ½ÏîÔ¤´´½¨
|
HPEN m_hPenUnder[2];
|
HPEN m_hPenUnderWnd;
|
BOOL m_bShowHightLine;
|
};
|
|
#endif // !defined(AFX_HMVERTICALTAB_H__FBB8916A_DE77_4EA3_9C21_E51E6B06194C__INCLUDED_)
|