Results 1 to 17 of 17

Thread: [RESOLVED] vibrate an image

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Resolved [RESOLVED] vibrate an image

    Hi
    I have an alarm icon in my form.I want to vibrate it.How can I do i?
    thanks

  2. #2
    Hyperactive Member kazar's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    323

    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

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  4. #4
    Hyperactive Member kazar's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    323

    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

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    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

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: vibrate an image

    How many iterations?
    I tried this loop
    VB Code:
    1. For i=0 to 1000
    2. Image1.left=Image1.left+50
    3. Image1.left=Image1.left-50
    4. Image1.Top=Image1.Top+50
    5. Image1.Top=Image1.Top-50
    6. Next i

    is there a better way?
    thanks

  9. #9
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: vibrate an image

    OK I'm waiting for ur example
    thanks

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: vibrate an image

    Here is a small example of shaking a form.

    Click the form to start/stop

    VB Code:
    1. Option Explicit
    2.  
    3. Private miTogglePos As Integer
    4.  
    5. Private Sub Form_Click()
    6.     Timer1.Enabled = Not Timer1.Enabled
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10.     Timer1.Enabled = False
    11.     Timer1.Interval = 25
    12.     miTogglePos = 1
    13. End Sub
    14.  
    15. Private Sub Timer1_Timer()
    16.     Select Case miTogglePos
    17.         Case 1
    18.             Me.Move 100, 100
    19.             miTogglePos = 2
    20.         Case 2
    21.             Me.Move 200, 100
    22.             miTogglePos = 3
    23.         Case 3
    24.             Me.Move 200, 200
    25.             miTogglePos = 4
    26.         Case 4
    27.             Me.Move 100, 200
    28.             miTogglePos = 1
    29.     End Select
    30. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    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

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: vibrate an image

    Updated code to move a image control for 5 seconds.
    VB Code:
    1. Option Explicit
    2.  
    3. Private miTogglePos As Integer
    4. Private mlElapsedTime As Long
    5.  
    6. Private Sub Form_Click()
    7.     Timer1.Enabled = Not Timer1.Enabled
    8.     mlElapsedTime = 0
    9. End Sub
    10.  
    11. Private Sub Form_Load()
    12.     Timer1.Enabled = False
    13.     Timer1.Interval = 25
    14.     miTogglePos = 1
    15.     Image1.Picture = LoadPicture("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Misc\FACE03.ICO")
    16. End Sub
    17.  
    18. Private Sub Timer1_Timer()
    19.     If mlElapsedTime = 5000 Then Timer1.Enabled = False
    20.     mlElapsedTime = mlElapsedTime + Timer1.Interval
    21.     Select Case miTogglePos
    22.         Case 1
    23.             Image1.Move 1000, 1000
    24.             miTogglePos = 2
    25.         Case 2
    26.             Image1.Move 1100, 1000
    27.             miTogglePos = 3
    28.         Case 3
    29.             Image1.Move 1100, 1100
    30.             miTogglePos = 4
    31.         Case 4
    32.             Image1.Move 1000, 1100
    33.             miTogglePos = 1
    34.     End Select
    35. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: vibrate an image

    RobDog888 u're great
    Thanks a lot

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    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

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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:
    1. Private Const SND_ASYNC As Long = &H1
    2.  
    3. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    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
  •  



Click Here to Expand Forum to Full Width