|
-
Aug 12th, 2006, 08:24 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] vibrate an image
Hi
I have an alarm icon in my form.I want to vibrate it.How can I do i?
thanks
-
Aug 12th, 2006, 01:26 PM
#2
Hyperactive Member
Re: vibrate an image
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
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Aug 12th, 2006, 01:35 PM
#3
Re: vibrate an image
Or place a image control with the icon in it and just change the .Top and .Left coordinates in a nudge type of motions.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2006, 01:38 PM
#4
Hyperactive Member
Re: vibrate an image
true, but i expect he wants the image to vibrate like a alarm clock, which means rotation, different parts moving, etc.
KAZAR
The Law Of Programming:
As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
__________________________________
www.startingqbasic.co.uk
-
Aug 12th, 2006, 01:45 PM
#5
Re: vibrate an image
True, so just depends on the type of movement desired.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2006, 02:02 PM
#6
Thread Starter
Fanatic Member
Re: vibrate an image
Or place a image control with the icon in it and just change the .Top and .Left coordinates in a nudge type of motions.
What do you mean by nudge type of motions?
thanks
-
Aug 12th, 2006, 02:08 PM
#7
Re: vibrate an image
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2006, 02:16 PM
#8
Thread Starter
Fanatic Member
Re: vibrate an image
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
-
Aug 12th, 2006, 02:19 PM
#9
Re: vibrate an image
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2006, 02:25 PM
#10
Thread Starter
Fanatic Member
Re: vibrate an image
OK I'm waiting for ur example
thanks
-
Aug 12th, 2006, 02:26 PM
#11
Re: vibrate an image
Here is a small example of shaking a form.
Click the form to start/stop
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
The effect came out quite well
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2006, 02:30 PM
#12
Thread Starter
Fanatic Member
Re: vibrate an image
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
-
Aug 12th, 2006, 02:35 PM
#13
Re: vibrate an image
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2006, 02:40 PM
#14
Thread Starter
Fanatic Member
Re: vibrate an image
RobDog888 u're great
Thanks a lot
-
Aug 12th, 2006, 02:47 PM
#15
Thread Starter
Fanatic Member
Re: [RESOLVED] vibrate an image
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
-
Aug 12th, 2006, 02:59 PM
#16
Re: [RESOLVED] vibrate an image
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
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 12th, 2006, 03:08 PM
#17
Thread Starter
Fanatic Member
Re: [RESOLVED] vibrate an image
Many thanks to you RobDog888
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|