• Welcome to Valhalla Legends Archive.
 

Flashing Form.

Started by GoSu_KaOs, January 20, 2005, 11:24 PM

Previous topic - Next topic

GoSu_KaOs

I need the form to flash only when it losses focus. When the form gets focus, I need the flashing to stop. I cant get this to work.

Private Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long

Private Sub Form_GotFocus()
timer1.enabled = false
End Sub

Private Sub Form_LostFocus()
Timer1.Enabled = True
End Sub

Private Sub Command1_Click()
timer1.enabled = true
End If

Private Sub timer1_timer()
FlashWindow hWnd, 1
End Sub


Help?

UserLoser.


Private Sub Form_Resize()
    If (WindowState <> vbMinimized) Then
        Timer1.Enabled = False
    End If
End Sub

GoSu_KaOs

Did you even test this? dont work..

CrAz3D

UserLoser's suggestion would work if the bot is minimize & you change the Timer1.Enabled = False to = True instead, wouldn't it?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

GoSu_KaOs

eh..

Quote
I need the form to flash only when it losses focus. When the form gets focus, I need the flashing to stop.

CrAz3D

Check to see if the form has focus or not before flashing it?
rebundance - having or being in excess of sheer stupidity
(ré-bun-dance)
Quote from: Spht on June 22, 2004, 07:32 PMSlap.
Quote from: Adron on January 28, 2005, 09:17 AMIn a way, I believe that religion is inherently evil, which includes Christianity. I'd also say Christianity is eviller than Buddhism (has more potential for evil).
Quote from: iago on April 19, 2005, 01:06 PM
CrAz3D's ... is too big vertically, at least, too big with ... iago ...

MyndFyre

Quote from: GoSu_KaOs on January 23, 2005, 10:35 AM
eh..

Quote
I need the form to flash only when it losses focus. When the form gets focus, I need the flashing to stop.

When the form gains focus stop flashing it?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

warz

Quote from: UserLoser on January 21, 2005, 12:25 AM

Private Sub Form_Resize()
    If (WindowState <> vbMinimized) Then
        Timer1.Enabled = False
    End If
End Sub


This should work.  Remember to begin the flashing though when you minimize it. All this code does is check to see if the window is not minimized, and if it isn't, it disabled the flash timer.

Dyndrilliac

This should've been answered long ago.

Public HasFocus as Boolean
Public Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long

Private Sub Form_GotFocus()
    HasFocus = True
End Sub

Private Sub Form_LostFocus()
    HasFocus = False
End Sub

Private Sub tmrIdle_Timer()
    If HasFocus = False Then
        FlashWindow Me.hWnd, 1
    End If
End Sub
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Grok

#9

Public Const FLASHW_STOP = 0
Public Const FLASHW_CAPTION = &H1
Public Const FLASHW_TRAY = &H2
Public Const FLASHW_ALL = (FLASHW_CAPTION + FLASHW_TRAY)
Public Const FLASHW_TIMER = &H4
Public Const FLASHW_TIMERNOFG = &HC

Public Type FLASHWINFO
    cbSize As Long
    hWnd As Long
    dwFlags As Long
    uCount As Long
    dwTimeout As Long
End Type
Public Declare Function FlashWindowEx Lib "user32" (lpFWI As FLASHWINFO) As Long

'-------------------------------------------------------------------
'FlashWin procedure flashes the given window a number of times at some rate.
'-------------------------------------------------------------------
Private Function FlashWin(ByVal pWnd As Long, ByVal pCount As Long, ByVal pTimeout As Long) As Long
   
    Dim pFW As FLASHWINFO
   
    pFW.cbSize = Len(pFW)
    pFW.dwFlags = FLASHW_ALL
    pFW.dwTimeout = pTimeout
    pFW.hWnd = pWnd
    pFW.uCount = pCount
    FlashWin = FlashWindowEx(pFW)
   
End Function


EXAMPLE USAGE -- flash current window 10 times at 150ms interval:

    FlashWin Me.hWnd, 10, 150

iNsaNe

Hmm... I had the code for this... except I forgot it.

Your code is wrong with the GetFocus and LostFocus

The code I had flashed the form when it had focus. It has nothing to do with getfocus or lostfocus.