Hi
I have an alarm icon in my form.I want to vibrate it.How can I do i?
thanks
Printable View
Hi
I have an alarm icon in my form.I want to vibrate it.How can I do i?
thanks
you need to create multiple versions of your image, and then loop through them on a timer. to do it to the image itself would require direct x, which is complicated
Or place a image control with the icon in it and just change the .Top and .Left coordinates in a nudge type of motions.
true, but i expect he wants the image to vibrate like a alarm clock, which means rotation, different parts moving, etc.
True, so just depends on the type of movement desired. ;)
What do you mean by nudge type of motions?Quote:
Or place a image control with the icon in it and just change the .Top and .Left coordinates in a nudge type of motions.
thanks
Like on MSN IM you can send a nudge which looks like the form is experiencing an earthquake.
Just perform a few variations of the positioning of top/left in a loop for a few iterations.
How many iterations?
I tried this loop
VB Code:
For i=0 to 1000 Image1.left=Image1.left+50 Image1.left=Image1.left-50 Image1.Top=Image1.Top+50 Image1.Top=Image1.Top-50 Next i
is there a better way?
thanks
Probably would be best in a Timer event. Set a timer with a short interval of 250 or 500. Then in the Timer procedure change the top/left to one position and toggle it to a different position on the next event. I'll write a short example. 1 sec.
OK I'm waiting for ur example
thanks
Here is a small example of shaking a form.
Click the form to start/stop
:D The effect came out quite well :lol:VB Code:
Option Explicit Private miTogglePos As Integer Private Sub Form_Click() Timer1.Enabled = Not Timer1.Enabled End Sub Private Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 25 miTogglePos = 1 End Sub Private Sub Timer1_Timer() Select Case miTogglePos Case 1 Me.Move 100, 100 miTogglePos = 2 Case 2 Me.Move 200, 100 miTogglePos = 3 Case 3 Me.Move 200, 200 miTogglePos = 4 Case 4 Me.Move 100, 200 miTogglePos = 1 End Select End Sub
Thanks RobDog888 that's what i want,
can i nudge only the image control(containing the alarm icon) and I want to nudge it for only 5 seconds
Updated code to move a image control for 5 seconds.
VB Code:
Option Explicit Private miTogglePos As Integer Private mlElapsedTime As Long Private Sub Form_Click() Timer1.Enabled = Not Timer1.Enabled mlElapsedTime = 0 End Sub Private Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 25 miTogglePos = 1 Image1.Picture = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Misc\FACE03.ICO") End Sub Private Sub Timer1_Timer() If mlElapsedTime = 5000 Then Timer1.Enabled = False mlElapsedTime = mlElapsedTime + Timer1.Interval Select Case miTogglePos Case 1 Image1.Move 1000, 1000 miTogglePos = 2 Case 2 Image1.Move 1100, 1000 miTogglePos = 3 Case 3 Image1.Move 1100, 1100 miTogglePos = 4 Case 4 Image1.Move 1000, 1100 miTogglePos = 1 End Select End Sub
RobDog888 u're great
Thanks a lot
By the way RobDog888 I forgot to ask you.
Is it possible to play a sound while the picture nudges for 5 seconds?
Many thanks
Sure. There is a PlaySound API but I think its synchronous so you will have to pass the asynchronous flag with it so it can play at the same time as the timer processing.
More info - http://www.allapi.net/apilist/PlaySound.shtml
VB Code:
Private Const SND_ASYNC As Long = &H1 Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Many thanks to you RobDog888