wxWidgets Logo

Docs/technote

Tutorials
FAQ
Licence

Using WXR resource files under Windows

Sometimes, .wxr resources can be too large to be included directly in a C++ file. Some compilers have a rather small limit on the size of string that can be handled. As the wxWidgets 1.68 resource sample shows, you can include WXR files in Windows resource (.rc) files, using a TEXT resource, but this doesn't seem to work for all compilers.

Dominic Gallagher recently pointed out that you can use a custom resource name, which works with most compilers. In your .rc file, you could have, for example:

    dialogswxr WXRDATA dialogs.wxr
    menuswxr WXRDATA menus.wxr
    wgthermdwxr WXRDATA wgthermd.wxr
    wgthermmwxr WXRDATA wgthermm.wxr
    cddialogswxr WXRDATA cddialogs.wxr
    cdmenuswxr WXRDATA cdmenus.wxr
    sgwmwxr WXRDATA ..\sgwx\sgwm.wxr
    sgwbwxr WXRDATA ..\sgwx\sgwb.wxr

There is nothing extra one needs to do to have a "user defined" resource - any unexpected resource type string, in this case WXRDATA, is automatically user-defined.

To read in the resources, you need code such as the following:

    static char* resources[] = { "dialogswxr", "menuswxr", "wgthermdwxr",
      "wgthermmwxr", "cddialogswxr", "cdmenuswxr", "sgwmwxr", "sgwbwxr" };

    for (int i = 0; i < 8; i++)
    {
        char *res = wxLoadUserResource(resources[i], "WXRDATA");
        if (!wxResourceParseString(res))
            wxMessageBox("Could not parse resource.");
    }

And that's it!


 
 

Quick Links

 
  Tutorials
Mailing Lists
Latest Docs

Community

wxForum
wxCommunity
Applications
Add-ons
wxWiki
 
 
 
 

wx Solutions

 
   
 
 
 

wxWidgets Book

 
 

Buy it From:
Amazon.com
Amazon.co.uk

 
 
 
 

Donate Now

 
 
 
 
SourceForge.net Logo

Site design and update scripts by Kevin Ollivier, with special thanks to Brad Anderson for his improvements to the sidebar, intro table and navbar designs, Bryan Petty for the new wxWidgets blocks graphics and logo text, and to the wxWidgets community for all their helpful suggestions, comments and testing!