社区
C#
帖子详情
winform 为何在运行时,用鼠标拖动窗体没反应???
erictang2003
2004-03-25 11:18:16
启动后,程序开始访问EXCEL 文件,但读取过程中,用鼠标拖动窗体没反应???
知道所有读取完成后,才能拖动.
怎样解决?
...全文
233
13
打赏
收藏
winform 为何在运行时,用鼠标拖动窗体没反应???
启动后,程序开始访问EXCEL 文件,但读取过程中,用鼠标拖动窗体没反应??? 知道所有读取完成后,才能拖动. 怎样解决?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
erictang2003
2004-03-27
打赏
举报
回复
up
HNU
2004-03-26
打赏
举报
回复
save & up
marvelstack
2004-03-26
打赏
举报
回复
要使用多线程就行了,
如下面是我写的代码,
楼主可以看看,对你会有帮助
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
namespace WindowsApplication1
{
//定义代理
public delegate void OccuredHandler(string msg);
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
//定义事件
public event OccuredHandler Occured;
//定义线程
Thread myThread;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
//注册事件
this.Occured +=new OccuredHandler(Form1_Occured);
myThread = new Thread(new ThreadStart(RunThread));
}
/// <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.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(184, 32);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "运行";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 112);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(192, 23);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(184, 72);
this.button2.Name = "button2";
this.button2.TabIndex = 2;
this.button2.Text = "退出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//线程方法
public void RunThread()
{
for(int i=0;i<1000000;i++)
{
this.label1.Text = i.ToString();
}
//激发事件
Occured("终于结束了,大哥快冒烟了!");
}
//线程结束通知函数
private void Form1_Occured(string msg)
{
MessageBox.Show(msg);
}
private void button1_Click(object sender, System.EventArgs e)
{
myThread.Start();
this.button1.Enabled = false;
}
private void button2_Click(object sender, System.EventArgs e)
{
//if(myThread.ThreadState!=ThreadState.Stopped||myThread.ThreadState!=ThreadState.Aborted)
myThread.Abort();
Application.Exit();
}
}
}
erictang2003
2004-03-26
打赏
举报
回复
up
yanransoft
2004-03-26
打赏
举报
回复
多线程操作
Napoleo
2004-03-26
打赏
举报
回复
用后台线程啦,比异步代理简单100倍
erictang2003
2004-03-26
打赏
举报
回复
up
HNU
2004-03-26
打赏
举报
回复
save
erictang2003
2004-03-26
打赏
举报
回复
有没有真正可用的代码?
wolftop
2004-03-25
打赏
举报
回复
开个线程处理打开和读取EXCEL~!
huangsuipeng
2004-03-25
打赏
举报
回复
用异步委托
delegate int Count(int a);
Count del =new Count(你的函数);
IAsyncReslut ar =del.BeginInvoke(10000,null,null);
.............
if(ar.IsCompleted)
{
int count=del.EndInvoke(ar);
}
else
{
以后再试
}
也可以使用CALLBACK方式
delegate int Count(int a);
Count del =new Count(你的函数);
AsyncCallback ab=new AsyncCallback(yourcallback)
IAsyncReslut ar =del.BeginInvoke(10000,ab,null);
.............
恶猫
2004-03-25
打赏
举报
回复
你读取是用的循环?还是...一次全部读取完??
如果是循环.
那么在循环内部加:
Application.DoEvents() (自己看大小写,我忘了)
如果是一次全部读完,
那你就要新建一个线程,另外读取那个文件了..
ipromise
2004-03-25
打赏
举报
回复
试着加一个读取线程,交给后台处理
【
Winform
进阶技巧】无边框
窗体
拖动
的四种实现方案对比
本文详细对比了
Winform
无边框
窗体
拖动
的四种实现方案,包括Panel控件、
窗体
事件、系统API和WndProc重写。针对不同开发需求和场景,提供了优化代码和实战技巧,帮助开发者选择最适合的方案实现高效、流畅的
窗体
拖动
功能。
C#禁止关闭和
拖动
窗体
【有漏洞】
*我也是抄别人的,禁止关闭
没
什么问题,当然只要别在进程管理器里关就行。呵呵
禁止
拖动
有问题,就是用标题栏左边的图标菜单,是可以
拖动
窗体
的。
【解决办法应该是,用this.position来解决吧】
private const int SC_CLOSE = 0xF060; private const int MF_ENABLED = 0x00000000; private const in
WinForm
特效:拦截
窗体
上各个部位的点击
windows
窗体
的标题栏无法直接通过一些默认的事件来控制,需要了解和WM_NCHITTEST相关的windows消息。 以下示例演示了最简单的效果片断: 他会把客户区和标题栏的效果互换,比如无法按住标题栏
拖动
窗体
而是改为了安抓客户区
拖动
,并禁用了关闭按钮。 其中m.Result从-2到21都有定义,分别度应了整个
窗体
的各个部位,比如1代表客户区,8代表最小化按钮等等。 us...
Winform
中panel的mousewheel
鼠标
滚轮事件触发
Winform
中panel的mousewheel
鼠标
滚轮事件触发
C#
窗体
美化实战:打造个性化最大化、最小化与关闭按钮
本文详细介绍了C#
窗体
美化的实战方案,重点讲解如何自定义最大化、最小化和关闭按钮。通过使用资源文件管理图片、利用WindowState属性控制
窗体
状态,并结合事件驱动实现动态交互效果,帮助开发者打造专业级个性化
窗体
界面,提升软件视觉体验与交互流畅度。
C#
111,129
社区成员
642,540
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章