using System.Runtime.InteropServices;
[DllImport("user32.dll")]
static extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("user32.dll")]
static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
public class SubWindow : NativeWindow
{
private Control control;
private string text = "null";
private Color foreColor = SystemColors.ControlText;
private Font font = SystemFonts.MenuFont;
public Font Font
{
set
{
font = value;
if (control != null)
control.Invalidate();
}
}
public Color ForeColor
{
set
{
foreColor = value;
if (control != null)
control.Invalidate();
}
}
public string Text
{
set
{
text = value;
if (control != null)
control.Invalidate();
}
}
public Control Control {
set
{
control = value;
if (control != null)
{
AssignHandle(control.Handle);
control.Invalidate();
}
}
}
protected override void WndProc(ref Message m)
{
const int WM_PAINT = 0x000F;
base.WndProc(ref m);
if (control == null) return;
switch (m.Msg)
{
case WM_PAINT:
IntPtr vDC = GetWindowDC(m.HWnd);
Graphics vGraphics = Graphics.FromHdc(vDC);
StringFormat vStringFormat = new StringFormat();
vStringFormat.Alignment = StringAlignment.Center;
vStringFormat.LineAlignment = StringAlignment.Center;
vGraphics.DrawString(text, font, new SolidBrush(foreColor),
new Rectangle(0, 0, control.Width, control.Height), vStringFormat);
ReleaseDC(m.HWnd, vDC);
break;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
SubWindow vSubWindow = new SubWindow();
vSubWindow.Font = Font;
vSubWindow.Text = "Zswang 路过";
vSubWindow.ForeColor = Color.Blue;
vSubWindow.Control = progressBar1;
}
分享到:
相关推荐
c#中使用进度条 c#中使用进度条 c#中使用进度条
C# progressBar进度条绘制文字显示百分比
C#中实现进度条的效果源码
C# Winform圆形进度条(改良版)从csdn下载,增加了圆形进度值文字显示。GDI+绘制,效率高。
C# Winform垂直进度条控件实例,含控件源码VerticalProgressBar
C#带文字进度条 C#文字进度条 C#带字进度条 C#自定义进度条 C#带文字进度条 C#文字进度条 C#带字进度条 C#自定义进度条
利用多线程创建的经典的好用的精度条,供大家参考使用
进度条 C#进度条 C#Winform进度条 C#开发的进度条 用C#开发的进度条
网上好多负责文件夹的进度条写的都有问题,在此基础上,自己修改了一下,进度条可以完美显示出来,另外还加了一个label动态显示拷贝的文件名,用的多线程,里面一些细节大家还是要注意一下的。另外拷贝文件夹是是...
c#中如何控制模态子窗体中的进度条 这个问题会让一些初学者感到困惑,一方面模态窗体在打开之后(Form.ShowDialog).主线程无法继续执行下面的事务;另一方面,又要在处理事务的时候来同步这个窗体里面的进度条。这...
文件下载进度条,自己记得在nuget中下载Jquery和Jquery UI ,文件上传进度条.net c#版本demo
c# Web网页实现进度条,把需要的代码填充即可
C#如何使用进度条控件 C#如何使用进度条控件
大量C#的自定义进度条,圆滑的,多边形的。有控件,有实例。
C#winfrom自定义进度条控件,可横着显示,可竖着显示,底色,进度颜色,都可修改,进度值可以选择是否显示,也可设置字体大小,里面有控件源码,可按照自己需求修改,主要是用GDI绘图画的
用C#开发的自定义进度条,可显示数字(百分值)。进度条色彩可自定义。并且有实例
包含9个不同的进度条源码,C#多线程、进度条、C#多线程进度条、progressBar、实例源码、C#.NET winform 利用多线程技术,值得参考和学习!
DataGridView添加进度条,DataGridView添加进度条
C# winform,重写ListView控件,让它实现每一行都带百分比的进度条,在实际项目中经常用到,所以留在这里与各位分享,如果有疑问,欢迎VX:VPAmway,共同交流学习编程知识
C# WinForm中进度条的实现方法,有需要的赶快来下啊,希望对你有帮助哦,相互学习哈