Article View: borland.public.cppbuilder.multimedia
Article #1226Re: Wierd Program (or Brain) Bug...
From: 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."
Technical Details
Message-ID:
<3b67c5c5_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsReferences:
<3b6794e8$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d0fc,4c584af82a6d7286 X-Google-Attributes: gid10d0fc,public X-Google-ArrivalTime: 2001-08-01 02:04:11 PST From: "Corey Murtagh" <emonk@ihug.co.nz> Newsgroups: borland.public.cppbuilder.multimedia References: <3b6794e8$1_2@dnews> Subject: Re: Wierd Program (or Brain) Bug... Date: Wed, 1 Aug 2001 21:03:12 +1200 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2314.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 NNTP-Posting-Host: 203.173.208.37 Message-ID: <3b67c5c5_2@dnews> X-Trace: dnews 996656581 203.173.208.37 (1 Aug 2001 02:03:01 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews