奇怪现象: 程序最大化后,快速拖动分割条,图片有时候不能正常显示.... 简单程序,看原程序。

canoe_eyes 2004-11-24 06:30:24
//谢谢大家!

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
namespace testimage
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private string strPath;
private Image imx;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.TreeView treeView1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
strPath = Path.GetDirectoryName( Application.ExecutablePath );
imx = Image.FromFile( strPath + @"\a.bmp" );
//
// 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.panel1 = new System.Windows.Forms.Panel();
this.treeView1 = new System.Windows.Forms.TreeView();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ActiveBorder;
this.panel1.Controls.Add(this.treeView1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(144, 557);
this.panel1.TabIndex = 0;
this.panel1.SizeChanged += new System.EventHandler(this.panel1_SizeChanged);
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
//
// treeView1
//
this.treeView1.ImageIndex = -1;
this.treeView1.ItemHeight = 14;
this.treeView1.Location = new System.Drawing.Point(0, 25);
this.treeView1.Name = "treeView1";
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(144, 528);
this.treeView1.TabIndex = 2;
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(144, 0);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 557);
this.splitter1.TabIndex = 1;
this.splitter1.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Desktop;
this.ClientSize = new System.Drawing.Size(632, 557);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
this.Load += new System.EventHandler(this.Form1_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion

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

private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;

g.DrawImageUnscaled (this.imx, this.panel1.Size.Width -50, 2);

}

private void panel1_SizeChanged(object sender, System.EventArgs e)
{
this.treeView1.Size = new Size (this.panel1.Size.Width - 4, this.panel1.Size.Height -25);
this.panel1.Invalidate();
//this.Refresh();
}

private void menuItem2_Click(object sender, System.EventArgs e)
{

}

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{

}

private void Form1_SizeChanged(object sender, System.EventArgs e)
{
this.panel1.Invalidate();
}

private void Form1_Load(object sender, System.EventArgs e)
{
this.treeView1.Location = new System.Drawing.Point(0,25);
}
}
}
...全文
232 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
canoe_eyes 2004-11-26
  • 打赏
  • 举报
回复
问题解决,再次谢谢大家!
youwanna 2004-11-25
  • 打赏
  • 举报
回复
奇怪。。未出现,帮顶
canoe_eyes 2004-11-25
  • 打赏
  • 举报
回复
to 楼上 我的机器玩魔兽很流畅...
xinbin1122 2004-11-25
  • 打赏
  • 举报
回复
Because you computer is slow, maybe.
canoe_eyes 2004-11-25
  • 打赏
  • 举报
回复
我用 SnagIt 做了一个这个程序奇怪现象演示的 avi .大家有兴趣可以留下 email。 哦 我一直在线....
canoe_eyes 2004-11-25
  • 打赏
  • 举报
回复
在sizechanged中如果 不重新调整 treeview的size就不会有问题...大家有兴趣可以试试...很奇怪...
private void panel1_SizeChanged(object sender, System.EventArgs e)
{
this.treeView1.Size = new Size (this.panel1.Size.Width - 4, this.panel1.Size.Height -25);
this.panel1.Invalidate();
}
51106354 2004-11-25
  • 打赏
  • 举报
回复
我也试了一下,没有发现什么问题呀!!!
我的版本是2003
canoe_eyes 2004-11-25
  • 打赏
  • 举报
回复
to oriesMap 我这边很明显的,奇怪... 把你的程序发给我在这边试试 ,谢谢。ali@deemax.com.tw
OriesMap 2004-11-25
  • 打赏
  • 举报
回复
不好意思,还是没有见到有什么问题。
karykwan 2004-11-25
  • 打赏
  • 举报
回复
因为pictureBox好控制一点
canoe_eyes 2004-11-25
  • 打赏
  • 举报
回复
to oriesMap 我的也是2003,你来回快速拖放分割条,。。。
to karykwan(独行者) 我现在试试你的方法,不过为什么image 不可以呢?
karykwan 2004-11-25
  • 打赏
  • 举报
回复
private Image imx;
楼主为什么不把image换成pictureBox组件不是要好控制一些
OriesMap 2004-11-25
  • 打赏
  • 举报
回复
你是什么版本的.net呀?
我是2003版的,试了几次,感觉没有什么问题呀?
xiaoslong 2004-11-24
  • 打赏
  • 举报
回复
帮你顶

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧