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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. When clicked a button on any application, play sound

When clicked a button on any application, play sound

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
6 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.
  • C Offline
    C Offline
    cedricvictor
    wrote on last edited by
    #1

    Hi All: I wanna implemented a application with MFC, when clicke a button on any application, select a icon on the desktop then play sound. I try to implement similar function with ON_WM_LBUTTONDOWN(), but not satisfied my request. If I click everywhere on desktop, it will play sound too. How do I implement this application? Does any keyword or reference? My English is not good. Please forgive me. Best regards, Victor

    L M 2 Replies Last reply
    0
    • C cedricvictor

      Hi All: I wanna implemented a application with MFC, when clicke a button on any application, select a icon on the desktop then play sound. I try to implement similar function with ON_WM_LBUTTONDOWN(), but not satisfied my request. If I click everywhere on desktop, it will play sound too. How do I implement this application? Does any keyword or reference? My English is not good. Please forgive me. Best regards, Victor

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      you need Windows Hooks to capture all mouse clicks; see http://msdn.microsoft.com/en-us/library/windows/desktop/ms644959(v=vs.85).aspx[^].

      Veni, vidi, abiit domum

      C 1 Reply Last reply
      0
      • C cedricvictor

        Hi All: I wanna implemented a application with MFC, when clicke a button on any application, select a icon on the desktop then play sound. I try to implement similar function with ON_WM_LBUTTONDOWN(), but not satisfied my request. If I click everywhere on desktop, it will play sound too. How do I implement this application? Does any keyword or reference? My English is not good. Please forgive me. Best regards, Victor

        M Offline
        M Offline
        Malli_S
        wrote on last edited by
        #3

        You'll have to use the concept of 'hook'. Please refer to hook details here. You can use this[^] article for your reference.

        [Delegates]      [Virtual Desktop]      [Tray Me !]
        -Malli...! :rose:****

        C 1 Reply Last reply
        0
        • L Lost User

          you need Windows Hooks to capture all mouse clicks; see http://msdn.microsoft.com/en-us/library/windows/desktop/ms644959(v=vs.85).aspx[^].

          Veni, vidi, abiit domum

          C Offline
          C Offline
          cedricvictor
          wrote on last edited by
          #4

          But, I added WM_LBUTTONDOWN into Mousehookproc, it does not work. which do I add in, WinProcHook or Mousehookproc? if I add into WinProcHook, how can I get the button? Thanks for your help, Victor

          1 Reply Last reply
          0
          • M Malli_S

            You'll have to use the concept of 'hook'. Please refer to hook details here. You can use this[^] article for your reference.

            [Delegates]      [Virtual Desktop]      [Tray Me !]
            -Malli...! :rose:****

            C Offline
            C Offline
            cedricvictor
            wrote on last edited by
            #5

            But, I added WM_LBUTTONDOWN into Mousehookproc, it does not work. which do I add in, WinProcHook or Mousehookproc? if I add into WinProcHook, how can I get the button? Thanks for your help, Victor

            M 1 Reply Last reply
            0
            • C cedricvictor

              But, I added WM_LBUTTONDOWN into Mousehookproc, it does not work. which do I add in, WinProcHook or Mousehookproc? if I add into WinProcHook, how can I get the button? Thanks for your help, Victor

              M Offline
              M Offline
              Malli_S
              wrote on last edited by
              #6

              Please verify that the Hook got installed properly. Once the hook is installed, you should be able to get the messages. When the mouse event is received, you can check the window handle. Using that window handle, identify the class type of the window.

              [Delegates]      [Virtual Desktop]      [Tray Me !]
              -Malli...! :rose:****

              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