小心=TCN_SELCHANGE和=TCN_SELCHANGING,今天使用CTabCtrl的时候,没有注意有两个消息都可以在选择选项卡的时候都有相应,想当然的用了SELCHANGING那个,但是在进入消息响应之后,获取当前选项卡的序列号一直不对,一直都是前一个的序列号,纠结了将近一个多小时,后来发现,还有一个SELCHANGE消息,查了之后,才发现,选项卡改变之后,是先执行=TCN_SELCHANGING,后执行=TCN_SELCHANGE,在执行=TCN_SELCHANGING的时候,选项卡还未最终完成切换,所以获取的当前序列一直都是之前哪一个的,而这里要获取切换后的,要用=TCN_SELCHANGE消息。
小心啊!!
PS:最近看了别人的界面,额,受打击了。。。完全不是一个等级的。。。
TCN_SELCHANGE notification code
Notifies a tab control's parent window that the currently selected tab has changed. This notification code is sent in the form of a WM_NOTIFY message.
TCN_SELCHANGE lpnmhdr = (LPNMHDR) lParam;
Parameters
-
lParam
-
Pointer to an NMHDR structure that contains additional information about this notification.
Return value
No return value.
Remarks
To determine the currently selected tab, use the TabCtrl_GetCurSel macro.
Requirements
Minimum supported client | Windows 2000 Professional [desktop apps only] |
---|---|
Minimum supported server | Windows 2000 Server [desktop apps only] |
Header |
|
See also
TCN_SELCHANGING notification code
Notifies a tab control's parent window that the currently selected tab is about to change. This notification code is sent in the form of a WM_NOTIFY message.
TCN_SELCHANGING lpnmhdr = (LPNMHDR) lParam;
Parameters
-
lParam
-
Pointer to an NMHDR structure that contains additional information about this notification.
Return value
Returns TRUE to prevent the selection from changing, or FALSE to allow the selection to change.
Remarks
To determine the currently selected tab, use the TabCtrl_GetCurSel macro.
Requirements
Minimum supported client | Windows 2000 Professional [desktop apps only] |
---|---|
Minimum supported server | Windows 2000 Server [desktop apps only] |
Header |
|
See also
Send comments about this topic to Microsoft
Build date: 10/27/2012