Hi all,
I've been trying to get a set of custom strings in to the Format popup of a
save dialog created with NavCreatePutFileDialog. I've done a bunch of
searches to find sample code on this as the API documentation seems sparse,
but everything I try ends up with the application crashing when I call my
dialog. My most recent search suggested a simple solution from this group:
CFArrayRef myCFArrayRef = NULL;
CFStringRef strs[2];
strs[0] = CFSTR("Standard MIDI file");
strs[1] = CFSTR("Hitlist Document");
myCFArrayRef = CFArrayCreate(NULL,(void *)strs,2,&kCFTypeArrayCallBacks);
dialogOptions.popupExtension = myCFArrayRef;
But even running something as simple as that using
'NavCreatePutFileDialog(&ndcOptions, '/?/?/?', '/?/?/?', NULL, NULL,
&ndrRef);' is causing the app to crash with 'Signal 10'.
I've tried a bunch of other solutions involving creating arrays of various
types of objects and allocating them to that member of the dialog options,
but nothing seems to be working for me. This is with a basic Carbon app,
implemented in main.c with Carbon.h included and nothing else.
Does anyone have any idea what could be going on? I've been tearing my hair
out trying to work out why the varied methods I'm finding out there aren't
working for me and any help would be much appreciated!
Thanks.
- Matt.
Eric VERGNAUD - 26 Jan 2005 13:44 GMT
dans l'article TsCJd.11659$mo2.894496@news.xtra.co.nz, Andy Bearsley à
andy@ambient.gen.nz.remoove a écrit le 26/01/05 2:43 :
> Hi all,
>
[quoted text clipped - 43 lines]
>
> - Matt.
I guess NavCreatePutFileDialog doesn't like '/?/?/?'. Try
OsType creator = '\?\?\?\?';
OsType kind = '\?\?\?\?';
NavCreatePutFileDialog(&ndcOptions, kind, creator , NULL, NULL, &ndrRef);
Eric
MFW - 26 Jan 2005 21:40 GMT
(Original poster here, had to get someone else to post as my client was
playing up yesterday).
Unfortunately, I tried replacing those with four character constants instead
and it still had problems. I can run the save dialog fine (even from that
for some reason) as long as I don't include the line:
dialogOptions.popupExtension = myCFArrayRef; Basically, as soon as I set
dialogOptions.popupExtension, the dialog crashes the app when it opens.
Thanks for pointing it out though, I'll double check my other stuff :)
- Matt.
> dans l'article TsCJd.11659$mo2.894496@news.xtra.co.nz, Andy Bearsley à
> andy@ambient.gen.nz.remoove a écrit le 26/01/05 2:43 :
[quoted text clipped - 62 lines]
>
> Eric
Eric VERGNAUD - 27 Jan 2005 00:03 GMT
dans l'article 57UJd.11962$mo2.924387@news.xtra.co.nz, MFW à
mattremove@ambient.gen.nz a écrit le 26/01/05 22:40 :
> (Original poster here, had to get someone else to post as my client was
> playing up yesterday).
[quoted text clipped - 7 lines]
>
> - Matt.
Here is my code for doing this and it works perfectly:
CFArrayRef XOpenFileFilter::_MAC_BuildPopup() const
{
CFMutableArrayRef result;
CFStringRef string;
XOpenFileDescription** first;
XOpenFileDescription** last;
long count;
if (fDescriptions.GetCount() == 0)
return 0; // no filtering
count = fDescriptions.GetCount();
result = ::CFArrayCreateMutable(kCFAllocatorDefault,count,0);
first = fDescriptions.LockAndGetFirst();
last = first + count;
while(first<last)
{
XMacCFString caption((*first)->fCaption);
string = caption;
string = ::CFStringCreateCopy(kCFAllocatorDefault,string);
::CFArrayAppendValue(result,string);
first++;
}
fDescriptions.Unlock();
return result;
}