If you have Windows development tools, you can use them to create the resources for your CodeWarrior projects. Just be sure to give the resources the same ID numbers as their Mac counterparts.
One tool that can help speed the conversion is ResConverter by Mark F. Coniglio, especially for items such as cursors.
For graphics with transparency, I recommend the SuperPNG Photoshop plugin from Fnordware. I place a BMP graphic as a placeholder, then replace it with a PNG resource later. (Please tell me if there's a better way.)
#include <WINDOWS.H>
#include <WINGDI.H>
#include <WINUSER.H>
#include "afxres.h"
These files must be included, as well as any header files with constants.Note that the samples in the SDK have plugin.h duplicated in the Win directory, but CodeWarrior is smart enough to find the one in your Common folder, so I suggest keeping only that one.
#include "Plugin.h"
You'll need a PIPL resource, and can choose either
#include "BasePiPL.rc"
which is found in many of the sample projects in the SDK, or include this one as a resource. Use either, but don't use both.
16000 PIPL DISCARDABLE "..\\..\\Common\\Win\\PiPL.bin"
String tables are defined like so. You'll recognize kFilterStrings as the constant defined in most sample plugins as 16000. You can simply type the number, but I prefer the constant as a reminder of the table's purpose.
STRINGTABLE DISCARDABLE
BEGIN
kFilterStrings "<Mac strings begin at index 1>"
16001 "Paths"
16002 "Arrowheads"
16003 "Paths"
16004 "Arrowheads and halos"
16005 ""
16006 ""
16007 "String 5-6 are purposely left blank"
END
Note that each string has its own resource number. For this reason, it's wise to leave enough numbers between Mac STR# resources to allow for the individual numbers under Windows.
A dialog box is defined as follows. This one is actually just copied from one of the sample project's existing .rc file. The first line begins with the resource number, or the constant for it, and the last four numbers are the coordinates of the upper left corner, then the width and height in Windows dialog units, which change depending on the current system font. More on this later.
The dialog items are typically defined by the item type, the item's text, its item number, left, top, width, and height.
Control items typically are defined by the control's text or graphic contents, item number, Windows class name, Windows Style, left, top, width, and height. See the ADM documentation for control information.
kErrorDialogID DIALOG DISCARDABLE 0, 0, 185, 92
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Plug-in Error"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",kDlgOKButton,127,65,50,14
LTEXT "Message",kErrorMessageText,43,12,126,28
LTEXT "Code",kErrorCodeText,13,66,30,8
CONTROL "",4,"Static",SS_BLACKFRAME,10,10,18,20
END
kAboutDLOG DIALOG DISCARDABLE 0, 0, 211, 94
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "About Arrowheads"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",kDlgOKButton,15,72,40,14
LTEXT "Arrowheads, v 10.0",IDC_STATIC,75,6,131,12
LTEXT "©1996-2003 Rick Johnson/Graffix",
IDC_STATIC,75,20,131,70
CONTROL kLogo2,4,"Static",SS_BITMAP,5,7,60,24
END
In the above example, I added a logo graphic with a predefined constant kLogo2 for the resource ID. The graphic itself is a BMP file, imported as shown below:
kLogo2 BITMAP DISCARDABLE "logo2.bmp" // my logo
If you want to replace it in code with a PNG graphic, you can import a PNG file as a resource like this:
kLogo2PNGID PNGI MOVEABLE PURE "logo2.png"
The above dialogs were defined in a Windows-based resource editor. To simply copy the coordinates item-by-item from your Mac resource file using actual pixel dimensions, you could build a dialog like the one below:
kNagDLOG DIALOG DISCARDABLE 0, 0, 272, 212
STYLE DS_LOCALEDIT | DS_MODALFRAME | WS_POPUP
CAPTION "Please register"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Register",kNagOKButton,172,168,76,20
PUSHBUTTON "Not yet",kNagCancelButton,24,168,80,20
LTEXT "You have not yet registered this plugin!",kNagHead,20,52,184,36
LTEXT "Please register it.",
kNagMessage,20,100,236,64
CONTROL kPluginName,kNagGraphic,"Static",SS_BITMAP,20,20,154,20
END
kPluginName BITMAP DISCARDABLE "pluginName.bmp"
The key here is to add add either "DS_LOCALEDIT" or "0x0020" to the dialog's properties. It will then use pixels instead of dialog units, which will allow you to specify item locations and sizes by their Mac resource counterparts.
Finally, you can add version info in this complex structure.
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x9L
#else
FILEFLAGS 0x8L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Graffix\0"
VALUE "FileDescription", "Arrowheads plugin\0"
VALUE "FileVersion", "1,0,0,0\0"
VALUE "InternalName", "Arrowheads\0"
VALUE "LegalCopyright", "Copyright © 1998-2003\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "Arrowheads.aip\0"
VALUE "PrivateBuild", "1\0"
VALUE "ProductName", "Graffix Arrowheads\0"
VALUE "ProductVersion", "10, 0, 0, 0\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
For more resource information, I suggest studying the Windows samples in the SDK, although some developers say they just write them in a Windows-based editor and copy the .rc files to the CodeWarrior project.