Results 1 to 7 of 7

Thread: C# equivalent of VB beep?

  1. #1

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796

    C# equivalent of VB beep?

    Does C# have an equivalent of the VB beep?

    Either it does not, or I'm too dumb to find it in the documentation.

    If there is none, what's the best way to produce simple sound cues, like those MessageBox produces?

    I know I can install ActiveX 9, which would be fine for playing mpegs etc. but it seems like overkill for a simple beep - and MessageBox seems to manage it without it.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Microsoft.VisualBasic.Interaction.Beep();

    I couldn't get it to work though on my laptop. I am not sure why. You are probably going to need to reference the VB namespaces.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You could simply grab MessageBeep from User32.dll.

    And it's DirectX 9, ActiveX is something different.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Yes, mea culpa, I meant DirectX of course.

    I was hoping to avoid anything than only runs on Windows, as I like to keep all my code portable.

    I can't believe C# does not have native support for a simple beep. Unix/Linux programs can beep.

    Has anybody run the C# MessageBox on a non-Windows OS? Does it beep?

    If MS can do it within the native framework, there should be a way.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    A search for "Beep" and "MessageBeep" turns up nothing in the whole .Net library.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Unless somebody comes up with a smart idea, it looks as if I will be forced to go the Windows route.

    At least I can encapsulate it and make sure it falls over in a dignified manner on Linux. I guess I could in theory write a separate sound handler for each OS type, but that's a big pain. Surely that is the sort of thing C# should handle seamlessly?

    Seems funny that such a basic issue is not covered.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    MS claims portability for C#, yet the framework leans so heavily towards windows that I pity the mono developers.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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