资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

关于vb.net拷屏的信息

用vb,net怎么做屏幕保护程序啊

用Visual C#编写屏幕保护程序

成都创新互联公司服务项目包括章丘网站建设、章丘网站制作、章丘网页制作以及章丘网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,章丘网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到章丘省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

Visual C#是微软公司推出的新一代程序开发语言,是微软.Net框架中的一个重要组成部分。屏幕保护程序是以scr为扩展名的标准Windows可执行程序。屏幕保护程序不仅可以延长显示器的使用寿命,还可以保护私人信息。本文向大家介绍一个.Net平台上用C#编写的一个动态文本及图形的屏幕保护程序。

一、具体实现步骤:

(1)在Visual Studio.Net下新建一个C#的Windows应用程序工程,不妨命名为screen_saver。

(2)现在我们来设计程序的主界面:

先将窗体的Name属性设置为screen、Text属性设置为空,BackColor属性设置为Black、Size属性设置为(800, 600)、 ControlBox、MaximizeBox、MinimizeBox、ShowInTaskbar属性设置均为false、FormBorderStyle属性设置为None。再往窗体上添加Label控件、PictureBox控件、Timer控件各一个。将Label控件的Name设置为word、Text属性设置为空;将PictureBox控件的Name设置为picture1、Image设置为一个预知图片;将Timer控件的Name设置为timerSaver、Enabled 属性设为true、Interval属性设为5。

(3)现在我们开始编写完整程序代码部分:

//导入使用到的名称空间

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

file://

namespace screen_saver

{

///

/// Form1 的摘要说明。

///

public class screen : System.Windows.Forms.Form

{

file://加入私有成员变量

private System.ComponentModel.IContainer components;

private int iSpeed = 2;

private string str="福建南纺股份公司计算机中心";

file://定义文本字体及大小

private System.Drawing.Font TextStringFont = new System.Drawing.Font ("宋体”, 10,System.Drawing.FontStyle.Bold);

private Color TextStringcolor =System.Drawing.Color.Yellow; file://文本字体颜色

private int iDistance;

private int ixStart= 0;

private int iyStart= 0;

private int speed;

private int x1,y1;

int width1,height1;

private System.Windows.Forms.Timer timerSaver; file://计时器控件

private System.Windows.Forms.PictureBox picture1; file://图形控件

private System.Windows.Forms.Label word; file://文本显示控件

///

/// 必需的设计器变量。

///

public screen()

{

file://

// Windows 窗体设计器支持所必需的

file://

InitializeComponent();

word.Font=TextStringFont;

word.ForeColor=TextStringcolor;

System.Windows.Forms.Cursor.Hide(); file://隐藏光标

file://

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

file://

}

///

/// 清理所有正在使用的资源。

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

///

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

///

private void InitializeComponent() file://初始化程序中使用到的组件

{

this.components = new System.ComponentModel.Container();

System.Resources.ResourceManager resources = new system.Resources.ResourceManger(typeof(screen));

this.word = new System.Windows.Forms.Label();

this.timerSaver = new System.Windows.Forms.Timer(this.components);

this.picture1 = new System.Windows.Forms.PictureBox();

this.SuspendLayout();

//

// 设置文本显示控件(word)属性

this.word.ForeColor = System.Drawing.Color.Yellow;

this.word.Location = new System.Drawing.Point(624, 8);

this.word.Name = "word";

this.word.Size = new System.Drawing.Size(168, 16);

this.word.TabIndex = 0;

this.word.Visible = false;

//

// 设置计时器控件(timerSaver)属性

this.timerSaver.Enabled = true;

this.timerSaver.Interval = 5;

this.timerSaver.Tick += new System.EventHandler(this.timerSaver_Tick);

//

// 设置图片控件(picture1)属性

this.picture1.Image = ((System.Drawing.Bitmap)(resources.GetObject("picture1.Image")));

this.picture1.Location = new System.Drawing.Point(800, 600);

this.picture1.Name = "picture1";

this.picture1.Size = new System.Drawing.Size(304, 224);

this.picture1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;

this.picture1.TabIndex = 1;

this.picture1.TabStop = false;

//

// 设置窗体(screen)属性

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.BackColor = System.Drawing.Color.Black;

this.ClientSize = new System.Drawing.Size(800, 600);

this.ControlBox = false;

this.Controls.AddRange(new System.Windows.Forms.Control[] {this.picture1,this.word});

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

this.KeyPreview = true;

this.MaximizeBox = false;

this.MinimizeBox = false;

this.Name = "screen";

this.ShowInTaskbar = false;

this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

file://键盘按下响应事件

this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.screen_KeyDown);

file://鼠标按下响应事件

this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.screen_MouseDown);

file://窗体启动调用事件

this.Load += new System.EventHandler(this.Form1_Load);

file://鼠标移动响应事件

this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.screen_MouseMove);

this.ResumeLayout(false);

}

#endregion

///

/// 应用程序的主入口点。

///

[STAThread]

static void Main(string[] args)

{

if(args.Length==1)

if(args[0].Substring(0,2).Equals("/c"))

{

MessageBox.Show("没有设置项功能","C# Screen Saver");

Application.Exit();

}

else if(args[0]=="/s")

Application.Run(new screen());

else if(args[0]=="/a")

{

MessageBox.Show("没有口令功能","C# Screen saver");

Application.Exit();

}

else

Application.Run(new screen());

}

private void Form1_Load(object sender, System.EventArgs e)

{

speed=0;

System.Drawing.Rectangle ssWorkArea=System.Windows.Forms.Screen.GetWorkingArea(this);

file://屏幕显示区域

width1=ssWorkArea.Width; file://屏幕宽度

height1=ssWorkArea.Height; file://屏幕高度

}

private void timerSaver_Tick(object sender, System.EventArgs e) file://计时器响应事件

{

word.Visible=true;

word.Text=str;

word.Height=word.Font.Height; file://设置文本的高度

word.Width=word.Text.Length*(int)word.Font.Size*2; file://设置文本的宽度

PlayScreenSaver();

}

private void PlayScreenSaver() file://自定义函数

{

file://下面设置文本显示框的位置坐标

word.Location =new System.Drawing.Point(width1-iDistance,word.Location.Y);

word.Visible=true; file://设置为可见

iDistance+=iSpeed;

if(word.Location.X=-(word.Width))

{

iDistance=0;

if(word.Location.Y==0)

word.Location=new System.Drawing.Point(word.Location.X,height1/2);

else if(word.Location.Y==height1/2)

word.Location=new System.Drawing.Point(word.Location.X,height1-word.Height);

else

word.Location=new System.Drawing.Point(word.Location.X,0);

}

file://下面是计算图片框移动坐标

speed++;

if(speed=2*height1)

{

x1=System.Math.Abs(width1-speed);

y1=System.Math.Abs(height1-speed);

}

else if(speed2*height1 speed=2*width1)

{

x1=System.Math.Abs(width1-speed);

y1=System.Math.Abs(height1-(speed-speed/height1*height1));

}

else if(speed2*width1 speed=3*height1)

{

x1=System.Math.Abs(width1-(speed-speed/width1*width1));

y1=System.Math.Abs(height1-(speed-speed/height1*height1));

}

else if(speed3*height1 speed4*height1)

{

x1=System.Math.Abs(width1-(speed-speed/width1*width1));

y1=System.Math.Abs(speed-speed/height1*height1);

}

else if(speed=4*height1 speed5*height1)

{

x1=System.Math.Abs(speed-speed/width1*width1);

y1=System.Math.Abs(height1-(speed-speed/height1*height1));

}

else if(speed=5*height1 speed4*width1)

{

x1=System.Math.Abs(speed-speed/width1*width1);

y1=System.Math.Abs(speed-speed/height1*height1);

}

else if(speed=4*width1 speed6*height1)

{

x1=System.Math.Abs(width1-(speed-speed/width1*width1));

y1=System.Math.Abs(speed-speed/height1*height1);

}

else if(speed=6*height1 speed5*width1)

{

x1=System.Math.Abs(width1-(speed-speed/width1*width1));

y1=System.Math.Abs(height1-(speed-speed/height1*height1));

}

else if(speed=5*width1 speed7*height1)

{

x1=System.Math.Abs(speed-speed/width1*width1);

y1=System.Math.Abs(height1-(speed-speed/height1*height1));

}

else if(speed=7*height1 speed6*width1)

{

x1=System.Math.Abs(speed-speed/width1*width1);

y1=System.Math.Abs(speed-speed/height1*height1);

}

if(speed==6*width1)

speed=0;

picture1.Location=new System.Drawing.Point(x1,y1);

}

private void StopScreenSaver() file://停止屏幕保护程序运行

{

System.Windows.Forms.Cursor.Show();

timerSaver.Enabled=false;

Application.Exit();

}

private void screen_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)

file://鼠标移动事件

{

if(ixStart==0 iyStart==0)

{

ixStart=e.X;

iyStart=e.Y;

return;

}

else if(e.X!=ixStart||e.Y!=iyStart)

StopScreenSaver();

}

private void screen_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)

file://鼠标按下事件

{

StopScreenSaver(); file://停止运行屏幕保护程序

}

private void screen_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)

file://键盘按下事件

{

StopScreenSaver(); file://停止运行屏幕保护程序

}

}

}

最后运行该程序,把screen_saver.exe改为screen_saver.scr,拷入Windows系统目录中,这样就可以运行该屏幕

请问如何用vb.net编写程序控制led电子屏显示文字?

主要是对SerialPort控件的编程和数据库的读取,

在数据库读取方面可以用 DataSet ,BindingSource , TableAdapter 等数据绑定控件,

SerialPort控件的具体读写方法建议你看MSDN,大概是:

Private Sub 关闭和启动串口()

Try

If 串口.IsOpen Then

串口.Close()

End If

串口.Open()

Catch ex As Exception

''''

End Try

End Sub

Private Sub 串口的读与写()

......

Dim 发送字节() As Byte, 返回字节 As Byte

Try

'例如要发送字节: 6D

发送字节 = BitConverter.GetBytes(CByte("H6D"))

串口.Write(发送字节, 0, 1)

......

'例如读串口返回的字节

返回字节 = 串口.ReadByte

Catch ex As Exception

''''

End Try

......

End Sub

'等等

VB.NET如何实现撷取区域屏幕

既然能够取得整个屏幕,可以取到整个屏幕以后创建一个全屏窗体显示静态的屏幕图像,然后在窗体上实现部分截取。

估计别的截图也是这个原理,因为一点开始截图屏幕就变为静态不动了,肯定是在截图初期复制了当时的屏幕场景

网上下的VB.NET截屏程序,试过好用,哪位大侠给详细解释一下!另外,怎么把截图加载到Picturebox里?

VB.NT用的是触发事件,一按就会触发,要不你加个timer控件,延迟一秒

标题的问题:你先把图片保存,再加载

vb.net的窗体Copy问题

先把"Form1.vb 的副本"改成"Form2",然后右击“Form2”---查看代码---把类名改成“Form2”就可以了

vb.net 截屏 ,获取活动窗口

'模块中

Declare Function GetDC Lib "user32" (ByVal hwnd As Long) _

As Long

Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

Declare Function BitBlt Lib "gdi32" _

(ByVal hDestDC As Long, ByVal x As Long, _

ByVal y As Long, ByVal nWidth As Long, _

ByVal nHeight As Long, ByVal hSrcDC As Long, _

ByVal xSrc As Long, ByVal ySrc As Long, _

ByVal dwRop As Long) As Long

'form1中

Private Sub Command1_Click()

Dim hDCtmp As Long, picWidth As Double, picHeight As Double

Dim x As Double

Dim y As Double

x = Val(Text2.Text)

y = Val(Text3.Text)

picWidth = Val(Text3.Text)

picHeight = Val(Text4.Text)

hDCtmp = GetDC(0)

BitBlt Picture1.hdc, 0, 0, picWidth, picHeight, hDCtmp, x, y, vbSrcCopy

ReleaseDC 0, hDCtmp

End Sub

目的: 将屏幕按照指定坐标和大小进行截取成图,在picture1显示

问题: 大小是相同了,为什么截取的坐标不对,只是屏幕上的左上

相信大家都用过QQ截图功能。不过很多人并没有真正掌握好它的用法。将QQ截图与其它截屏和制图软件配合使用,会有意想不到的效果。

获取颜色的RGB值

我们在编辑图片或网页的时候,经常需要获取某种颜色的“RGB值”,所以很多人都安装了第三方的颜色吸取工具。其时用QQ截图键即可获取屏幕上任意颜色的RGB值。

当按下“Ctrl+Shift+A”弹出“截图”提示框时,提示框中的“当前像素RGB”即为当前鼠标屏幕位置的颜色RGB值,将鼠标移动到你想查看的屏幕颜色上即可获得相应的RGB值(如图1)。

图1精确截取图片大小

有时我们对要使用的截图尺寸有严格要求,比如论坛签名或QQ头像等。用QQ截图键可以按尺寸精确截取,一步到位无需再进行后期裁剪了。

按下QQ截图键,按住鼠标不放选取截取范围时,在鼠标上方会有一个信息框显示当前范围的详细信息,其中“矩形大小”就是以像素来表示的图片的尺寸大小,括号内的数字分别表示的是长和高(如图2)。松开鼠标调整截图框时,对照“矩形大小”就可以按需要的尺寸来精确截图范围,然后用鼠标点住截图框将截图框拖到要截取的图片上,双击即可获得所需尺寸的图片了。

图2图片拼贴好帮手

大部分的截图软件一次只能截取一张图片,当要截取多张图片并进行拼贴组合时,就需要一张一张截取全部保存后再进行拼贴操作,非常麻烦。

我们知道用QQ截图键截取的图片可以在任一个可以粘贴图片的程序中使用,这样只需用截图软件进行一次截图操作,剩下的图片用QQ截图键来截取,然后依次粘贴到截图软件的窗口中即可快速进行拼贴操作了,是不是很方便啊。

小提示:QQ截图键无需打开聊天窗口即可使用,截取的图片在任一可粘贴图片的程序窗口中如画图、Word等,使用“粘贴”命令即可使用


标题名称:关于vb.net拷屏的信息
链接分享:http://cdkjz.cn/article/hdpgcp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220