How to Flash a form..

R_K_T_ASHOKA

Active member
Joined
Apr 6, 2006
Messages
33
Programming Experience
3-5
Hi all

Can any one tell me how we can flash a form using FlashWindow or FlashWindowEx API functions.. i tried the same code i used in vb6, but its not working in VB.Net..

Thanks
 
Last edited:
If you're using FlashWindow in VB.NET then you need to declare the arguments as Integer instead of Long. A VB6 Long is 32 bits, while the VB.NET Long is 64 bits and the VB.NET Integer is 32 bits.
 
Thanks !!!

:) Thanks jmcilhinney its working.. great

i am putting the code here so it might be useful for others...

PrivateDeclareFunction FlashWindow Lib "user32" (ByVal hwnd As Int32, ByVal bInvert As Int32) As Int32
'in above code Int32 can be Integer also

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call FlashWindow(Me.Handle.ToInt32, -1)
EndSub

just paste in a empty form and keep a button in the form..

Thanks

 
PrivateDeclareFunction FlashWindow Lib "user32" (ByVal hwnd As Int32, ByVal bInvert As Int32) As Int32
'in above code Int32 can be Integer also

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call FlashWindow(Me.Handle.ToInt32, -1)
EndSub


i am a new member of this . Amit

this is not working in my vb.net 2002
 
Problem with FlashWindowEx

The following code is not working... please help..


'declaration..
Private Structure FLASHWINFO
Dim cbSize As Int32
Dim Hwnd As IntPtr
Dim dwFlags As Int32
Dim uCount As Int32
Dim dwTimeout As Int32
End Structure

Private Const FLASHW_TRAY = 2

Private Declare Function FlashWindowEx Lib "user32" _
(ByVal FWInfo As FLASHWINFO) As Boolean


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bRet As Boolean
Dim udtFWInfo As FLASHWINFO
With udtFWInfo
.cbSize = 20
.Hwnd = Hwnd
.dwFlags = FLASHW_TRAY
.uCount = 5 'NumberOfFlashes

.dwTimeout = 0
End With
bRet = FlashWindowEx(udtFWInfo)
End Sub


Thanks
 
I'm not much of an API guru, but this line...

VB.NET:
.Hwnd = Hwnd

shouldn't .hwnd be pointing to the handle of the window you want to flash?
 
Sorry..

I missed the following, my carelessness..:D

VB.NET:
.Hwnd = Hwnd



But i tried bef looking the post of vis781 by starting a new project and the below code worked, i was wondering how the below code worked but code in prev post didnt work, which u clarified..that i have missed the Hwnd thanks..

I am puting the code that workes for reference by other members..
PrivateStructure FLASHWINFO
Dim cbSize AsInteger
Dim Hwnd As IntPtr
Dim dwFlags AsInteger
Dim uCount AsInteger
Dim dwTimeout AsInteger
EndStructure

PrivateConst FLASHW_TRAY AsShort = 2
PrivateDeclareFunction FlashWindowEx Lib "user32" (ByRef FWInfo As FLASHWINFO) AsBoolean

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bRet AsBoolean
Dim udtFWInfo As FLASHWINFO
With udtFWInfo
.cbSize = 20
.Hwnd =
Me.Handle
.dwFlags = FLASHW_TRAY
.uCount = 5
'flash window 5 times
.dwTimeout = 0
EndWith
bRet = FlashWindowEx(udtFWInfo)
EndSub


Thanks vis781 again

 
Back
Top