elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Aviso estilo Messenger
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Aviso estilo Messenger  (Leído 2,055 veces)
.:Weeds:.

Desconectado Desconectado

Mensajes: 122



Ver Perfil
Aviso estilo Messenger
« en: 1 Junio 2014, 18:02 pm »

Bueno, el caso es que estoy creando un chat en vb.net y al recibir un nuevo mensaje he pensado de que el aviso se de como en el messenger, es decir, que se habra la ventana minimizada y parpadeando en la barra de tareas. Alguna información al respecto?

Saludos y gracias.


En línea


.:Weeds:.

Desconectado Desconectado

Mensajes: 122



Ver Perfil
Re: Aviso estilo Messenger
« Respuesta #1 en: 2 Junio 2014, 01:36 am »

Ya encontré la respuesta.

Código
  1.   <DllImport("user32.dll", EntryPoint:="FlashWindow")> _
  2.    Public Shared Function FlashWindow(ByVal hwnd As Integer, ByVal bInvert As Integer) As Integer
  3.    End Function

Saludos.


En línea


Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.817



Ver Perfil
Re: Aviso estilo Messenger
« Respuesta #2 en: 30 Junio 2014, 17:04 pm »

En mi opinión, lo suyo sería usar la alternativa FlashWindowEx(tended) para tener un mayor control sobre como actua el flash y su personalización xD.

Ejemplo de uso, para flashear el icono de la barra de tareas hasta que la ventana se vuelva activa:
Código
  1. Me.FlashWindow(Me.Handle, FlashFlags.TaskBar Or FlashFlags.Until_Foreground)

Te dejo el código completo que escribí, por si te sirve:

Código
  1.    ''' <summary>
  2.    ''' Flashes the specified window.
  3.    ''' It does not change the active state of the window.
  4.    ''' For more info see here:
  5.    ''' http://msdn.microsoft.com/en-us/library/windows/desktop/ms679347%28v=vs.85%29.aspx
  6.    ''' </summary>
  7.    ''' <param name="pwfi">A pointer to a FLASHWINFO structure.</param>
  8.    ''' <returns>
  9.    ''' The return value specifies the window's state before the call to the FlashWindowEx function.
  10.    ''' If the window caption was drawn as active before the call, the return value is nonzero.
  11.    ''' Otherwise, the return value is zero.
  12.    ''' </returns>
  13.    <System.Runtime.InteropServices.DllImport("user32.dll")>
  14.    Private Shared Function FlashWindowEx(
  15.            ByRef pwfi As FLASHWINFO
  16.    ) As <System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean
  17.    End Function
  18.  
  19.    ''' <summary>
  20.    ''' Contains the flash status for a window and the number of times the system should flash the window.
  21.    ''' For more info see here:
  22.    ''' http://msdn.microsoft.com/en-us/library/windows/desktop/ms679348%28v=vs.85%29.aspx
  23.    ''' </summary>
  24.    <System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)>
  25.    Public Structure FLASHWINFO
  26.  
  27.        ''' <summary>
  28.        ''' The size of the structure, in bytes.
  29.        ''' </summary>
  30.        Public cbSize As UInteger
  31.  
  32.        ''' <summary>
  33.        ''' A handle to the window to be flashed.
  34.        ''' The window can be either opened or minimized.
  35.        ''' </summary>
  36.        Public hwnd As IntPtr
  37.  
  38.        ''' <summary>
  39.        ''' The flash status.
  40.        ''' </summary>
  41.        Public dwFlags As FlashFlags
  42.  
  43.        ''' <summary>
  44.        ''' The number of times to flash the window.
  45.        ''' </summary>
  46.        Public uCount As UInteger
  47.  
  48.        ''' <summary>
  49.        ''' The rate at which the window is to be flashed, in milliseconds.
  50.        ''' If dwTimeout is zero, the function uses the default cursor blink rate.
  51.        ''' </summary>
  52.        Public dwTimeout As UInteger
  53.  
  54.    End Structure
  55.  
  56.    ''' <summary>
  57.    ''' Contains the flash status for a window.
  58.    ''' </summary>
  59.    <System.ComponentModel.Description("Enum used as 'FlashFlags' parameter in 'FlashWindow' function.")>
  60.    <Flags>
  61.    Public Enum FlashFlags As Integer
  62.  
  63.        ''' <summary>
  64.        ''' Stop flashing.
  65.        ''' The system restores the window to its original state.
  66.        ''' </summary>    
  67.        [Stop] = 0I
  68.  
  69.        ''' <summary>
  70.        ''' Flash the window caption.
  71.        ''' </summary>
  72.        Caption = 1I
  73.  
  74.        ''' <summary>
  75.        ''' Flash the taskbar button.
  76.        ''' </summary>
  77.        TaskBar = 2I
  78.  
  79.        ''' <summary>
  80.        ''' Flash both the window caption and taskbar button.
  81.        ''' This is equivalent to setting the 'Caption Or TaskBar' flags.
  82.        ''' </summary>
  83.        All = 3I
  84.  
  85.        ''' <summary>
  86.        ''' Flash continuously, until the 'Stop' flag is set.
  87.        ''' </summary>
  88.        Until_Stop = 4I
  89.  
  90.        ''' <summary>
  91.        ''' Flash continuously until the window comes to the foreground.
  92.        ''' </summary>
  93.        Until_Foreground = 12I
  94.  
  95.    End Enum
  96.  
  97.    ''' <summary>
  98.    ''' Flashes the specified window.
  99.    ''' It does not change the active state of the window.
  100.    ''' </summary>
  101.    ''' <param name="Handle">
  102.    ''' Indicates the handle to the window to flash.
  103.    ''' </param>
  104.    ''' <param name="FlashFlags">
  105.    ''' Indicates the flash flags.
  106.    ''' </param>
  107.    ''' <param name="FlashCount">
  108.    ''' Indicates the number of times to flash the window.
  109.    ''' </param>
  110.    ''' <param name="FlashDelay">
  111.    ''' Indicates the rate at which the window is to be flashed, in milliseconds.
  112.    ''' If dwTimeout is zero, the function uses the default cursor blink rate.
  113.    ''' </param>
  114.    ''' <returns>
  115.    ''' The return value specifies the window's state before the call to the FlashWindowEx function.
  116.    ''' If the window caption was drawn as active before the call, the return value is nonzero.
  117.    ''' Otherwise, the return value is zero.
  118.    ''' </returns>
  119.    Public Function FlashWindow(ByVal [Handle] As IntPtr,
  120.                                ByVal FlashFlags As FlashFlags,
  121.                                Optional ByVal FlashCount As UInteger = UInteger.MaxValue,
  122.                                Optional ByVal FlashDelay As UInteger = 0UI) As Boolean
  123.  
  124.        Dim fInfo As New FLASHWINFO()
  125.  
  126.        With fInfo
  127.  
  128.            .cbSize = Convert.ToUInt32(System.Runtime.InteropServices.Marshal.SizeOf(fInfo))
  129.            .hwnd = [Handle]
  130.            .dwFlags = FlashFlags
  131.            .uCount = FlashCount
  132.            .dwTimeout = FlashDelay
  133.  
  134.        End With
  135.  
  136.        Return FlashWindowEx(fInfo)
  137.  
  138.    End Function
  139.  

Saludos
« Última modificación: 30 Junio 2014, 17:12 pm por Eleкtro » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines