从线程显示表单不起作用... [英] Showing Form from a thread doesnt work...

查看:119
本文介绍了从线程显示表单不起作用...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用jabber-net开源库开发聊天应用程序..

我的目的是在消息显示时显示表单(聊天窗口)来了。

但是当我使用这个代码时,Form出现在任务栏中,,,没有完美呈现......

看起来像这样...更多我可以只有当我将鼠标悬停在任务栏上的图标上时才能看到表格(Hail Windows 7)......任何形式都是这样......



点击此处查看图片 [ ^ ]



我的代码就是这个...



Hi,
I am developing a chat application using jabber-net opensource library..
my aim is to display a form (chat window ) when a message is coming.
But when I use this code, Form appears in the task bar,,, not perfectly rendered...
seems like this... More over I can see the form only when I mousehover the Icon on taskbar (Hail Windows 7)... Any form are like this...

Click here for Picture[^]

my code is this...

public jabber.client.JabberClient jabberClient1;
jabberClient1.User = UserName;
jabberClient1.Password = Password;
jabberClient1.Resource = resource;
jabberClient1.AutoRoster = true;
jabberClient1.OnMessage += new MessageHandler(jabberClient1_OnMessage);

private void jabberClient1_OnMessage(object sender, jabber.protocol.client.Message msg)
{
	try
	{
		chatWindow chw = new chatWindow();
		chw.Left = 0;
		chw.Top = 0;
		chw.TopMost = true;
		//chw.LoadChat(msg.From.User, msg.From.Bare, "0");
		//chw.SetMessage(msg);
		chw.Show();
	}
}

推荐答案

试试

try
chk.BringToFront();


谢谢所有回答我的人,,,我自己解决了....

问题我必须将jabberclient中的InvokeCOntrol属性设置为应用程序中加载的第一个表单...如果未加载Invoked COntrol表单,它将显示从其事件中显示的所有表单,如下所示...这是代码.. 。



JabberClient1.InvokeControl = FirstShownFormInstance;
Thanks all who answered me,,, I have solved it myself....
The Problem was I had to set the InvokeCOntrol property in jabberclient to the very first form loaded in the application... If Invoked COntrol form is not loaded, It will show all forms shown from its events like this... Here is the code...

JabberClient1.InvokeControl = FirstShownFormInstance;


这篇关于从线程显示表单不起作用...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆