🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #1243

Re: Changing a PlaySound path name on the fly...

#1243
From: Nicholas Gessler
Date: Sat, 11 Aug 2001 23:25
55 lines
3138 bytes
Thanks Yoto,

I'll try your approach below:

> Here's how your code may look like:
>
>   String FileName(WinDir);
>   FileName += "\\media\\jungle asterisk.wav";
>   PlaySound(FileName.c_str(), NULL, SND_ASYNC | SND_FILENAME);
>
> Note that your code assumes that this file exists.  However, on most
> systems (including mine), this file is not available.  A more correct
> approach is to use the user's default sounds such "SystemExclamation",
> "SystemQuestion", "SystemHand", etc:
>
>   PlaySound("SystemExclamation", NULL, SND_ASYNC | SND_ALIAS);

Yes, your point is well taken.  This silly application was intended to
gain/teach a little bit about playing wave files.  I calle it "wave harp."
It is an annoying little work that plays 64 noises in the Win98 media file
as you move the mouse around the window.

>   http://www.bcbdev.com/faqs/faq54.htm

Based on your previous recommendation, I independently came up with:

    // Fetch the windows directory
    char WinDir[MAX_PATH];

    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
       WinDir[MAX_PATH] = '\0';
       GetWindowsDirectory(WinDir,MAX_PATH);
       Form1->Edit1->Text = MAX_PATH;  // from which I see that MAX_PATH =
260
    }

I then go through a MouseOver event handler with 64 statements similar to
this:

        if (X == 10) PlaySound(strcat(WinDir,"\\media\\jungle
asterisk.wav"), "", SND_ASYNC);

This also works, though I realize that WinDir just keeps growing in size, so
it plays the first sound, the paths for the remaining sounds are too long
and are therefore ignored, and I get an error very soon because WinDir has
grown larger than 260.  I was looking for a simple way to concatenate the
path and file names.  I guess it will simply take a few lines to do so.  I
guess there's not much point in avoiding pasting all these lines in 64
times.  I understand these other problems and can find a way to work around
them.

Cheers,
Nick
Technical Details
Message-ID: <3b75be83$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!opentransit.net!proxad.net!fr.usenet-edu.net!usenet-edu.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3b736dcb$1_2@dnews> <MPG.15dd39c3e95d87759896ac@newsgroups.borland.com> <3b756607_1@dnews> <MPG.15df44279eebbab89896c1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,c5d6b1e2caa77662
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2001-08-11 16:38:53 PST
Reply-To: "Nicholas Gessler" <gessler@ucla.edu>
From: "Nicholas Gessler" <gessler@ucla.edu>
Newsgroups: borland.public.cppbuilder.multimedia
References: <3b736dcb$1_2@dnews> <MPG.15dd39c3e95d87759896ac@newsgroups.borland.com> <3b756607_1@dnews> <MPG.15df44279eebbab89896c1@newsgroups.borland.com>
Subject: Re: Changing a PlaySound path name on the fly...
Date: Sat, 11 Aug 2001 16:25:29 -0700
Lines: 57
Organization: UCLA - Geography
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2615.200
NNTP-Posting-Host: 4.40.56.105
Message-ID: <3b75be83$1_1@dnews>
X-Trace: dnews 997572227 4.40.56.105 (11 Aug 2001 16:23:47 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!opentransit.net!proxad.net!fr.usenet-edu.net!usenet-edu.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews