DrawTabItem() приватный Метод

Draws certain tab.
private DrawTabItem ( Graphics g, int index, TabItemState state, Rectangle tabRect, StringFormat textFmt ) : void
g System.Drawing.Graphics The object used to draw tab control.
index int Index of the tab being drawn.
state TabItemState State of the tab item.
tabRect System.Drawing.Rectangle The object specifying tab bounds.
textFmt System.Drawing.StringFormat The object specifying text formatting /// in the tab.
Результат void
Пример #1
0
 protected override void WndProc(ref Message m)
 {
     //if native updown is destroyed we need release our hook
     if (m.Msg == NativeMethods.WM_DESTROY || m.Msg == NativeMethods.WM_NCDESTROY)
     {
         this.ReleaseHandle();
     }
     else if (m.Msg == NativeMethods.WM_WINDOWPOSCHANGING)
     {
         //When scroller position is changed we should remember that new position.
         x = ((NativeMethods.WINDOWPOS)m.GetLParam(typeof(NativeMethods.WINDOWPOS))).x;
     }
     else if (m.Msg == NativeMethods.WM_MOUSEMOVE && fparent.lastHotIndex > 0 &&
              fparent.lastHotIndex != fparent.SelectedIndex)
     {
         //owerdrawing former hot tab as normal
         using (Graphics context = Graphics.FromHwnd(fparent.Handle))
         {
             using (StringFormat textFormat = new StringFormat())
             {
                 textFormat.Alignment     = StringAlignment.Center;
                 textFormat.LineAlignment = StringAlignment.Center;
                 fparent.DrawTabItem(context, fparent.lastHotIndex, TabItemState.Normal,
                                     fparent.GetTabRect(fparent.lastHotIndex), textFormat);
                 if (fparent.lastHotIndex - fparent.SelectedIndex == 1)
                 {
                     Rectangle selRect = fparent.GetTabRect(fparent.SelectedIndex);
                     selRect.Inflate(2, 2);
                     fparent.DrawTabItem(context, fparent.SelectedIndex, TabItemState.Selected, selRect, textFormat);
                 }
             }
         }
     }
     else if (m.Msg == NativeMethods.WM_LBUTTONDOWN)
     {
         Rectangle invalidRect = fparent.GetTabRect(fparent.SelectedIndex);
         invalidRect.X = 0; invalidRect.Width = 2;
         invalidRect.Inflate(0, 2);
         fparent.Invalidate(invalidRect);
     }
     else if (m.Msg == NativeMethods.WM_SHOWWINDOW)
     {
         // If the scroll control for the labels is being hidden we need to stop
         // clipping the labels.
         // USUALLY we get WM_WINDOWPOSCHANGING with position 0 as well as this
         // message, but not while starting up a parent control that gets laid out
         // twice, first at a width that needs the scroll control and later at a width
         // that does not. See FWR-1794 for one case where this can be a problem.
         if (m.WParam.ToInt32() == 0)                     // window being hidden
         {
             x = 0;
         }
     }
     base.WndProc(ref m);
 }
Пример #2
0
 protected override void WndProc(ref Message m)
 {
     //if native updown is destroyed we need release our hook
     if (m.Msg == NativeMethods.WM_DESTROY || m.Msg == NativeMethods.WM_NCDESTROY)
     {
         this.ReleaseHandle();
     }
     else if (m.Msg == NativeMethods.WM_WINDOWPOSCHANGING)
     {
         //When scroller position is changed we should remember that new position.
         x = ((NativeMethods.WINDOWPOS)m.GetLParam(typeof(NativeMethods.WINDOWPOS))).x;
     }
     else if (m.Msg == NativeMethods.WM_MOUSEMOVE && fparent.lastHotIndex > 0 &&
              fparent.lastHotIndex != fparent.SelectedIndex)
     {
         //owerdrawing former hot tab as normal
         using (Graphics context = Graphics.FromHwnd(fparent.Handle))
         {
             StringFormat textFormat = new StringFormat();
             textFormat.Alignment     = StringAlignment.Center;
             textFormat.LineAlignment = StringAlignment.Center;
             fparent.DrawTabItem(context, fparent.lastHotIndex, TabItemState.Normal,
                                 fparent.GetTabRect(fparent.lastHotIndex), textFormat);
             if (fparent.lastHotIndex - fparent.SelectedIndex == 1)
             {
                 Rectangle selRect = fparent.GetTabRect(fparent.SelectedIndex);
                 selRect.Inflate(2, 2);
                 fparent.DrawTabItem(context, fparent.SelectedIndex, TabItemState.Selected, selRect, textFormat);
             }
         }
     }
     else if (m.Msg == NativeMethods.WM_LBUTTONDOWN)
     {
         Rectangle invalidRect = fparent.GetTabRect(fparent.SelectedIndex);
         invalidRect.X = 0; invalidRect.Width = 2;
         invalidRect.Inflate(0, 2);
         fparent.Invalidate(invalidRect);
     }
     base.WndProc(ref m);
 }