0

I need to modify this tabcontrol i found online, if i change the item height, the triable does not adjust properly

enter image description here

The code doing the drawing is

G.SmoothingMode = SmoothingMode.HighQuality
                Dim p() As Point = {New Point(ItemSize.Height - 3, GetTabRect(i).Location.Y + 20), _
                           New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14), _
                           New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 28)}
     G.FillPolygon(Brushes.White, p)
     G.DrawPolygon(New Pen(Color.FromArgb(170, 187, 204)), p)

I have made adjustments to the line New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + 14) without success.

i need the triangle albeit bigger and centered in the Tabpage rectangle if the size is adjusted, say by 3 points.

Any ideas

Smith
  • 5,765
  • 17
  • 102
  • 161

1 Answers1

1

I was able to find a solution after futher tinkering

 Dim hlf As Integer = GetTabRect(i).Height \ 2
G.SmoothingMode = SmoothingMode.HighQuality
            Dim p() As Point = {New Point(ItemSize.Height - 6, GetTabRect(i).Location.Y + hlf), _
      New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + hlf - 7), _
      New Point(ItemSize.Height + 4, GetTabRect(i).Location.Y + hlf + 7)}
Smith
  • 5,765
  • 17
  • 102
  • 161
  • It is better, but you are going to change it again sooner or later. Drawing code needs to be dpiAware today. One of the few good reasons to use Control.CreateGraphics(). – Hans Passant Sep 13 '18 at 11:23
  • P,ease can you explain more on that? – Smith Sep 13 '18 at 11:27
  • 14 pixels is but a fleck of dust on a high resolution 4k monitor, you just can't see it. Make it dpiAware by multiplying values like 4 and 7 by Graphics.DpiY / 96.0. ScaleTransform() can do it too, but harder to get right in this specific case. – Hans Passant Sep 13 '18 at 11:40
  • Yeah, thanks, i currently set the hosting form `this.AutoScaleMode = AutoScaleMode.Dpi`, this i guess should fix the problem as i dont have a high resolution monitor to test with now. however, any suggestion will be appreciated – Smith Sep 13 '18 at 11:52