Answered Tabpage click event needed

  • Saturday, July 14, 2012 10:16 AM
     
     
    I need to get the click event when the cursor is on any tabpage. Now the tab pages are "covered" or filled or hidden completely by lots of other controls on it and so something like tabpage_Click(.....) will not work since it is not visible. Any help will be appreciated.
    • Edited by OrionWalli Saturday, July 14, 2012 10:17 AM
    •  

All Replies

  • Monday, July 16, 2012 4:58 AM
    Moderator
     
     Answered Has Code

    Hi OrionWalli,

    I think you can handle the WM_PARENTNOTIFY message to capture mouse input of all child control.

    public class MyTabControl : TabControl
    {
        const int WM_PARENTNOTIFY = 0x0210;
        const int WM_LBUTTONDOWN = 0x0201;
        protected override void WndProc(ref Message m)
        {
            if (!this.DesignMode)
            {
                if (m.Msg == WM_PARENTNOTIFY)
                {
                    if (m.WParam.ToInt32() == WM_LBUTTONDOWN)
                    {
                        //do you staff
                    }
                }
            }
            base.WndProc(ref m);
        }
    }
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked As Answer by OrionWalli Tuesday, July 17, 2012 9:32 AM
    •