Results 1 to 8 of 8

Thread: Flashing A Window

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308

    Flashing A Window

    Is there a way, without useing a Timer control (which I'm not the least familiar with) to continously flash a form's title?

  2. #2
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    VB Code:
    1. Option Explicit
    2. Private Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long
    3.  
    4. Private Sub Form_Load()
    5.     Me.Timer1.Interval = 200 'Change this value according to requirements
    6.     Me.Timer1.Enabled = True
    7. End Sub
    8.  
    9. Private Sub timer1_timer()
    10.     Dim nReturnValue As Long
    11.     nReturnValue = FlashWindow(hWnd, True)
    12. End Sub
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308
    I would actually perfer not to use a Timer, but thank you very much.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    If you don't want to use a Timer, then use FlashWindowEx
    VB Code:
    1. Private Const FLASHW_STOP = 0 'Stop flashing. The system restores the window to its original state.
    2. Private Const FLASHW_CAPTION = &H1 'Flash the window caption.
    3. Private Const FLASHW_TRAY = &H2 'Flash the taskbar button.
    4. Private Const FLASHW_ALL = (FLASHW_CAPTION Or FLASHW_TRAY) 'Flash both the window caption and taskbar button. This is equivalent to setting the FLASHW_CAPTION Or FLASHW_TRAY flags.
    5. Private Const FLASHW_TIMER = &H4 'Flash continuously, until the FLASHW_STOP flag is set.
    6. Private Const FLASHW_TIMERNOFG = &HC 'Flash continuously until the window comes to the foreground.
    7. Private Type FLASHWINFO
    8.     cbSize As Long
    9.     hwnd As Long
    10.     dwFlags As Long
    11.     uCount As Long
    12.     dwTimeout As Long
    13. End Type
    14. Private Declare Function FlashWindowEx Lib "user32" (pfwi As FLASHWINFO) As Boolean
    15.  
    16. Private Sub Form_Load()
    17.     'KPD-Team 1999
    18.     'URL: [url]http://www.allapi.net/[/url]
    19.     'E-Mail: [email][email protected][/email]
    20.     Dim FlashInfo As FLASHWINFO
    21.     'Specifies the size of the structure.
    22.     FlashInfo.cbSize = Len(FlashInfo)
    23.     'Specifies the flash status
    24.     FlashInfo.dwFlags = FLASHW_ALL Or FLASHW_TIMER
    25.     'Specifies the rate, in milliseconds, at which the window will be flashed. If dwTimeout is zero, the function uses the default cursor blink rate.
    26.     FlashInfo.dwTimeout = 0
    27.     'Handle to the window to be flashed. The window can be either opened or minimized.
    28.     FlashInfo.hwnd = Me.hwnd
    29.     'Specifies the number of times to flash the window.
    30.     FlashInfo.uCount = 0
    31.     FlashWindowEx FlashInfo
    32. End Sub
    33.  
    34. Private Sub Form_Paint()
    35.     Me.CurrentX = 0
    36.     Me.CurrentY = 0
    37. End Sub

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Connecticut, USA
    Posts
    308

    Thumbs up

    Thank you.

    I like it.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    It might get to be annoying, so at some point, you probably want to turn it off.

  7. #7
    Lively Member jamieoboth's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    116
    OK, slightly harder problem (well I say SLIGHTLY):

    How would you get just teh TEXT of the title bar to flash, say from blue to white?

    Thanks for your help,
    James Booth
    Ich widerstehe allem - nur nicht der Versuchung

    (I can resist anything but temptation)

  8. #8
    Megatron
    Guest
    Here's a shorter version of the code
    VB Code:
    1. Private Type FLASHWINFO
    2.     cbSize As Long
    3.     hwnd As Long
    4.     dwFlags As Long
    5.     uCount As Long
    6.     dwTimeout As Long
    7. End Type
    8. Private Declare Function FlashWindowEx Lib "user32" (pfwi As FLASHWINFO) As Boolean
    9. Private Const FLASHW_ALL = &H3 'Flash both the window caption and taskbar button. This is equivalent to setting the FLASHW_CAPTION Or FLASHW_TRAY flags.
    10. Private Const FLASHW_TIMER = &H4 'Flash continuously, until the FLASHW_STOP flag is set.
    11.  
    12. Private Sub Form_Load()
    13.     Dim FlashInfo As FLASHWINFO
    14.     FlashInfo.cbSize = Len(FlashInfo)
    15.     FlashInfo.dwFlags = FLASHW_ALL Or FLASHW_TIMER
    16.     FlashInfo.hwnd = Me.hwnd
    17.     FlashWindowEx FlashInfo
    18. End Sub
    And no, FlashWindow doesn't have the capability to flash different colors of the title text.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width