C# 自定义重绘TextBox
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- using System.ComponentModel;
- namespace ControlExs.ControlExs.TextBoxEx
- {
- public class QCTextBox : TextBox
- {
- #region Field
- private QQControlState _state = QQControlState.Normal;
- private Font _defaultFont = new Font("微软雅黑", );
- //当Text属性为空时编辑框内出现的提示文本
- private string _emptyTextTip;
- private Color _emptyTextTipColor = Color.DarkGray;
- #endregion
- #region Constructor
- public QCTextBox()
- {
- SetStyles();
- this.Font = _defaultFont;
- //this.AutoSize = true;
- this.BorderStyle = BorderStyle.None;
- }
- #endregion
- #region Properites
- [Description("当Text属性为空时编辑框内出现的提示文本")]
- public String EmptyTextTip
- {
- get { return _emptyTextTip; }
- set
- {
- if (_emptyTextTip != value)
- {
- _emptyTextTip = value;
- base.Invalidate();
- }
- }
- }
- [Description("获取或设置EmptyTextTip的颜色")]
- public Color EmptyTextTipColor
- {
- get { return _emptyTextTipColor; }
- set
- {
- if (_emptyTextTipColor != value)
- {
- _emptyTextTipColor = value;
- base.Invalidate();
- }
- }
- }
- private int _radius = ;
- [Description("获取或设置圆角弧度")]
- public int Radius
- {
- get { return _radius; }
- set {
- _radius = value;
- this.Invalidate();
- }
- }
- [Description("获取或设置是否可自定义改变大小")]
- public bool CustomAutoSize
- {
- get { return this.AutoSize; }
- set { this.AutoSize = value; }
- }
- #endregion
- #region Override
- protected override void OnMouseEnter(EventArgs e)
- {
- _state = QQControlState.Highlight;
- base.OnMouseEnter(e);
- }
- protected override void OnMouseLeave(EventArgs e)
- {
- if (_state == QQControlState.Highlight && Focused)
- {
- _state = QQControlState.Focus;
- }
- else if (_state == QQControlState.Focus)
- {
- _state = QQControlState.Focus;
- }
- else
- {
- _state = QQControlState.Normal;
- }
- base.OnMouseLeave(e);
- }
- protected override void OnMouseDown(MouseEventArgs mevent)
- {
- if (mevent.Button == MouseButtons.Left)
- {
- _state = QQControlState.Highlight;
- }
- base.OnMouseDown(mevent);
- }
- protected override void OnMouseUp(MouseEventArgs mevent)
- {
- if (mevent.Button == MouseButtons.Left)
- {
- if (ClientRectangle.Contains(mevent.Location))
- {
- _state = QQControlState.Highlight;
- }
- else
- {
- _state = QQControlState.Focus;
- }
- }
- base.OnMouseUp(mevent);
- }
- protected override void OnLostFocus(EventArgs e)
- {
- _state = QQControlState.Normal;
- base.OnLostFocus(e);
- }
- protected override void OnEnabledChanged(EventArgs e)
- {
- if (Enabled)
- {
- _state = QQControlState.Normal;
- }
- else
- {
- _state = QQControlState.Disabled;
- }
- base.OnEnabledChanged(e);
- }
- protected override void WndProc(ref Message m)
- {//TextBox是由系统进程绘制,重载OnPaint方法将不起作用
- base.WndProc(ref m);
- if (m.Msg == Win32.WM_PAINT || m.Msg == Win32.WM_CTLCOLOREDIT)
- {
- WmPaint(ref m);
- }
- }
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (_defaultFont != null)
- {
- _defaultFont.Dispose();
- }
- }
- _defaultFont = null;
- base.Dispose(disposing);
- }
- #endregion
- #region Private
- private void SetStyles()
- {
- // TextBox由系统绘制,不能设置 ControlStyles.UserPaint样式
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- SetStyle(ControlStyles.ResizeRedraw, true);
- SetStyle(ControlStyles.SupportsTransparentBackColor, true);
- UpdateStyles();
- }
- private void WmPaint(ref Message m)
- {
- Graphics g = Graphics.FromHwnd(base.Handle);
- //g.SmoothingMode = SmoothingMode.AntiAlias;
- //去掉 TextBox 四个角
- g.InterpolationMode = InterpolationMode.HighQualityBicubic;
- g.SmoothingMode = SmoothingMode.AntiAlias;
- SetWindowRegion(this.Width, this.Height);
- if (!Enabled)
- {
- _state = QQControlState.Disabled;
- }
- switch (_state)
- {
- case QQControlState.Normal:
- DrawNormalTextBox(g);
- break;
- case QQControlState.Highlight:
- DrawHighLightTextBox(g);
- break;
- case QQControlState.Focus:
- DrawFocusTextBox(g);
- break;
- case QQControlState.Disabled:
- DrawDisabledTextBox(g);
- break;
- default:
- break;
- }
- if (Text.Length == && !string.IsNullOrEmpty(EmptyTextTip) && !Focused)
- {
- TextRenderer.DrawText(g, EmptyTextTip, Font, ClientRectangle, EmptyTextTipColor, GetTextFormatFlags(TextAlign, RightToLeft == RightToLeft.Yes));
- }
- }
- private void DrawNormalTextBox(Graphics g)
- {
- using (Pen borderPen = new Pen(Color.LightGray))
- {
- //g.DrawRectangle(borderPen, new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1));
- g.DrawPath(borderPen, DrawHelper.DrawRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - , ClientRectangle.Height - , _radius));
- }
- }
- private void DrawHighLightTextBox(Graphics g)
- {
- using (Pen highLightPen = new Pen(ColorTable.QQHighLightColor))
- {
- //Rectangle drawRect = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
- //g.DrawRectangle(highLightPen, drawRect);
- g.DrawPath(highLightPen, DrawHelper.DrawRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - , ClientRectangle.Height - , _radius));
- //InnerRect
- //drawRect.Inflate(-1, -1);
- //highLightPen.Color = ColorTable.QQHighLightInnerColor;
- //g.DrawRectangle(highLightPen, drawRect);
- g.DrawPath(new Pen(ColorTable.QQHighLightInnerColor), DrawHelper.DrawRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - , ClientRectangle.Height - , _radius));
- }
- }
- private void DrawFocusTextBox(Graphics g)
- {
- using (Pen focusedBorderPen = new Pen(ColorTable.QQHighLightInnerColor))
- {
- //g.DrawRectangle(focusedBorderPen,new Rectangle(ClientRectangle.X,ClientRectangle.Y,ClientRectangle.Width - 1, ClientRectangle.Height - 1));
- g.DrawPath(focusedBorderPen, DrawHelper.DrawRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - , ClientRectangle.Height - , _radius));
- }
- }
- private void DrawDownTextBox(Graphics g)
- {
- using (Pen focusedBorderPen = new Pen(ColorTable.QQHighLightInnerColor))
- {
- //g.DrawRectangle(focusedBorderPen,new Rectangle(ClientRectangle.X,ClientRectangle.Y,ClientRectangle.Width - 1, ClientRectangle.Height - 1));
- g.DrawPath(focusedBorderPen, DrawHelper.DrawRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - , ClientRectangle.Height - , _radius));
- }
- }
- private void DrawDisabledTextBox(Graphics g)
- {
- using (Pen disabledPen = new Pen(SystemColors.ControlDark))
- {
- //g.DrawRectangle(disabledPen,new Rectangle( ClientRectangle.X,ClientRectangle.Y, ClientRectangle.Width - 1,ClientRectangle.Height - 1));
- g.DrawPath(disabledPen, DrawHelper.DrawRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - , ClientRectangle.Height - , _radius));
- }
- }
- private static TextFormatFlags GetTextFormatFlags(HorizontalAlignment alignment, bool rightToleft)
- {
- TextFormatFlags flags = TextFormatFlags.WordBreak |
- TextFormatFlags.SingleLine;
- if (rightToleft)
- {
- flags |= TextFormatFlags.RightToLeft | TextFormatFlags.Right;
- }
- switch (alignment)
- {
- case HorizontalAlignment.Center:
- flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter;
- break;
- case HorizontalAlignment.Left:
- flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.Left;
- break;
- case HorizontalAlignment.Right:
- flags |= TextFormatFlags.VerticalCenter | TextFormatFlags.Right;
- break;
- }
- return flags;
- }
- #endregion
- public void SetWindowRegion(int width, int height)
- {
- System.Drawing.Drawing2D.GraphicsPath FormPath = new System.Drawing.Drawing2D.GraphicsPath();
- Rectangle rect = new Rectangle(, , width, height);
- FormPath = GetRoundedRectPath(rect, _radius);
- this.Region = new Region(FormPath);
- }
- private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
- {
- int diameter = radius;
- Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
- GraphicsPath path = new GraphicsPath();
- // 左上角
- path.AddArc(arcRect, , );
- // 右上角
- arcRect.X = rect.Right - diameter;
- path.AddArc(arcRect, , );
- // 右下角
- arcRect.Y = rect.Bottom - diameter;
- path.AddArc(arcRect, , );
- // 左下角
- arcRect.X = rect.Left;
- path.AddArc(arcRect, , );
- path.CloseFigure();
- return path;
- }
- }
- }
- public enum QQControlState
- {
- /// <summary>
- /// 正常状态
- /// </summary>
- Normal = ,
- /// <summary>
- /// /鼠标进入
- /// </summary>
- Highlight = ,
- /// <summary>
- /// 鼠标按下
- /// </summary>
- Down = ,
- /// <summary>
- /// 获得焦点
- /// </summary>
- Focus = ,
- /// <summary>
- /// 控件禁止
- /// </summary>
- Disabled =
- }
- /// <summary>
- /// 实现仿QQ效果控件内部使用颜色表
- /// </summary>
- internal class ColorTable
- {
- public static Color QQBorderColor = Color.LightBlue; //LightBlue = Color.FromArgb(173, 216, 230)
- public static Color QQHighLightColor =RenderHelper.GetColor(QQBorderColor,,-,-,); //Color.FromArgb(110, 205, 253)
- public static Color QQHighLightInnerColor = RenderHelper.GetColor(QQBorderColor, , -, -, ); //Color.FromArgb(73, 172, 231);
- }
- internal class DrawHelper
- {
- public static GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius)
- {
- GraphicsPath gp = new GraphicsPath();
- gp.AddArc(x, y, radius, radius, , );
- gp.AddArc(width - radius, y, radius, radius, , );
- gp.AddArc(width - radius, height - radius, radius, radius, , );
- gp.AddArc(x, height - radius, radius, radius, , );
- gp.CloseAllFigures();
- return gp;
- }
- /// <summary>
- /// 绘制圆角矩形
- /// </summary>
- /// <param name="rect">矩形</param>
- /// <param name="radius">弯曲程度(0-10),越大越弯曲</param>
- /// <returns></returns>
- public static GraphicsPath DrawRoundRect(Rectangle rect, int radius)
- {
- int x = rect.X;
- int y = rect.Y;
- int width = rect.Width;
- int height = rect.Height;
- return DrawRoundRect(x, y, width - , height - , radius);
- }
- /// <summary>
- /// 得到两种颜色的过渡色(1代表开始色,100表示结束色)
- /// </summary>
- /// <param name="c">开始色</param>
- /// <param name="c2">结束色</param>
- /// <param name="value">需要获得的度</param>
- /// <returns></returns>
- public static Color GetIntermediateColor(Color c, Color c2, int value)
- {
- float pc = value * 1.0F / ;
- int ca = c.A, cr = c.R, cg = c.G, cb = c.B;
- int c2a = c2.A, c2r = c2.R, c2g = c2.G, c2b = c2.B;
- int a = (int)Math.Abs(ca + (ca - c2a) * pc);
- int r = (int)Math.Abs(cr - ((cr - c2r) * pc));
- int g = (int)Math.Abs(cg - ((cg - c2g) * pc));
- int b = (int)Math.Abs(cb - ((cb - c2b) * pc));
- if (a > ) { a = ; }
- if (r > ) { r = ; }
- if (g > ) { g = ; }
- if (b > ) { b = ; }
- return (Color.FromArgb(a, r, g, b));
- }
- public static StringFormat StringFormatAlignment(ContentAlignment textalign)
- {
- StringFormat sf = new StringFormat();
- switch (textalign)
- {
- case ContentAlignment.TopLeft:
- case ContentAlignment.TopCenter:
- case ContentAlignment.TopRight:
- sf.LineAlignment = StringAlignment.Near;
- break;
- case ContentAlignment.MiddleLeft:
- case ContentAlignment.MiddleCenter:
- case ContentAlignment.MiddleRight:
- sf.LineAlignment = StringAlignment.Center;
- break;
- case ContentAlignment.BottomLeft:
- case ContentAlignment.BottomCenter:
- case ContentAlignment.BottomRight:
- sf.LineAlignment = StringAlignment.Far;
- break;
- }
- return sf;
- }
- /// <summary>
- /// 绘图对像
- /// </summary>
- /// <param name="g">绘图对像</param>
- /// <param name="img">图片</param>
- /// <param name="r">绘置的图片大小、坐标</param>
- /// <param name="lr">绘置的图片边界</param>
- /// <param name="index">当前状态</param>
- /// <param name="Totalindex">状态总数</param>
- public static void DrawRect(Graphics g, Bitmap img, Rectangle r, Rectangle lr, int index, int Totalindex)
- {
- if (img == null) return;
- Rectangle r1, r2;
- int x = (index - ) * img.Width / Totalindex;
- int y = ;
- int x1 = r.Left;
- int y1 = r.Top;
- if (r.Height > img.Height && r.Width <= img.Width / Totalindex)
- {
- r1 = new Rectangle(x, y, img.Width / Totalindex, lr.Top);
- r2 = new Rectangle(x1, y1, r.Width, lr.Top);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- r1 = new Rectangle(x, y + lr.Top, img.Width / Totalindex, img.Height - lr.Top - lr.Bottom);
- r2 = new Rectangle(x1, y1 + lr.Top, r.Width, r.Height - lr.Top - lr.Bottom);
- if ((lr.Top + lr.Bottom) == ) r1.Height = r1.Height - ;
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- r1 = new Rectangle(x, y + img.Height - lr.Bottom, img.Width / Totalindex, lr.Bottom);
- r2 = new Rectangle(x1, y1 + r.Height - lr.Bottom, r.Width, lr.Bottom);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- }
- else
- if (r.Height <= img.Height && r.Width > img.Width / Totalindex)
- {
- r1 = new Rectangle(x, y, lr.Left, img.Height);
- r2 = new Rectangle(x1, y1, lr.Left, r.Height);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- r1 = new Rectangle(x + lr.Left, y, img.Width / Totalindex - lr.Left - lr.Right, img.Height);
- r2 = new Rectangle(x1 + lr.Left, y1, r.Width - lr.Left - lr.Right, r.Height);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- r1 = new Rectangle(x + img.Width / Totalindex - lr.Right, y, lr.Right, img.Height);
- r2 = new Rectangle(x1 + r.Width - lr.Right, y1, lr.Right, r.Height);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- }
- else
- if (r.Height <= img.Height && r.Width <= img.Width / Totalindex) { r1 = new Rectangle((index - ) * img.Width / Totalindex, , img.Width / Totalindex, img.Height); g.DrawImage(img, new Rectangle(x1, y1, r.Width, r.Height), r1, GraphicsUnit.Pixel); }
- else if (r.Height > img.Height && r.Width > img.Width / Totalindex)
- {
- //top-left
- r1 = new Rectangle(x, y, lr.Left, lr.Top);
- r2 = new Rectangle(x1, y1, lr.Left, lr.Top);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //top-bottom
- r1 = new Rectangle(x, y + img.Height - lr.Bottom, lr.Left, lr.Bottom);
- r2 = new Rectangle(x1, y1 + r.Height - lr.Bottom, lr.Left, lr.Bottom);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //left
- r1 = new Rectangle(x, y + lr.Top, lr.Left, img.Height - lr.Top - lr.Bottom);
- r2 = new Rectangle(x1, y1 + lr.Top, lr.Left, r.Height - lr.Top - lr.Bottom);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //top
- r1 = new Rectangle(x + lr.Left, y,
- img.Width / Totalindex - lr.Left - lr.Right, lr.Top);
- r2 = new Rectangle(x1 + lr.Left, y1,
- r.Width - lr.Left - lr.Right, lr.Top);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //right-top
- r1 = new Rectangle(x + img.Width / Totalindex - lr.Right, y, lr.Right, lr.Top);
- r2 = new Rectangle(x1 + r.Width - lr.Right, y1, lr.Right, lr.Top);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //Right
- r1 = new Rectangle(x + img.Width / Totalindex - lr.Right, y + lr.Top,
- lr.Right, img.Height - lr.Top - lr.Bottom);
- r2 = new Rectangle(x1 + r.Width - lr.Right, y1 + lr.Top,
- lr.Right, r.Height - lr.Top - lr.Bottom);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //right-bottom
- r1 = new Rectangle(x + img.Width / Totalindex - lr.Right, y + img.Height - lr.Bottom,
- lr.Right, lr.Bottom);
- r2 = new Rectangle(x1 + r.Width - lr.Right, y1 + r.Height - lr.Bottom,
- lr.Right, lr.Bottom);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //bottom
- r1 = new Rectangle(x + lr.Left, y + img.Height - lr.Bottom,
- img.Width / Totalindex - lr.Left - lr.Right, lr.Bottom);
- r2 = new Rectangle(x1 + lr.Left, y1 + r.Height - lr.Bottom,
- r.Width - lr.Left - lr.Right, lr.Bottom);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- //Center
- r1 = new Rectangle(x + lr.Left, y + lr.Top,
- img.Width / Totalindex - lr.Left - lr.Right, img.Height - lr.Top - lr.Bottom);
- r2 = new Rectangle(x1 + lr.Left, y1 + lr.Top,
- r.Width - lr.Left - lr.Right, r.Height - lr.Top - lr.Bottom);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- }
- }
- /// <summary>
- /// 绘图对像
- /// </summary>
- /// <param name="g"> 绘图对像</param>
- /// <param name="obj">图片对像</param>
- /// <param name="r">绘置的图片大小、坐标</param>
- /// <param name="index">当前状态</param>
- /// <param name="Totalindex">状态总数</param>
- public static void DrawRect(Graphics g, Bitmap img, Rectangle r, int index, int Totalindex)
- {
- if (img == null) return;
- int width = img.Width / Totalindex;
- int height = img.Height;
- Rectangle r1, r2;
- int x = (index - ) * width;
- int y = ;
- r1 = new Rectangle(x, y, width, height);
- r2 = new Rectangle(r.Left, r.Top, r.Width, r.Height);
- g.DrawImage(img, r2, r1, GraphicsUnit.Pixel);
- }
- /// <summary>
- /// 得到要绘置的图片对像
- /// </summary>
- /// <param name="str">图像在程序集中的地址</param>
- /// <returns></returns>
- public static Bitmap GetResBitmap(string str)
- {
- Stream sm;
- sm = FindStream(str);
- if (sm == null) return null;
- return new Bitmap(sm);
- }
- /// <summary>
- /// 得到图程序集中的图片对像
- /// </summary>
- /// <param name="str">图像在程序集中的地址</param>
- /// <returns></returns>
- private static Stream FindStream(string str)
- {
- Assembly assembly = Assembly.GetExecutingAssembly();
- string[] resNames = assembly.GetManifestResourceNames();
- foreach (string s in resNames)
- {
- if (s == str)
- {
- return assembly.GetManifestResourceStream(s);
- }
- }
- return null;
- }
- }
- public class Win32
- {
- #region Window Const
- public const int WM_KEYDOWN = 0x0100;
- public const int WM_KEYUP = 0x0101;
- public const int WM_CTLCOLOREDIT = 0x133;
- public const int WM_ERASEBKGND = 0x0014;
- public const int WM_LBUTTONDOWN = 0x0201;
- public const int WM_LBUTTONUP = 0x0202;
- public const int WM_LBUTTONDBLCLK = 0x0203;
- public const int WM_WINDOWPOSCHANGING = 0x46;
- public const int WM_PAINT = 0xF;
- public const int WM_CREATE = 0x0001;
- public const int WM_ACTIVATE = 0x0006;
- public const int WM_NCCREATE = 0x0081;
- public const int WM_NCCALCSIZE = 0x0083;
- public const int WM_NCPAINT = 0x0085;
- public const int WM_NCACTIVATE = 0x0086;
- public const int WM_NCLBUTTONDOWN = 0x00A1;
- public const int WM_NCLBUTTONUP = 0x00A2;
- public const int WM_NCLBUTTONDBLCLK = 0x00A3;
- public const int WM_NCMOUSEMOVE = 0x00A0;
- public const int WM_NCHITTEST = 0x0084;
- public const int HTLEFT = ;
- public const int HTRIGHT = ;
- public const int HTTOP = ;
- public const int HTTOPLEFT = ;
- public const int HTTOPRIGHT = ;
- public const int HTBOTTOM = ;
- public const int HTBOTTOMLEFT = 0x10;
- public const int HTBOTTOMRIGHT = ;
- public const int HTCAPTION = ;
- public const int HTCLIENT = ;
- public const int WM_FALSE = ;
- public const int WM_TRUE = ;
- #endregion
- #region Public extern methods
- [DllImport("gdi32.dll")]
- public static extern int CreateRoundRectRgn(int x1, int y1, int x2, int y2, int x3, int y3);
- [DllImport("user32.dll")]
- public static extern int SetWindowRgn(IntPtr hwnd, int hRgn, Boolean bRedraw);
- [DllImport("gdi32.dll", EntryPoint = "DeleteObject", CharSet = CharSet.Ansi)]
- public static extern int DeleteObject(int hObject);
- [DllImport("user32.dll")]
- public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
- [DllImport("user32.dll")]
- public static extern bool ReleaseCapture();
- #endregion
- }
C# 自定义重绘TextBox的更多相关文章
- C# 自定义重绘DataGridView
using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using Syste ...
- C# 自定义重绘TabControl
using System.Drawing; using System.Windows.Forms; using System.Drawing.Drawing2D; using System.Runti ...
- Windows开发进阶之VC++中如何实现对话框的界面重绘
技术:Windows 系统+Visual studio 2008 概述 应用程序界面是用户与应用程序之间的交互的桥梁和媒介,用户界面是应用程序中最重要的组成部分,也是最为直观的视觉体现.对用户而言 ...
- [DForm]我也来做自定义Winform之另类标题栏重绘
据说得有楔子 按照惯例,先来几张样例图(注:为了展示窗口阴影效果,截图范围向外扩展了些,各位凭想象吧). 还要来个序 其实,很多年没写过Winform了,前端时间在 ...
- c#winform自定义窗体,重绘标题栏,自定义控件学习
c#winform自定义窗体,重绘标题栏 虽然现在都在说winform窗体太丑了,但是我也能尽量让桌面应用程序漂亮那么一点点话不多说,先上图 重绘标题栏先将原生窗体设置成无边框,FormBoderSt ...
- iOS 视图:重绘与UIScrollView(内容根据iOS编程编写)
我们继续之前的 Hypnosister 应用,当用户开始触摸的时候,圆形的颜色会改变. 首先,在 JXHypnosisView 头文件中声明一个属性,用来表示圆形的颜色. #import " ...
- Android视图状态及重绘流程分析,带你一步步深入了解View(三)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17045157 在前面一篇文章中,我带着大家一起从源码的层面上分析了视图的绘制流程, ...
- (转)使用Custom Draw实现ListCtrl的重绘
使用Custom Draw实现ListCtrl的重绘 common control 4.7版本介绍了一个新的特性叫做Custom Draw,这个名字显得模糊不清,让人有点摸不着头脑,而且MSDN里 ...
- 【转】【C#】C#重绘windows窗体标题栏和边框
摘要 windows桌面应用程序都有标准的标题栏和边框,大部分程序也默认使用这些样式,一些对视觉效果要求较高的程序,如QQ, MSN,迅雷等聊天工具的样式则与传统的windows程序大不相同,其中迅雷 ...
随机推荐
- Python使用UUID库生成唯一ID(转)
原文:http://www.cnblogs.com/dkblog/archive/2011/10/10/2205200.html 资料: Python官方Doc:<20.15. uuid — U ...
- Clean Code第三章<函数>
1.方法不要写太长,如果太长,抽取其中的逻辑到新的方法中 bad good 2.函数只做一件事 如果做了多件事,要在方法名里体现出来 3.每个函数一个抽象层级 4.函数名可以长一些,比长注释好 5.方 ...
- Bash's ArithmeticExpression
[Bash's ArithmeticExpression] let command: let a=17+23 echo "a = $a" # Prints a = 40 let a ...
- 树上的DP
CF#196B http://codeforces.com/contest/338/problem/B 题意:在一颗树上,给m个点,求到所有m个点距离不超过d的点的个数,所有路径长度为1. 分析:问题 ...
- QTbaWidget控件几个例程 【worldsing笔记】
Qt Creator自带的 QTabWidget控件几个例程 在Qt Windos版本安装后,在Example目录可以找到与QTabWidget相关的工程Demo,如果按默认安装的话他们分别是: ...
- uestc oj 1217 The Battle of Chibi (dp + 离散化 + 树状数组)
题目链接:http://acm.uestc.edu.cn/#/problem/show/1217 给你一个长为n的数组,问你有多少个长度严格为m的上升子序列. dp[i][j]表示以a[i]结尾长为j ...
- POJ2299Ultra-QuickSort (线段树和归并排序的解法)
题目大意就是说帮你给一些(n个)乱序的数,让你求冒泡排序需要交换数的次数(n<=500000) 此题最初真不会做,我也只是在听了章爷的讲解后才慢慢明白过来的 首先介绍线段树的解法: 我们先将原数 ...
- Eclipse 安装对 Java 8 的支持
Java 8 正式版今天已经发布了(详情),但最常用的 Java 开发工具 Eclipse 还没有正式发布对 Java 8 的支持.不过目前可以通过更新 JDT 来支持 Java 8.步骤如下: 菜单 ...
- [MySQL] 字符集和排序方式
字符串类型 MySQL的字符串分为两大类: 1)二进制字符串:即一串字节序列,对字节的解释不涉及字符集,因此它没有字符集和排序方式的概念 2)非二进制字符串:由字符构成的序列,字符集用来解释字符串的内 ...
- 设置ul阴影效果和边框圆角
ul.box {position: relative;z-index: 1; /* prevent shadows falling behind containers with backgrounds ...