不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
.NET在屏幕上输出文字
编辑:dnawo 日期:2008-12-02
方法一:调用API函数获取屏幕的设备驱动器句柄,然后用Graphics在屏幕上输出文字。
缺点:输出的文字不好用程序擦除,桌面刷新文字就会丢失!
方法二:使用透明的窗体
在Form1中输入如下代码:
相比方法一,这种方法修改文字非常容易,并且文字不会丢失!
复制内容到剪贴板
程序代码

using System.Runtime.InteropServices;
namespace Test
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
private static extern IntPtr ReleaseDC(IntPtr hwnd, IntPtr hdc);
private void button1_Click(object sender, EventArgs e)
{
IntPtr hwnd = IntPtr.Zero;
IntPtr hdc = GetDC(hwnd);
using (Graphics graphics = Graphics.FromHdc(hdc))
{
graphics.DrawString("木子屋:http://www.mzwu.com/", new Font("宋体", 15), new SolidBrush(Color.Red), 3, 3);
}
ReleaseDC(hwnd, hdc);//释放句柄
}
}
}
namespace Test
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
private static extern IntPtr ReleaseDC(IntPtr hwnd, IntPtr hdc);
private void button1_Click(object sender, EventArgs e)
{
IntPtr hwnd = IntPtr.Zero;
IntPtr hdc = GetDC(hwnd);
using (Graphics graphics = Graphics.FromHdc(hdc))
{
graphics.DrawString("木子屋:http://www.mzwu.com/", new Font("宋体", 15), new SolidBrush(Color.Red), 3, 3);
}
ReleaseDC(hwnd, hdc);//释放句柄
}
}
}
缺点:输出的文字不好用程序擦除,桌面刷新文字就会丢失!
方法二:使用透明的窗体
在Form1中输入如下代码:
复制内容到剪贴板
程序代码

Form curForm;
private void Form1_Load(object sender, EventArgs e)
{
//新建窗体并设置属性
curForm = new Form();
curForm.TopMost = true;//最顶层
curForm.FormBorderStyle = FormBorderStyle.None;//无标题栏,边框
curForm.TransparencyKey = this.BackColor;//底色透明
curForm.Width = 600;
curForm.Height = 30;
curForm.Left = (Screen.GetWorkingArea(curForm).Width - curForm.Width) / 2;
curForm.Top = (Screen.GetWorkingArea(curForm).Height - curForm.Height);
//添加Label
Label label1 = new Label();
label1.AutoSize = true;
label1.Text = "木子屋:http://www.mzwu.com/";
curForm.Controls.Add(label1);
//显示新窗体
curForm.Show();
}
private void Form1_Load(object sender, EventArgs e)
{
//新建窗体并设置属性
curForm = new Form();
curForm.TopMost = true;//最顶层
curForm.FormBorderStyle = FormBorderStyle.None;//无标题栏,边框
curForm.TransparencyKey = this.BackColor;//底色透明
curForm.Width = 600;
curForm.Height = 30;
curForm.Left = (Screen.GetWorkingArea(curForm).Width - curForm.Width) / 2;
curForm.Top = (Screen.GetWorkingArea(curForm).Height - curForm.Height);
//添加Label
Label label1 = new Label();
label1.AutoSize = true;
label1.Text = "木子屋:http://www.mzwu.com/";
curForm.Controls.Add(label1);
//显示新窗体
curForm.Show();
}
相比方法一,这种方法修改文字非常容易,并且文字不会丢失!
评论: 0 | 引用: 0 | 查看次数: 5617
发表评论
请登录后再发表评论!