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.Reflection;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace TextboxsStyleLineControlLibrary
{
/// <summary>
///csharp winform 划横线输入框
/// 塗聚文 2012-03-27
/// 締友計算機信息技術有限公司
/// 捷為工作室
/// </summary>
[ToolboxItem(true)]
public class GeovinDuTextBoxLine:TextBox
{
private bool m_DrawLine = false;
private const int WM_NCPAINT = 0x0085;
private const int WM_CHAR = 0x0102;
[System.Runtime.InteropServices.DllImport("user32.dll ")]
static extern IntPtr GetWindowDC(IntPtr hWnd);
[System.Runtime.InteropServices.DllImport("user32.dll ")]
static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
/// <summary>
///
/// </summary>
public GeovinDuTextBoxLine()
{
//
// TODO: 在此处添加构造函数逻辑
//
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.BorderStyle = BorderStyle.None;
}
private Color _linecolor = Color.Black;
/// <summary>
/// 线条颜色
/// </summary>
public Color LineColor
{
get
{
return this._linecolor;
}
set
{
this._linecolor = value;
this.Invalidate();
}
}
private const int WM_PAINT = 0xF;
/// <summary>
///
/// </summary>
public bool DrawLine
{
get
{
return this.m_DrawLine;
}
set
{
this.m_DrawLine = value;
this.Invalidate();
}
}
/// <summary>
///
/// </summary>
/// <param name="m"></param>
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0xf || m.Msg == 0x133)
{
if (this.DrawLine)
{
IntPtr hDC = GetWindowDC(m.HWnd);
if (hDC.ToInt32() == 0)
{
return;
}
Graphics g = Graphics.FromHdc(hDC);
//Brush b = Brushes.Black;
Pen p = new Pen(this._linecolor, 1);//b
Point p1 = new Point(0, this.Height - 2);
Point p2 = new Point(this.Width, Height - 2);
g.DrawLine(p, p1, p2);
m.Result = IntPtr.Zero;
ReleaseDC(m.HWnd, hDC);
}
}
}
}
}
分享到:
相关推荐
c# winform实例大全(198个经典Csharp WinForm实例源码),学习c#的朋友可以参考下。
c# winform实例大全(198个Csharp WinForm实例源码)
Csharp winform下ftp的基本功能.zip
如题. 程序启动后自动隐藏窗体,只在任务栏显示个图标。点击图标后,窗体自动显示,并在5秒后自动关闭窗体,退出。 通过设置NotifyIcon可以完全实现隐藏窗体。
CSharpWinForm实践开发教程课件全.ppt
ConverterApp-CSharpWinForm ##简单转换器桌面应用-Windows ####技术:C#Windows表单 #####下载: #/ #####转换器应用 #####例子 #####帮助
自定义Csharp WinForm ToolTip, Form.
C#,Csharp,winform QQ,IM即时会议聊天
csharp 的winform 打印程序完整案例 1,无需安装任何其他插件 2,可以打印条形码(一维,二维多种主流格式) 3,支持分页打印
Csharp-WinForm实践开发教程,详细的入门教程与开发资料;
基于winform 的权限管理管理框架。 功能模块: 版本管理 功能管理 角色管理 用户管理 版本管理 1.创建版本,创建本版本下的角色,用户 2.修改版本,如果是加入权限,只加默认角色,如果删除,则删除所有本版本下的...
实现DataWarehouse数据调用,增删改查
WPF制作的15个效果的demo,没有广告的。之前有个里面全是广告链接。。。。
CSharp WinForm
Csharp显示实时曲线并保存截图winform通过Chart类实现c#
C#实现显示实时数据,并形成曲线,保存数据,完整的项目代码
CSharp winform 模仿QQ聊天窗口皮肤控件
波形显示控件,实现了同时显示多条数据曲线、局部放大查看、波形显示自动调整最佳坐标范围、动态显示波形等功能
CSHARP调用google搜索服务的源码示例(winform)源码
198个经典的c#源代码,新手比较适合看看,可以仿照其中的自己设计