private int scUpDown_SubClassedWndProc(ref Message m) { switch (m.Msg) { case Win32.WM_PAINT: { //------------------------ // redraw IntPtr hDC = Win32.GetWindowDC(scUpDown.Handle); Graphics g = Graphics.FromHdc(hDC); DrawIcons(g); g.Dispose(); Win32.ReleaseDC(scUpDown.Handle, hDC); //------------------------ // return 0 (processed) m.Result = IntPtr.Zero; //------------------------ // validate current rect Rectangle rect = new Rectangle(); Win32.GetClientRect(scUpDown.Handle, ref rect); Win32.ValidateRect(scUpDown.Handle, ref rect); //------------------------ } return(1); } return(0); }
private void UpdateUpDown() { if (bUpDown) { if (Win32.IsWindowVisible(scUpDown.Handle)) { Rectangle rect = new Rectangle(); Win32.GetClientRect(scUpDown.Handle, ref rect); Win32.InvalidateRect(scUpDown.Handle, ref rect, true); } } }
internal void DrawIcons(Graphics g) { if ((leftRightImages == null) || (leftRightImages.Images.Count != 4)) { return; } //---------------------------- // calc positions Rectangle TabControlArea = this.ClientRectangle; Rectangle r0 = new Rectangle(); Win32.GetClientRect(scUpDown.Handle, ref r0); Brush br = new SolidBrush(SystemColors.Control); g.FillRectangle(br, r0); br.Dispose(); Color color = Color.FromArgb(SystemColors.Control.A, SystemColors.Control.R, SystemColors.Control.G, SystemColors.Control.B); if (this.SelectedTab != null) { color = this.SelectedTab.BackColor; } Pen border = new Pen(color); Rectangle rborder = r0; rborder.Inflate(-1, -1); g.DrawRectangle(border, rborder); border.Dispose(); int nMiddle = (r0.Width / 2); int nTop = (r0.Height - 16) / 2; int nLeft = (nMiddle - 16) / 2; Rectangle r1 = new Rectangle(nLeft, nTop, 16, 16); Rectangle r2 = new Rectangle(nMiddle + nLeft, nTop, 16, 16); //---------------------------- //---------------------------- // draw buttons Image img = leftRightImages.Images[1]; if (img != null) { if (this.TabCount > 0) { Rectangle r3 = this.GetTabRect(0); if (r3.Left < TabControlArea.Left) { g.DrawImage(img, r1); } else { img = leftRightImages.Images[3]; if (img != null) { g.DrawImage(img, r1); } } } } img = leftRightImages.Images[0]; if (img != null) { if (this.TabCount > 0) { Rectangle r3 = this.GetTabRect(this.TabCount - 1); if (r3.Right > (TabControlArea.Width - r0.Width)) { g.DrawImage(img, r2); } else { img = leftRightImages.Images[2]; if (img != null) { g.DrawImage(img, r2); } } } } //---------------------------- }