首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

为啥小弟我的桌面背景自动转换程序老是不成功

2012-01-05 
为啥我的桌面背景自动转换程序老是不成功?程序名称:ChangeDesktop设计代码:ChangeDesktop.Designer.cs:nam

为啥我的桌面背景自动转换程序老是不成功?
程序名称:ChangeDesktop

设计代码:
ChangeDesktop.Designer.cs:
namespace ChangeDesktop
{
partial class ChangeDesktop
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lblChImgDir = new System.Windows.Forms.Label();
this.txtChImgDir = new System.Windows.Forms.TextBox();
this.btnChImgDir = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnStart = new System.Windows.Forms.Button();
this.lblMsg = new System.Windows.Forms.Label();
this.timer = new System.Windows.Forms.Timer(this.components);
this.fldBrower = new System.Windows.Forms.FolderBrowserDialog();
this.SuspendLayout();
//
// lblChImgDir
//
this.lblChImgDir.AutoSize = true;
this.lblChImgDir.Location = new System.Drawing.Point(12, 20);
this.lblChImgDir.Name = "lblChImgDir";
this.lblChImgDir.Size = new System.Drawing.Size(107, 12);
this.lblChImgDir.TabIndex = 0;
this.lblChImgDir.Text = "请选择图片文件夹:";
//
// txtChImgDir
//
this.txtChImgDir.Location = new System.Drawing.Point(14, 46);
this.txtChImgDir.Name = "txtChImgDir";
this.txtChImgDir.Size = new System.Drawing.Size(287, 21);
this.txtChImgDir.TabIndex = 1;
//
// btnChImgDir
//
this.btnChImgDir.Location = new System.Drawing.Point(317, 44);
this.btnChImgDir.Name = "btnChImgDir";
this.btnChImgDir.Size = new System.Drawing.Size(83, 22);
this.btnChImgDir.TabIndex = 2;
this.btnChImgDir.Text = "选择文件夹";
this.btnChImgDir.UseVisualStyleBackColor = true;
this.btnChImgDir.Click += new System.EventHandler(this.btnChImgDir_Click);
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(339, 82);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(61, 22);
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "取消";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnStart
//
this.btnStart.Location = new System.Drawing.Point(263, 82);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(61, 22);
this.btnStart.TabIndex = 4;
this.btnStart.Text = "开始";
this.btnStart.UseVisualStyleBackColor = true;


this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// lblMsg
//
this.lblMsg.AutoSize = true;
this.lblMsg.Location = new System.Drawing.Point(12, 92);
this.lblMsg.Name = "lblMsg";
this.lblMsg.Size = new System.Drawing.Size(0, 12);
this.lblMsg.TabIndex = 5;
//
// timer
//
this.timer.Interval = 1000;
this.timer.Tick += new System.EventHandler(this.timer_Tick);
//
// fldBrower
//
this.fldBrower.Description = "请选择您要做为桌面背景的文件夹";
//
// ChangeDesktop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(412, 116);
this.Controls.Add(this.lblMsg);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnChImgDir);
this.Controls.Add(this.txtChImgDir);
this.Controls.Add(this.lblChImgDir);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Name = "ChangeDesktop";
this.Text = "桌面背景自动换";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label lblChImgDir;
private System.Windows.Forms.TextBox txtChImgDir;
private System.Windows.Forms.Button btnChImgDir;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.FolderBrowserDialog fldBrower;
private System.Windows.Forms.Label lblMsg;
private System.Windows.Forms.Timer timer;
}
}


[解决办法]
慢慢调试,小心查改
[解决办法]
把这一句
bmp.Save(imgPath); 
改成下面一行就可以了。

C# code
bmp.Save(imgPath, System.Drawing.Imaging.ImageFormat.Bmp); 

热点排行