SIZED_DIALOG | Macro

dialogs.h

#define SIZED_DIALOG(NumbItems,StrLen) struct {

| unsigned short TextOffset;

| unsigned short NumItems;

| unsigned char Width, Height;

| Dialog_Callback_t Callback;

| DIALOG_ITEM Fields[(NumbItems)+1];

| char String[StrLen];

}

A macro to help defining dialogs, it is nearly the same as DIALOG.

There are two main dificulties one encouters using the DIALOG structure:
First there is a variable size array, and variable size arrays can't be initialized with non constant value.
Secondly it doesn't include strings, which should better be placed just after the DIALOG in memory.
SIZED_DIALOG avoids both of these problems: It needs two argument : the number of Items NumbItems and the size of the all the strings together StrLen, and defines a struct from this, wich is the same as DIALOG but with some place for the strings: you can define a dilalog using SIZED_DIALOG(NumbItems,StrLen)={/*Dialog definition*/}. It is done in the given examples. If you use that macro, it will fill to the right number of Item, and If you forget to add an item with type D_END after the last used Item, it is automatically done.
Using SIZED_DIALOG also helps to get the offset of the strings. You can initialize it with offsetof(SIZED_DIALOG(ItemsNum,0),String)