private int scUpDown_SubClassedWndProc(ref Message m) { switch (m.Msg) { case CustomWin32.WM_PAINT: { //------------------------ // redraw IntPtr hDC = CustomWin32.GetWindowDC(scUpDown.Handle); Graphics g = Graphics.FromHdc(hDC); DrawIcons(g); g.Dispose(); CustomWin32.ReleaseDC(scUpDown.Handle, hDC); //------------------------ // return 0 (processed) m.Result = IntPtr.Zero; //------------------------ // validate current rect Rectangle rect = new Rectangle(); CustomWin32.GetClientRect(scUpDown.Handle, ref rect); CustomWin32.ValidateRect(scUpDown.Handle, ref rect); //------------------------ } return(1); } return(0); }
private void UpdateUpDown() { if (bUpDown) { if (CustomWin32.IsWindowVisible(scUpDown.Handle)) { Rectangle rect = new Rectangle(); CustomWin32.GetClientRect(scUpDown.Handle, ref rect); CustomWin32.InvalidateRect(scUpDown.Handle, ref rect, true); } } }
internal void DrawIcons(Graphics g) { if ((leftRightImages == null) || (leftRightImages.Images.Count != 4)) { return; } //---------------------------- // calculate positions Rectangle TabControlArea = this.ClientRectangle; Rectangle r0 = new Rectangle(); CustomWin32.GetClientRect(scUpDown.Handle, ref r0); Brush br = new SolidBrush(Color.FromArgb(120, 135, 156)); g.FillRectangle(br, r0); br.Dispose(); Pen border = new Pen(SystemColors.ControlDark); 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); } } } } //---------------------------- }