Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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 ?
Posted

Hi,
First : In your code
C#
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
 
Share this answer
 
Comments
Nayana Rajan 26-Feb-13 22:28pm    
I mean, assume if A and B are two persons.they chat with each other through the messenger.A minimized his chat window.Then B send a message to A.But A cannot identify it.So to get the attention of A, B Press 'ctrl+g'(like yahoo messenger).At that time,A's minimized window need to come in the normal state and shake to get the attention of A..
Jegan Thiyagesan 27-Feb-13 4:58am    
Yes I understand that.
When the A gets a "buzz" you would do this on the A's chat program wouldn't you?

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

Regadrs
Jegan
Code for shaking the window,

C#
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

C#
using (SoundPlayer sndplayr = new SoundPlayer(Resource1.MessageReceived))
           {
               sndplayr.Play();
           }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900