試試調(diào)整之前
創(chuàng)新互聯(lián)是一家以網(wǎng)絡(luò)技術(shù)公司,為中小企業(yè)提供網(wǎng)站維護、成都網(wǎng)站制作、網(wǎng)站建設(shè)、網(wǎng)站備案、服務(wù)器租用、域名注冊、軟件開發(fā)、小程序定制開發(fā)等企業(yè)互聯(lián)網(wǎng)相關(guān)業(yè)務(wù),是一家有著豐富的互聯(lián)網(wǎng)運營推廣經(jīng)驗的科技公司,有著多年的網(wǎng)站建站經(jīng)驗,致力于幫助中小企業(yè)在互聯(lián)網(wǎng)讓打出自已的品牌和口碑,讓企業(yè)在互聯(lián)網(wǎng)上打開一個面向全國乃至全球的業(yè)務(wù)窗口:建站電話聯(lián)系:18980820575
Me.SuspendLayout()
調(diào)整完之后再
Me.ResumeLayout()
用Visual C#編寫屏幕保護程序
Visual C#是微軟公司推出的新一代程序開發(fā)語言,是微軟.Net框架中的一個重要組成部分。屏幕保護程序是以scr為擴展名的標(biāo)準(zhǔn)Windows可執(zhí)行程序。屏幕保護程序不僅可以延長顯示器的使用壽命,還可以保護私人信息。本文向大家介紹一個.Net平臺上用C#編寫的一個動態(tài)文本及圖形的屏幕保護程序。
一、具體實現(xiàn)步驟:
(1)在Visual Studio.Net下新建一個C#的Windows應(yīng)用程序工程,不妨命名為screen_saver。
(2)現(xiàn)在我們來設(shè)計程序的主界面:
先將窗體的Name屬性設(shè)置為screen、Text屬性設(shè)置為空,BackColor屬性設(shè)置為Black、Size屬性設(shè)置為(800, 600)、 ControlBox、MaximizeBox、MinimizeBox、ShowInTaskbar屬性設(shè)置均為false、FormBorderStyle屬性設(shè)置為None。再往窗體上添加Label控件、PictureBox控件、Timer控件各一個。將Label控件的Name設(shè)置為word、Text屬性設(shè)置為空;將PictureBox控件的Name設(shè)置為picture1、Image設(shè)置為一個預(yù)知圖片;將Timer控件的Name設(shè)置為timerSaver、Enabled 屬性設(shè)為true、Interval屬性設(shè)為5。
(3)現(xiàn)在我們開始編寫完整程序代碼部分:
//導(dǎo)入使用到的名稱空間
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://文本顯示控件
///
/// 必需的設(shè)計器變量。
///
public screen()
{
file://
// Windows 窗體設(shè)計器支持所必需的
file://
InitializeComponent();
word.Font=TextStringFont;
word.ForeColor=TextStringcolor;
System.Windows.Forms.Cursor.Hide(); file://隱藏光標(biāo)
file://
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
file://
}
///
/// 清理所有正在使用的資源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
///
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();
//
// 設(shè)置文本顯示控件(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;
//
// 設(shè)置計時器控件(timerSaver)屬性
this.timerSaver.Enabled = true;
this.timerSaver.Interval = 5;
this.timerSaver.Tick += new System.EventHandler(this.timerSaver_Tick);
//
// 設(shè)置圖片控件(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;
//
// 設(shè)置窗體(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://鍵盤按下響應(yīng)事件
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.screen_KeyDown);
file://鼠標(biāo)按下響應(yīng)事件
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.screen_MouseDown);
file://窗體啟動調(diào)用事件
this.Load += new System.EventHandler(this.Form1_Load);
file://鼠標(biāo)移動響應(yīng)事件
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.screen_MouseMove);
this.ResumeLayout(false);
}
#endregion
///
/// 應(yīng)用程序的主入口點。
///
[STAThread]
static void Main(string[] args)
{
if(args.Length==1)
if(args[0].Substring(0,2).Equals("/c"))
{
MessageBox.Show("沒有設(shè)置項功能","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://屏幕顯示區(qū)域
width1=ssWorkArea.Width; file://屏幕寬度
height1=ssWorkArea.Height; file://屏幕高度
}
private void timerSaver_Tick(object sender, System.EventArgs e) file://計時器響應(yīng)事件
{
word.Visible=true;
word.Text=str;
word.Height=word.Font.Height; file://設(shè)置文本的高度
word.Width=word.Text.Length*(int)word.Font.Size*2; file://設(shè)置文本的寬度
PlayScreenSaver();
}
private void PlayScreenSaver() file://自定義函數(shù)
{
file://下面設(shè)置文本顯示框的位置坐標(biāo)
word.Location =new System.Drawing.Point(width1-iDistance,word.Location.Y);
word.Visible=true; file://設(shè)置為可見
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://下面是計算圖片框移動坐標(biāo)
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://鼠標(biāo)移動事件
{
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://鼠標(biāo)按下事件
{
StopScreenSaver(); file://停止運行屏幕保護程序
}
private void screen_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
file://鍵盤按下事件
{
StopScreenSaver(); file://停止運行屏幕保護程序
}
}
}
最后運行該程序,把screen_saver.exe改為screen_saver.scr,拷入Windows系統(tǒng)目錄中,這樣就可以運行該屏幕
呵呵,如果不需要太復(fù)雜,那么前提下你必須是懂得如何連接SQL數(shù)據(jù)庫的方法,假如你明白了,那么只要在連接的字符串中修改下“服務(wù)器”項就可以了:
connstr="Driver={sql server};uid=用戶名;pwd=密碼;database=數(shù)據(jù)庫名;server=網(wǎng)站的SQL服務(wù)器IP或域名"
......
就這么簡單!
我的一個遠(yuǎn)程數(shù)據(jù)庫維護工具就是這樣連接的網(wǎng)站的SQL2000數(shù)據(jù)庫的。
把啟動窗體先顯示出來,然后,過一段時間再把這個窗體隱藏起來就行了。在其他窗體中加一句form1.visible=false
然后啟動窗體把標(biāo)題欄什么的設(shè)置一下,做個圖片背景什么的,就行了。
分類: 電腦/網(wǎng)絡(luò) 程序設(shè)計 其他編程語言
問題描述:
VB6中的form1.circle (100,200),rgb(0,255,0)的語句如何在VB中使用啊?
急用啊?。。。。。。?!
解析:
VB與VB不同。
VB已經(jīng)有專門繪圖的類。
可以定義筆刷然后用Drawing類中的方法繪制。
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub