如何任意定制TabControl标签的形状和位置?

mopyman 2008-03-22 02:01:13
想自绘TabControl,但不知道更改了标签的形状和位置后,如何处理WM_NCHITTEST来指示鼠标点击的位置,或者说落在新标签的位置上应该反回什么样的值?
...全文
371 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yebeans 2008-03-22
  • 打赏
  • 举报
回复
网上有个自绘的Tab代码,你搜一下CSkinTab
cnzdgs 2008-03-22
  • 打赏
  • 举报
回复
你需要自己派生一个类,重载WindowProc函数并响应TCM_HITTEST消息,你要返回的是符合条件的索引值或者-1。
mopyman 2008-03-22
  • 打赏
  • 举报
回复
spy++无法截获TCM_HITTEST消息
mopyman 2008-03-22
  • 打赏
  • 举报
回复
To yxz_lp:
tab control内部会用TCM_HITTEST来决定是点击到了哪个tab上?我感觉好像是给用户使用的一个函数,
用户可以截获这个消息吗?
yxz_lp 2008-03-22
  • 打赏
  • 举报
回复
返回 TCHITTESTINFO结构
Determines which tab, if any, is at a specified screen position. You can use this macro or send the TCM_HITTEST message explicitly.

Syntax

int TabCtrl_HitTest(
HWND hwnd,
LPTCHITTESTINFO pinfo
);

Parameters

hwnd
Handle to the tab control.
pinfo
Pointer to a TCHITTESTINFO structure that specifies the screen position to test.
//////////////////////////////////
TCHITTESTINFO Structure

--------------------------------------------------------------------------------

Contains information about a hit test. This structure supersedes the TC_HITTESTINFO structure.

Syntax

typedef struct tagTCHITTESTINFO {
POINT pt;
UINT flags;
} TCHITTESTINFO, *LPTCHITTESTINFO;
Members

pt
Position to hit test, in client coordinates.
flags
Variable that receives the results of a hit test. The tab control sets this member to one of the following values:
TCHT_NOWHERE
The position is not over a tab.
TCHT_ONITEM
The position is over a tab but not over its icon or its text. For owner-drawn tab controls, this value is specified if the position is anywhere over a tab.
TCHT_ONITEMICON
The position is over a tab's icon.
TCHT_ONITEMLABEL
The position is over a tab's text.
TCHT_ONITEM is a bitwise-OR operation on TCHT_ONITEMICON and TCHT_ONITEMLABEL.

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧