我有一个CTabCtrl的控件,当它向父窗口发送TCN_SELCHANGE消息的时候,在父窗口的处理程序中我想判断该消息是否是由鼠标单击控件而发生的。因为如果直接调用控件的SetCurSel方法也会发送TCN_SELCHANGE消息,我想区分这种情况。
我想能不能在消息处理的函数中获得发送消息时鼠标的位置,然后调用HitTest函数去看看是否是单击了控件的某个Item. 或者还有什么别的方法,恳请帮助!

解决方案 »

  1.   

    谢谢LS,响应NM_CLICK应该能做到,不过因为原来的代码就是响应TCN_SELCHANGE,我不想改动得太大,难道处理TCN_SELCHANGE中没有办法做到吗?
      

  2.   

    Selects a tab in a tab control. 
    int SetCurSel(
      int nItem 
    );
     
    Parameters
    nItem
    The zero-based index of the item to be selected.Return Value
    Zero-based index of the previously selected tab if successful, otherwise – 1.Res
    A tab control does not send a TCN_SELCHANGING or TCN_SELCHANGE notification message when a tab is selected using this function. These notifications are sent, using WM_NOTIFY, when the user clicks or uses the keyboard to change tabs.
    按照msdn上的说法 调用SetCurSel 没有发送TCN_SELCHANGE 消息啊