[VB.Net 2008] FlashWindow e Focus...

lunedì 02 agosto 2010 - 20.41

Frayx Profilo | Newbie

Devo creare una funzione tipo quella di Messenger per far lampeggiare l'icona e la finestra quando mi arriva un nuovo messaggio... Riesco in tutto tranne a far smettere di lampeggiare.
Ora come ora uso questo metodo: all'arrivo di un nuovo messaggio faccio partire un timer che esegue FlashWindow ogni 500 millisecondi, poi ho messo in GotFocus Timer1.Stop solo che non succede nulla e l'icona continua a lampeggiare! Mi potete dire come risolvere? Grazie in anticipo :)

Fako Profilo | Newbie

ciao,
se ho ben capito non serve utilizzare un Timer, ti scrivo il codice:
[DllImport("user32")]
public static extern int FlashWindowEx(ref FLASHWINFO pwfi);
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public UInt32 cbSize;
public IntPtr hwnd;
public Int32 dwFlags;
public UInt32 uCount;
public Int32 dwTimeout;
}
public enum flstatus{
// stop flashing
FLASHW_STOP = 0,

// flash the window title
FLASHW_CAPTION = 1,

// flash the taskbar button
FLASHW_TRAY = 2,

// 1 | 2
FLASHW_ALL = 3,

// flash continuously
FLASHW_TIMER = 4,

// flash until the window comes to the foreground
FLASHW_TIMERNOFG = 12
}
public FLASHWINFO fw = new FLASHWINFO();

private void button1_Click(object sender, EventArgs e)
{

fw.cbSize = Convert.ToUInt32(Marshal.SizeOf(typeof(FLASHWINFO)));
fw.hwnd = this.Handle;
fw.dwFlags = (int)flstatus.FLASHW_TRAY;
fw.uCount = UInt32.MaxValue;

FlashWindowEx(ref fw);

}

private void button2_Click(object sender, EventArgs e)
{
fw.dwFlags = (int)flstatus.FLASHW_STOP;
FlashWindowEx(ref fw);
}

col button1 scateni il flash nel taskbar col button2 arresti il flash.

Il riferimento è questo:
http://msdn.microsoft.com/en-us/library/ms679347(VS.85).aspx

Ciao,
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5