Thread View: borland.public.cppbuilder.multimedia
3 messages
3 total messages
Started by Nicholas Gessler
Wed, 01 Aug 2001 05:35
Wierd Program (or Brain) Bug...
Author: Nicholas Gessler
Date: Wed, 01 Aug 2001 05:35
Date: Wed, 01 Aug 2001 05:35
47 lines
2851 bytes
2851 bytes
This one has me stumped:
I wrote a stupid little program. There is one form, two edit boxes, and a
MouseOver event handler. In the handler is the code:
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
EditX->Text = " " + X;
EditY->Text = " " + Y;
// Jungle Sounds
if (X == 10) PlaySound("c:\\windows\\media\\jungle asterisk.wav",
"", SND_ASYNC);
if (X == 20) PlaySound("c:\\windows\\media\\jungle close.wav", "",
SND_ASYNC);
if (X == 30) PlaySound("c:\\windows\\media\\jungle critical
stop.wav", "", SND_ASYNC);
// and so on
// Musica Sounds
if (Y == 10) PlaySound("c:\\windows\\media\\musica asterisk.wav",
"", SND_ASYNC);
if (Y == 20) PlaySound("c:\\windows\\media\\musica close.wav", "",
SND_ASYNC);
if (Y == 30) PlaySound("c:\\windows\\media\\musica critical
stop.wav", "", SND_ASYNC);
if (Y == 40) PlaySound("c:\\windows\\media\\musica default.wav", "",
SND_ASYNC);
// and so with Utopia and Robotz on up to 370 for all 68 Media
sounds
// and the window is at least 400 by 400 in size.
}
So, OK, this is supposed to operate like a harp with strings in the
horizontal and vertical directions that are each attached to a sound and are
plucked when the cursor passes over them. And the sounds work OK.
What is puzzling is what appears in the EditX and EditY boxes. I was hoping
that the X and Y coordinates would appear. NOPE!
As you move the cursor in the X direction, what scrolls through the Edit Box
are the names of the paths to the first 9 jungle sounds.
As you move the cursor in the Y direction, what scrolls through the Edit Box
are the names of the paths to the first 11 jungle sounds.
And I do mean "scroll" as in an LED message board.
Can anyone tell me what is going on here? I am mystified.
Thanks,
Nick
Re: Wierd Program (or Brain) Bug...
Author: Corey Murtagh
Date: Wed, 01 Aug 2001 09:03
Date: Wed, 01 Aug 2001 09:03
39 lines
2323 bytes
2323 bytes
Nicholas Gessler <gessler@ucla.edu> wrote in message
news:3b6794e8$1_2@dnews...
> This one has me stumped:
> I wrote a stupid little program. There is one form, two edit boxes, and a
> MouseOver event handler. In the handler is the code:
>
> void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
> int X, int Y)
> {
> EditX->Text = " " + X;
Here's your problem. Adding an int to a char* will give you an index into
the array of chars. You need to do something like:
EditX->Text = AnsiString(" ") + Y;
Once you've got AnsiString involved in the act it properly appends the
string value of Y rather than indexing the string.
> What is puzzling is what appears in the EditX and EditY boxes. I was
hoping
> that the X and Y coordinates would appear. NOPE!
> As you move the cursor in the X direction, what scrolls through the Edit
Box
> are the names of the paths to the first 9 jungle sounds.
You're lucky you didn't get some random garbage, or cause an AV. Imagine
you have a block of memory where these string constants are stored, starting
with the first one (your block of spaces) and continuing through each wav
path. Index the space string by a large enough value and you'll find
yourself in the middle of one of the wav paths. This is probably not far
from what's actually happening.
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur."
Re: Wierd Program (or Brain) Bug...
Author: Nicholas Gessler
Date: Thu, 02 Aug 2001 01:20
Date: Thu, 02 Aug 2001 01:20
3 lines
956 bytes
956 bytes
Corey, Thanks. Nick
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads