Dialog Resource

Basics

A dialog resource contains instructions for placing the GUI elements of a dialog.
Each dialog resource file must be named dialogname.res and be placed within the dialogs folder of the res path in a plugin directory.
The file should be structured like this:

DIALOG dlgname // Like the file name without ".res"
{
  [Elements and groups]
}

The dlgname identifier must also be an enum value in the file c4d_symbols.h within the res folder in a plugin directory. See Dialog Layout for more information.

Elements

The dialog group contains one or more dialog elements formatted like this:

[Element type] [id]
{
  [Flags and options]
}

The id is optional. All elements in a dialog that need to be reference in any way should be given an ID.
This can either be just an integer or, more recommended, an enum value from the file c4d_symbols.h within the res folder in a plugin directory. Here is an example:

DIALOG MYDIALOG
{
  NAME DIALOG_TITLE;

  GROUP MYGROUP
  {
    COLUMNS 1;
    SPACE 4,4;
    BORDERSIZE 4,4,4,4;

    STATICTEXT { NAME MYSTATICTEXT; }
  }

  DLGGROUP { OK; CANCEL; }
}

See Element Types for a list all valid element types. The flags and options available varies between the elements, but some are common and are described in the next sections.

Layout Flags

The layout of the dialogs in Cinema 4D is dynamic. That means that one does not specify the exact position of an element but rather its relation to other elements.
This ensures that the dialogs are resolution independent and allows easy scaling of the whole layout.

As a rule of thumb, Cinema 4D always ensures that a dialog element gets at least the space that it has requested. This can either be a manually specified size or the minimum size of the component.
For most dialog elements one can additionally specify how they should behave if they are to be placed within a space that is larger than their minimum size. These are the possible flags:

Layout FlagExplanation
FIT_VFit the element vertically.
FIT_HFit the element horizontally.
CENTER_VCenter the object vertically.
CENTER_HCenter the object horizontally.
ALIGN_LEFTAlign the object left.
ALIGN_RIGHTAlign the object right.
ALIGN_TOPAlign the object on top.
ALIGN_BOTTOMAlign the object on bottom.
SCALE_HAllows the parent to scale the element horizontally.
SCALE_VAllows the parent to scale the element vertically.

For elements that support the layout flags, they are listed as [LAYOUTFLAGS].

Size Flag

Some elements support the option to specify their size manually. This is done using the flag:

Size FlagExplanation
SIZE width, heightSpecify the size manually.

Negative values of width and height specify absolute pixel values. For example SIZE -100,-20; means 100 pixels wide and 20 pixels high.
Positive values specify the width in 1/10ths of a character and the height in 1/10ths of a line. So SIZE 100,10; gives an element that is 10 characters wide and one line high.
A width or height of 0 means the default or minimum size of the element.

For elements that support the size flag, it is listed as [SIZE].

Name Flag

The names of tabs or groups and the texts of static text fields or buttons are specified using the flag:

Name FlagExplanation
NAME stringidElement name or text.

stringid should be an identifier from the string resource file dialogname.str that belongs to the dialog.
The identifier must also be listed as an enum in the c4d_symbols.h. It is not possible to specify a string directly. This ensures that all text within a dialog can be localized.

For elements that support the name flag, it is listed as [NAME].

Element Types

Here are links to the valid element types:

Custom GUI Element Types

There are also some more custom GUI elements provided as libraries in the API. See the c4d_customgui folder.