Defining Windows Resources
Prev | Chapter 4. Programming with Cygwin | Next

## Defining Windows Resources

`windres` reads a Windows resource file (`*.rc`) and converts it to a res or coff file. The syntax and semantics of the input file are the same as for any other resource compiler, so please refer to any publication describing the Windows resource format for details. Also, the `windres` program itself is fully documented in the Binutils manual. Here's an example of using it in a project:

    myapp.exe : myapp.o myapp.res
    	gcc -mwindows myapp.o myapp.res -o $@

    myapp.res : myapp.rc resource.h
    	windres $< -O coff -o $@

What follows is a quick-reference to the syntax `windres` supports.

    id ACCELERATORS suboptions
    BEG
    "^C" 12
    "Q" 12
    65 12
    65 12 , VIRTKEY ASCII NOINVERT SHIFT CONTROL ALT
    65 12 , VIRTKEY, ASCII, NOINVERT, SHIFT, CONTROL, ALT
    (12 is an acc_id)
    END

    SHIFT, CONTROL, ALT require VIRTKEY

    id BITMAP memflags "filename"
    memflags defaults to MOVEABLE

    id CURSOR memflags "filename"
    memflags defaults to MOVEABLE,DISCARDABLE

    id DIALOG memflags exstyle x,y,width,height styles BEG controls END
    id DIALOGEX memflags exstyle x,y,width,height styles BEG controls END
    id DIALOGEX memflags exstyle x,y,width,height,helpid styles BEG controls END

    memflags defaults to MOVEABLE
    exstyle may be EXSTYLE=number
    styles:	CAPTION "string"
    	CLASS id
    	STYLE  FOO | NOT FOO | (12)
    	EXSTYLE number
    	FONT number, "name"
    	FONT number, "name",weight,italic
    	MENU id
    	CHARACTERISTICS number
    	LANGUAGE number,number
    	VERSIONK number
    controls:
    	AUTO3STATE params
    	AUTOCHECKBOX params
    	AUTORADIOBUTTON params
    	BEDIT params
    	CHECKBOX params
    	COMBOBOX params
    	CONTROL ["name",] id, class, style, x,y,w,h [,exstyle] [data]
    	CONTROL ["name",] id, class, style, x,y,w,h, exstyle, helpid [data]
    	CTEXT params
    	DEFPUSHBUTTON params
    	EDITTEXT params
    	GROUPBOX params
    	HEDIT params
    	ICON ["name",] id, x,y [data]
    	ICON ["name",] id, x,y,w,h, style, exstyle [data]
    	ICON ["name",] id, x,y,w,h, style, exstyle, helpid [data]
    	IEDIT params
    	LISTBOX params
    	LTEXT params
    	PUSHBOX params
    	PUSHBUTTON params
    	RADIOBUTTON params
    	RTEXT params
    	SCROLLBAR params
    	STATE3 params
    	USERBUTTON "string", id, x,y,w,h, style, exstyle
    params:
    	["name",] id, x, y, w, h, [data]
    	["name",] id, x, y, w, h, style [,exstyle] [data]
    	["name",] id, x, y, w, h, style, exstyle, helpid [data]

    [data] is optional BEG (string|number) [,(string|number)] (etc) END

    id FONT memflags "filename"
    memflags defaults to MOVEABLE|DISCARDABLE

    id ICON memflags "filename"
    memflags defaults to MOVEABLE|DISCARDABLE

    LANGUAGE num,num

    id MENU options BEG items END
    items:
    	"string", id, flags
    	SEPARATOR
    	POPUP "string" flags BEG menuitems END
    flags:
    	CHECKED
    	GRAYED
    	HELP
    	INACTIVE
    	MENUBARBREAK
    	MENUBREAK

    id MENUEX suboptions BEG items END
    items:
    	MENUITEM "string"
    	MENUITEM "string", id
    	MENUITEM "string", id, type [,state]
    	POPUP "string" BEG items END
    	POPUP "string", id BEG items END
    	POPUP "string", id, type BEG items END
    	POPUP "string", id, type, state [,helpid] BEG items END

    id MESSAGETABLE memflags "filename"
    memflags defaults to MOVEABLE

    id RCDATA suboptions BEG (string|number) [,(string|number)] (etc) END

    STRINGTABLE suboptions BEG strings END
    strings:
    	id "string"
    	id, "string"

    (User data)
    id id suboptions BEG (string|number) [,(string|number)] (etc) END

    id VERSIONINFO stuffs BEG verblocks END
    stuffs:	FILEVERSION num,num,num,num
    	PRODUCTVERSION num,num,num,num
    	FILEFLAGSMASK num
    	FILEOS num
    	FILETYPE num
    	FILESUBTYPE num
    verblocks:
    	BLOCK "StringFileInfo" BEG BLOCK BEG vervals END END
    	BLOCK "VarFileInfo" BEG BLOCK BEG vertrans END END
    vervals: VALUE "foo","bar"
    vertrans: VALUE num,num

    suboptions:
    	memflags
    	CHARACTERISTICS num
    	LANGUAGE num,num
    	VERSIONK num

    memflags are MOVEABLE/FIXED PURE/IMPURE PRELOAD/LOADONCALL DISCARDABLE

Prev | Up | Next
Building and Using DLLs | Home | Profiling Cygwin Programs