🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #154

Re: Drag-and-drop 101

#154
From: Mike K
Date: Tue, 17 Jun 2008 13:48
23 lines
2139 bytes
Eliot Frank wrote:
> Mike K wrote:
>>
>> filename.SetLength(DragQueryFile((HDROP)message.Drop,i,fname.c_str(),MAX_PATH)); 
> 
> 
> This is very very wrong.  What's "fname"?  Is fname initialized to be 
> long enough to accept up to MAX_PATH bytes?  Since you don't show the 
> initialization code, I guess the answer is no.  If fname is an 
> uninitialized String (aka AnsiString), c_str() returns NULL (bad bad 
> craziness there).  Also you are passing a char const * (the result of 
> c_str()) to a function that expects a char * (I don't see why that 
> should even compile).
> 
> Just use the simple,
> 
>     char name[MAX_PATH];
>     DragQueryFile((HDROP)message.Drop,i,name,MAX_PATH);
>     filename = name;
> 
> -Eliot

Sorry, these are transcription typos.  I left out 'filename.SetLength(MAX_PATH)' and spelled 'filename' as 'fname'.  The code is right out of the Developers Guide.  Doesn't matter anyway, since the handler code is commented out.  The only way the app runs without crashing is by commenting out the message mapping macros. 
Technical Details
Message-ID: <4857C0B6.6060009@nospam.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4857aabb$1@newsgroups.borland.com> <4857b861@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,15dfb293aacb32ec
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Message-ID: <4857C0B6.6060009@nospam.net>
Date: Tue, 17 Jun 2008 08:48:38 -0500
From: Mike K <nospam@nospam.net>
User-Agent: Thunderbird 1.5.0.14 (Windows/20071210)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
To: Eliot Frank <eliot_h_frank@yahoosky.comski>
Subject: Re: Drag-and-drop 101
References: <4857aabb$1@newsgroups.borland.com> <4857b861@newsgroups.borland.com>
In-Reply-To: <4857b861@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 74.38.233.225
X-Trace: newsgroups.borland.com 1213710518 74.38.233.225 (17 Jun 2008 06:48:38 -0700)
Lines: 24
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
X-Original-Bytes: 1964