TabControl - Owner Drawn TabPage Dividers

G

Guest

Hi,

[ BTW I'm using C# ]

I am trying to create a custom style tab control. I've managed to code it
so far so that I can custom draw the TabPage dividers ( the buttons at the
top of the TabControl that select the TabPage ).

My ultimate goal is to have fancy style TabPage dividers which overlap.
I've created a Polygon ( GraphicsPath ) to draw these, but cant work out how
to perform the HitTest of overlapping dividers ( the standard control works
off rectangles only - which is useless for my overlapping dividers!! ).

Can I intercept the HitTest message - so that I can test against my Polygon
( GraphicsPath ) and then set the SelectedTab myself ? If so a bit of sample
could would be great.

regards,
Rich.
 
M

Mick Doherty

With the amount of work involved and the limitations you are going to face,
I would suggest recreating the TabControl from scratch, i.e. do not inherit
from TabControl. It's something I've started to do several times, but I keep
getting distracted by other projects.

If you really want to play around with the TabControl, then you'll find an
example of working with the HitTest method on my site. I have only used it
in the designer, but you can use the same method in the control itself. It
will need a little work to be used as you wish to use it, but I do not know
of any other example.
http://dotnetrix.co.uk/tabcontrols.html --> TabControl using custom
tabpages.

When taking full responsibility for drawing the tabcontrol, you will find
that the tabitemstrip does not resize in proportion to the font. For this
reason you may want to handle the message TCM_ADJUSTRECT so that you can
modify the size of the tabpage to give you more Non-Client Area. You could
send a WM_SETFONT message to the tabcontrol so as to change it's font size
internally, but you will find the method to be unreliable due to differences
between System.Drawing.Font and Win32 LogFont. This is the method I used in
the TabControlEX that is available from my Controls section.
 
G

Guest

Oh well, thanks for the response.

I originally started with my own TabControl, but decided to try to exploit
the WindowsForms TabControl hoping that it would be better.

I know that the use of my TabControl is going to be very limited so may I
can hack together something pretty quick.

regards,
Rich.

Mick Doherty said:
With the amount of work involved and the limitations you are going to face,
I would suggest recreating the TabControl from scratch, i.e. do not inherit
from TabControl. It's something I've started to do several times, but I keep
getting distracted by other projects.

If you really want to play around with the TabControl, then you'll find an
example of working with the HitTest method on my site. I have only used it
in the designer, but you can use the same method in the control itself. It
will need a little work to be used as you wish to use it, but I do not know
of any other example.
http://dotnetrix.co.uk/tabcontrols.html --> TabControl using custom
tabpages.

When taking full responsibility for drawing the tabcontrol, you will find
that the tabitemstrip does not resize in proportion to the font. For this
reason you may want to handle the message TCM_ADJUSTRECT so that you can
modify the size of the tabpage to give you more Non-Client Area. You could
send a WM_SETFONT message to the tabcontrol so as to change it's font size
internally, but you will find the method to be unreliable due to differences
between System.Drawing.Font and Win32 LogFont. This is the method I used in
the TabControlEX that is available from my Controls section.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html


RichS said:
Hi,

[ BTW I'm using C# ]

I am trying to create a custom style tab control. I've managed to code it
so far so that I can custom draw the TabPage dividers ( the buttons at the
top of the TabControl that select the TabPage ).

My ultimate goal is to have fancy style TabPage dividers which overlap.
I've created a Polygon ( GraphicsPath ) to draw these, but cant work out
how
to perform the HitTest of overlapping dividers ( the standard control
works
off rectangles only - which is useless for my overlapping dividers!! ).

Can I intercept the HitTest message - so that I can test against my
Polygon
( GraphicsPath ) and then set the SelectedTab myself ? If so a bit of
sample
could would be great.

regards,
Rich.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top