如何实现buzz功能 [英] how to implement buzz feature

查看:142
本文介绍了如何实现buzz功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在聊天信使中实现动态更新功能。我创建了气球工具提示和闪光灯,以便在聊天窗口处于最小化状态时突出显示新消息的存在。代码如下所示。但现在我希望在鼠标点击或按键时实现蜂鸣功能,以最大化状态恢复聊天窗口。



  .nfiBroadcast.Icon = Resource1.chat; 
nfiBroadcast.ShowBalloonTip( 2000 新广播消息收到..!
+ msg.senderDisplayName
+ 向您发送消息。,ToolTipIcon.Info);

if this .WindowState == FormWindowState.Minimized)
{
this .WindowState = FormWindowState.Minimized;
FlashWindow.Flash( this 3 );
}





我该如何实现呢?

解决方案



第一:在你的代码中

 如果 this  .WindowState == FormWindowState.Minimized)
{
this .WindowState = FormWindowState。最小化;
FlashWindow.Flash( this 3 );
}





您正在检查窗口状态是否已最小化,然后您将其指定为最小化,当它已经是在最小化状态下,有什么意义?



第二:

是的,你可以通过将WindowState设置为FormWindowState来最大化窗口.Maximize,虽然我宁愿把它设置为FormWindowState.Restore。



你可能需要在设置WindowState后调用Refresh()方法。



希望这会有所帮助。



问候

Jegan


< blockquote>摇动窗口的代码,



  int  a = < span class =code-digit> 1 ; 
while (a < 10
{

this .Location = new Point ( this .Location.X + 20 this .Location.Y + 20 );
System.Threading.Thread.Sleep( 15 );
.Location = new Point( this .Location.X - 20 this .Location.Y - 20 );
System.Threading.Thread.Sleep( 15 );
a + = 1 ;

}
.Activate();
.TopMost = true ; // 重要
.TopMost = false ; // 重要





代码用于设置消息的消息,此处Messagerecieved是.wav文件



 使用(SoundPlayer sndplayr =  new  SoundPlayer(Resource1.MessageReceived))
{
sndplayr.Play();
}


I would like to implement the buzz feature in our chat messenger. I created the balloon tool tip and flash for highlighting the presence of new message while the chat window is in minimized state. The code is given below.but now i wished to implement the buzz feature on mouse click or key press to restore the chat window in maximized state.

this.nfiBroadcast.Icon = Resource1.chat;
nfiBroadcast.ShowBalloonTip(2000, "New broadcast message received..!", ""
     + msg.senderDisplayName
     + " messaged you.", ToolTipIcon.Info);

if (this.WindowState == FormWindowState.Minimized)
{
    this.WindowState = FormWindowState.Minimized;
    FlashWindow.Flash(this, 3);
}



how can i implement it ?

解决方案

Hi,
First : In your code

if (this.WindowState == FormWindowState.Minimized)
{
    this.WindowState = FormWindowState.Minimized;
    FlashWindow.Flash(this, 3);
}



you are checking the window state is it minimized, then you are assigning it to minimized, when it is already in minimized state, what is the point of that?

Second:
Yes, you can maximize the window by setting the WindowState to FormWindowState.Maximize, although I would rather set it to FormWindowState.Restore.

you may have to call the Refresh() method after setting the WindowState.

Hope this helps.

Regards
Jegan


Code for shaking the window,

int a=1;
           while (a < 10)
           {

               this.Location = new Point(this.Location.X + 20, this.Location.Y + 20);
               System.Threading.Thread.Sleep(15);
               this.Location = new Point(this.Location.X - 20, this.Location.Y - 20);
               System.Threading.Thread.Sleep(15);
               a += 1;

           }
         this.Activate();
           this.TopMost = true;  //important
           this.TopMost = false; //important



code for set sound for message,here Messagerecieved is the .wav file

using (SoundPlayer sndplayr = new SoundPlayer(Resource1.MessageReceived))
           {
               sndplayr.Play();
           }


这篇关于如何实现buzz功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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