Stop Tab Page being selected in TabControl

  • Thread starter Thread starter Steve Amey
  • Start date Start date
S

Steve Amey

Hi all

I want to be able to prevent a particular tab from being selected at
run-time, how would I go about doing that?

At the moment, I have created a custom control and inherited the TabControl.
I then override the WndProc method and trap the WM_NCHITTEST message (I
don't know if this is the correct message to watch out for).

I need to check to see if the tab that they are clicking on is Enabled or
not (Eg. TabPage1.Enabled = False) and if the Enabled is False then I want
to ignore the message so the tab doesn't change, otherwise forward the
message on as normal.

Am I going about it the right way or is there a better way to do this??

Kind Regards,
Steve.
 
Hi all

Ok. I have the code I need to disable the tab page, but this code is run in
the OnDrawItem event, and this event doesn't get fired until the tab page
either gets focus or loses focus, so if I set the Enabled property to False
and I'm not already on the tab, it will never appear to be greyed out.

So my question is, how can I force the OnDrawItem event? If I can do some
sort of refresh for the tab page I have just set the Enabled property for
then the event will be run and the tab page will be disabled.

Kind Regards,
Steve.
 
Back
Top