HOWTO convert a .rc file to VC++ flavored one

Recently I was in need to import a resource file (.rc) generated by ResEdit program into a Visual C++ program.
As long you do not open it with the VC embedded editor, only can only add it to the project.

Problems came when you try to use the embedded VC resource editor.  It usually fails to load, because of a problem in prsht.h.  I don’t want to touch it, because it is one of Windows SDK files.

I used the process below to finally get a full flavored VC++ resource file.

External included resources

If your original resource file is has any custom resource importing binary files, and you don’t want to touch them, the solution is to split it into two separate files, and include them in the project:

  • the first one with the editable resources that we will convert,
  • and the second one with these custom resources, that we will not touch.

Import the file

  • open the resource file with a text editor (select it from the project tree, and press F7),
  • remove any include-file except resource.h or similar files (if any),
  • copy and paste the lines below at the beginning of the file:
    #include "winres.h"
    #define WC_HEADER "SysHeader32"
    #define WC_LINK "SysLink"
    #define WC_LISTVIEW "SysListView32"
    #define WC_TREEVIEW "SysTreeView32"
    #define WC_COMBOBOXEX "ComboBoxEx32"
    #define WC_TABCONTROL "SysTabControl32"
    #define WC_IPADDRESS "SysIPAddress32"
    #define WC_PAGESCROLLER "SysPager"
    #define WC_NATIVEFONTCTL "NativeFontCtl"
    #define TRACKBAR_CLASS "msctls_trackbar32"
    #define UPDOWN_CLASS "msctls_updown32"
    #define PROGRESS_CLASS "msctls_progress32"
    #define HOTKEY_CLASS "msctls_hotkey32"
    #define ANIMATE_CLASS "SysAnimate32"
    #define MONTHCAL_CLASS "SysMonthCal32"
    #define DATETIMEPICK_CLASS "SysDateTimePick32"
    #define TOOLTIPS_CLASS "tooltips_class32"
    #define WC_BUTTON "Button"
    #define WC_STATIC "Static"
    #define WC_EDIT "Edit"
    #define WC_LISTBOX "ListBox"
    #define WC_COMBOBOX "ComboBox"
    #define WC_SCROLLBAR "ScrollBar"
    
    
  • save and close the file.

Convert it

  • open it with VC++ resource editor,
  • modify it and save again (open one item and click on Save toolbar button),
  • accept to replace the existing files with VC++ flavored ones.

Fix it

At this point, we have a file that doesn’t include any system-needed include-file, and that VC++ cannot load anymore.

We need to fix it.

  • open it with the text editor again (F7),
  • add at the beginning of the file:
    #include "winres.h"
  • look for 2 TEXTINCLUDE (usually near the end of the file),
  • add the line below between the following BEGIN and “\0”:
    "#include ""winres.h""\r\n"
  • save and close the file.

Save the final working file

  • reopen it with the VC resource editor,
  • modify and save it again.

Congratulations, you have converted your first resource file.