Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. mouse enter event [modified]

mouse enter event [modified]

Scheduled Pinned Locked Moved C#
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    treah
    wrote on last edited by
    #1

    hi, i have to play sound when user enter the mouse on toolstrip button,i have written followin code but it is not working.plzz help me out where is the problem:confused: private void button5_Click(object sender, EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); b=1 if (a == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } private void tsbutton_MouseEnter(object sender,EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); a = 1; if (b == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } thanks -- modified at 4:33 Saturday 14th July, 2007

    S 1 Reply Last reply
    0
    • T treah

      hi, i have to play sound when user enter the mouse on toolstrip button,i have written followin code but it is not working.plzz help me out where is the problem:confused: private void button5_Click(object sender, EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); b=1 if (a == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } private void tsbutton_MouseEnter(object sender,EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); a = 1; if (b == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } thanks -- modified at 4:33 Saturday 14th July, 2007

      S Offline
      S Offline
      satsumatable
      wrote on last edited by
      #2

      private void tsbutton_MouseEnter(object sender,EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); a = 1; if (b == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } In this a = 1; if (b == 1) { When your b will become 1 ? Is this is hiccup?

      T 1 Reply Last reply
      0
      • S satsumatable

        private void tsbutton_MouseEnter(object sender,EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); a = 1; if (b == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } In this a = 1; if (b == 1) { When your b will become 1 ? Is this is hiccup?

        T Offline
        T Offline
        treah
        wrote on last edited by
        #3

        now plz check this out private void button5_Click(object sender, EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); b=1 if (a == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } private void tsbutton_MouseEnter(object sender,EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); a = 1; if (b == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } :rolleyes:

        L 1 Reply Last reply
        0
        • T treah

          now plz check this out private void button5_Click(object sender, EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); b=1 if (a == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } private void tsbutton_MouseEnter(object sender,EventArgs e) { System.Media.SoundPlayer player = new SoundPlayer(); a = 1; if (b == 1) { player.SoundLocation = "C:\\WINDOWS\\Media\\tada.wav"; player.Play(); } } :rolleyes:

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, some suggestions: 1. have only one SoundPlayer, make it a class member 2. dont use variable names such as a and b, no one understands them (including yourself) 3. have a bool "soundEnabled" which gets set/cleared by button5 and ... 4. have a bool "alreadyPlaying" to prevent multiple concurrent sounds 5. is MouseEnter handler first check soundEnabled, if false, dont do anything; check alreadyPlaying, if false, set it true and start sound asynchronously 6. biggest problem will be how to clear alreadyPlaying since there is no event for end of sound. Maybe a Forms.Timer is the way to go. :)

          Luc Pattyn


          try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups