InitDialogItems
The InitDialogItems function translates an
array of InitDialogItem structures to
an array of FarDialogItem structures.
Attention!
- The InitDialogItems function is not part of the standard API.
void InitDialogItems( const struct InitDialogItem *Init, struct FarDialogItem *Item, int ItemsNumber ) { int I; const struct InitDialogItem *PInit=Init; struct FarDialogItem *PItem=Item; for (I=0; I < ItemsNumber; I++,PItem++,PInit++) { PItem->Type=PInit->Type; PItem->X1=PInit->X1; PItem->Y1=PInit->Y1; PItem->X2=PInit->X2; PItem->Y2=PInit->Y2; PItem->Focus=PInit->Focus; PItem->Reserved=PInit->Selected; PItem->Flags=PInit->Flags; PItem->DefaultButton=PInit->DefaultButton; if ((unsigned int)PInit->Data < 2000) strcpy(PItem->Data,GetMsg((unsigned int)PInit->Data)); else strcpy(PItem->Data,PInit->Data); } }
Parameters
Init
Pointer to an array of InitDialogItem structures.
Each array item defines one dialog item.
Item
Pointer to an array of FarDialogItem structures
to initialize. Each array item will define one dialog item.
ItemsNumber
Number of elements in Init.
Return value
None.
Remarks
Use of the InitDialogItems function is reasoned by the following:
FarDialogItem.Data variable is large, that's why direct
initalization of an array of FarDialogItem structures may significantly increase
memory usage.
The example bellow shows how to use the InitDialogItems function and the InitDialogItem structure to create a dialog.
Example
TempPanel plugin configuration dialog sample:
int Config() { struct InitDialogItem InitItems []={ DI_DOUBLEBOX,3,1,72,8,0,0,0,0,(char *)MConfigTitle, DI_CHECKBOX,5,2,0,0,0,0,0,0,(char *)MConfigAddToDisksMenu, . . . DI_BUTTON,0,7,0,0,0,0,DIF_CENTERGROUP,1,(char *)MOk, DI_BUTTON,0,7,0,0,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: