| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1475 人关注过本帖
标题:进来随便看看(还是闪啊?)
只看楼主 加入收藏
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
结帖率:100%
收藏
 问题点数:0 回复次数:26 
进来随便看看(还是闪啊?)

各位大侠帮小弟看看这段程序,我画出了系统的时间,但是当它动态画的时候,一直是覆盖跳动的,我加了个Refresh,但是不怎么好,太闪了,要怎么才能实现刷新而不重叠呢?谢谢了!(将代码直接复制就可以运行)
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace waDrawingTime
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

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

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.btnStart = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 96);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(432, 88);
this.label1.TabIndex = 0;
//
// btnStart
//
this.btnStart.BackColor = System.Drawing.Color.LightSeaGreen;
this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnStart.ForeColor = System.Drawing.Color.Black;
this.btnStart.Location = new System.Drawing.Point(24, 32);
this.btnStart.Name = "btnStart";
this.btnStart.TabIndex = 3;
this.btnStart.Text = "Start";
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// timer1
//
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(400, 237);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void btnStart_Click(object sender, System.EventArgs e)
{
this.timer1.Start();
}

private void timer1_Tick(object sender, System.EventArgs e)
{
System.Drawing.Drawing2D.LinearGradientBrush myBrush2 = new System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle,Color.Red, Color.Red, System.Drawing.Drawing2D.LinearGradientMode.Vertical);

System.Drawing.Graphics labelGraphics = this.label1.CreateGraphics();
System.Drawing.Font DrawFont = new System.Drawing.Font("Arial", 30);
System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
System.Drawing.RectangleF rec = new System.Drawing.RectangleF();

labelGraphics.DrawString(System.DateTime.Now.ToString(("yyyy/MM/dd" + " " + "HH:mm:ss")),DrawFont,myBrush2,rec,drawFormat);
//this.label3.Refresh();
}
}
}


[此贴子已经被作者于2006-8-26 13:17:23编辑过]

搜索更多相关主题的帖子: public 动态 
2006-08-26 11:54
chenjin145
Rank: 1
等 级:禁止访问
帖 子:3922
专家分:0
注 册:2006-7-12
收藏
得分:0 
label1.Refresh();

加到time_tick開頭就可以了

[url=javascript:alert(1);] [div]fdgfdgfdg\" on\"[/div] [/url]
2006-08-26 12:09
xxxxx52
Rank: 4
等 级:贵宾
威 望:13
帖 子:689
专家分:0
注 册:2006-4-30
收藏
得分:0 
不错 有点意思

好的资料下载网站http:///in.asp?id=xuelion2006 嘿嘿帮点一下拉~
2006-08-26 12:44
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
收藏
得分:0 
OK,太感谢了,编程真的辛苦啊。。。
哎。。。
加油!!

汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2006-08-26 13:00
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
收藏
得分:0 

虽然可以画了,但是还是闪啊!


汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2006-08-26 13:16
xxxxx52
Rank: 4
等 级:贵宾
威 望:13
帖 子:689
专家分:0
注 册:2006-4-30
收藏
得分:0 
win2003  .net2003环境下不闪烁了

好的资料下载网站http:///in.asp?id=xuelion2006 嘿嘿帮点一下拉~
2006-08-26 13:36
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
收藏
得分:0 

晕,我是xp .net 2003环境,好郁闷,怎么办呢?


汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2006-08-26 13:52
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
你开始不是要做LED的吗?
2006-08-26 14:42
tanghuawei
Rank: 4
来 自:美丽的湖南
等 级:业余侠客
威 望:3
帖 子:531
专家分:220
注 册:2006-3-16
收藏
得分:0 
是啊,我是做LED的啊,但是那也不能总是闪动啊!

汽车尾气检测网络系统QQ:357766186__MSN:MSNTHW19850316@
2006-08-26 14:59
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
我运行了你的代码,没有闪动,但覆盖了,例如8覆盖了7,9再覆盖8,你怎么不清一下图?
2006-08-26 15:02
快速回复:进来随便看看(还是闪啊?)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017006 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved