# Dialog

The Dialog function shows a dialog.

    int WINAPI Dialog(
      int PluginNumber,
      int X1,
      int Y1,
      int X2,
      int Y2,
      const char *HelpTopic,
      struct FarDialogItem *Item,
      int ItemsNumber
    );

### Parameters

PluginNumber
Number of the plugin module. It is passed to the plugin in the SetStartupInfo function.
X1, Y1, X2, Y2
Dialog coordinates. You can specify them explicitly or use `"Width x Height"` formula - in this case both X1 and Y1 must be set to -1, while X2 and Y2 define dialog width and height respectively. In the latter case the dialog will be automatically centered on the screen. X2 and Y2 parameters can't be less than zero.
HelpTopic
Help topic associated with the dialog. It can be NULL if help is not required.
Item
Address of an array of FarDialogItem structures. Each structure describes one dialog item.
ItemsNumber
Number of FarDialogItem structures.

### Return value

This function returns either -1, if the user cancelled the dialog, or the index of the selected dialog item in the Item array.

### Remarks

FAR transforms Item elements to its own internal structure before creating a dialog. After dialog processing is over, Item elements array is adjusted according to changes made in the progress of user work with the dialog.

### Example

Example from the configuration dialog of TempPanel plugin:

    int Config()
    {
      struct InitDialogItem InitItems []={
        DI_DOUBLEBOX,3,1,72,8,0,0,0,0,(char *)MConfigTitle,
        DI_CHECKBOX,5,2,0,2,0,0,0,0,(char *)MConfigAddToDisksMenu,
        DI_FIXEDIT,7,3,7,3,1,0,0,0,"",
        DI_TEXT,9,3,0,3,0,0,0,0,(char *)MConfigDisksMenuDigit,
        DI_TEXT,5,4,0,4,0,0,DIF_BOXCOLOR|DIF_SEPARATOR,0,"",
        DI_CHECKBOX,5,5,0,5,0,0,0,0,(char *)MConfigCommonPanel,
        DI_TEXT,5,6,0,6,0,0,DIF_BOXCOLOR|DIF_SEPARATOR,0,"",
        DI_BUTTON,0,7,0,7,0,0,DIF_CENTERGROUP,1,(char *)MOk,
        DI_BUTTON,0,7,0,7,0,0,DIF_CENTERGROUP,0,(char *)MCancel
      };
      struct FarDialogItem DialogItems[sizeof(InitItems)/sizeof(InitItems[0])];
      . . .
      InitDialogItems(InitItems,DialogItems,
                       sizeof(InitItems)/sizeof(InitItems[0]));
      . . .
      int ExitCode=Info.Dialog(Info.ModuleNumber,
                      -1,-1,76,10,
                      "TempCfg",DialogItems,
                      sizeof(DialogItems)/sizeof(DialogItems[0]));
      if (ExitCode != 7)
        return(FALSE);
    . . .
    }

See also:
DialogEx, service functions, Message, InitDialogItems