Professional Web Applications Themes

Resource files and Carbon - PLEASE HELP! - Mac Programming

I've been messing with this for hours, and am at my wit's end. If anyone has an ideas, please help! I find that when using FSpOpenResFile as a Carbon-compatible replacement to the old OpenResFile, that my res files no longer behave as they used to. Previously, I could open many files, and when trying to load a given resource, if it didn't exist in the current file, other open resource files would be searched, going backwards in the order that I opened them. But once I switch to FSpOpenResFile, I seem to have to use UseResFile() to switch between current ...

  1. #1

    Default Resource files and Carbon - PLEASE HELP!

    I've been messing with this for hours, and am at my wit's end. If anyone
    has an ideas, please help!

    I find that when using FSpOpenResFile as a Carbon-compatible replacement
    to the old OpenResFile, that my res files no longer behave as they used
    to. Previously, I could open many files, and when trying to load a given
    resource, if it didn't exist in the current file, other open resource
    files would be searched, going backwards in the order that I opened them.

    But once I switch to FSpOpenResFile, I seem to have to use UseResFile()
    to switch between current files, since I seem to only be able to read
    from the current file, even though I'm using GetResource (not
    Get1Resource).

    Is there a way to fix this? Or do I just have to live with it?

    Here's my Carbon-compatible replacement for OpenResFile:

    short MyOpenResFile(Str255 fileName)
    {
    FSSpec dir, file;
    Boolean targetIsFolder, wasAliased;
    short curResRefNum;
    OSErr err = noErr;

    curResRefNum = -1;

    // get directory of application
    err = GetCurrentResFileDirectory(&dir);

    if (err == noErr)
    {
    // get frame resource file, and resolve alias (if any)
    err = FSMakeFSSpec(dir.vRefNum, dir.parID, fileName, &file );
    }

    if (err == noErr)
    {
    err = ResolveAliasFile( &file, true, &targetIsFolder,
    &wasAliased);
    }

    if (err == noErr)
    {
    curResRefNum = FSpOpenResFile(&file,fsRdPerm);
    }

    return curResRefNum;
    }

    -Vern

    --
    --
    EarthLink User <vernjensenearthlink.net>
    Vern Jensen Guest

  2. #2

    Default Re: Resource files and Carbon - PLEASE HELP!

    Hello Vern,

    I'm not exactly sure about this, but I believe you cannot be sure in Carbon
    that the opened resource file is appended to the end of the resource chain.

    This must be the reason for Apple having added some new resource manager
    calls for manipulating the resource chain.

    Maybe a call to the function InsertResourceFile(file, kRsrcChainBelowAll)
    after opening it will solve your problems.

    I never had problems because I always called UseResFile after loading a
    file.

    ----------------
    Sebastian Wegner

    [url]http://www.mcsebi.com/[/url]

    Sebastian Wegner Guest

Similar Threads

  1. <img> tag and resource files for scr-source?
    By Ole Hanson in forum ASP.NET Building Controls
    Replies: 3
    Last Post: January 12th, 01:20 PM
  2. memory mapped files under Carbon
    By Jedidja Bourgeois in forum Mac Programming
    Replies: 1
    Last Post: September 10th, 08:11 PM
  3. HELP: Fireworks can not run. The resource files are missing or damaged
    By college guy webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 4
    Last Post: September 3rd, 07:00 PM
  4. Using Resource Files
    By Hazem Abu Ghazaleh in forum ASP.NET General
    Replies: 0
    Last Post: July 28th, 10:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139