C#
Control内
public delegate void SetExRichReciveHandel(string str);
public void SetExRichRecive(string str)
{
if (this.exRichRecive.InvokeRequired)
{
SetExRichReciveHandel SPBH = new SetExRichReciveHandel(SetExRichRecive);
this.exRichRecive.Invoke(SPBH, new object[] { str });
}
else
{
this.exRichRecive.AppendText(str + "\r\n");
}
}
{
if (this.exRichRecive.InvokeRequired)
{
SetExRichReciveHandel SPBH = new SetExRichReciveHandel(SetExRichRecive);
this.exRichRecive.Invoke(SPBH, new object[] { str });
}
else
{
this.exRichRecive.AppendText(str + "\r\n");
}
}
WinForm 内
private void MessageText(string str, string qicquid)
{
foreach (System.Windows.Forms.Control ctrl in chatPanle1.Controls)
{
string C = ctrl.Parent.ToString();//控件类型
if (C.ToUpper().Trim() == "SSTOICQ.Control.ChatPanle".ToUpper().Trim())
{
if (((ChatPanle)ctrl.Parent).Oicq.ToLower().Trim().Equals(qicquid.Trim().ToLower()))
{
//发送消息
((ChatPanle)ctrl.Parent).SetExRichRecive(str);
break;
}
}
}
}
{
foreach (System.Windows.Forms.Control ctrl in chatPanle1.Controls)
{
string C = ctrl.Parent.ToString();//控件类型
if (C.ToUpper().Trim() == "SSTOICQ.Control.ChatPanle".ToUpper().Trim())
{
if (((ChatPanle)ctrl.Parent).Oicq.ToLower().Trim().Equals(qicquid.Trim().ToLower()))
{
//发送消息
((ChatPanle)ctrl.Parent).SetExRichRecive(str);
break;
}
}
}
}