3.62 DM_SetContent
Using this function the complete contents of an object can be set by the application in one function call. This function is significantly faster than setting the contents with DM_SetValue and the attribute AT_content. The function can be used in tablefields, poptexts, and listboxes.
DM_Boolean DML_default DM_EXPORT DM_SetContent
(
DM_ID objectID,
DM_Value *firstindex,
DM_Value *lastindex,
DM_Content *contentvec,
DM_UInt count,
DM_Options options
)
Parameters
-> DM_ID objectID
Specifies the object to be filled with the new contents.
-> DM_Value *firstindex
Controls which range of the contents is modified by this function. This parameter then defines the starting point of the range.
For a listbox or a poptext the type in the DM_Value structure has to be set to DT_index and the index value in the union has to be assigned the starting value. For tablefield you have to set the type in the DM_Value structure to DT_index and the index value in the union has to be assigned the starting value. For index.first you have to specify the row, for index.second you have to specify the column.
Note
If this parameter is a NULL pointer, the starting point has the following defaults, e.g.
listbox |
integer = 1 |
poptext |
integer = 1 |
tablefield |
index.first = 1, index.second = 1 |
-> DM_Value *lastindex
Controls which range of the contents is to be modified by this function. This parameter defines the ending point of the range. For a listbox or a poptext the type in the DM_Value structure has to be set to DT_index and the index value in the union has to be assigned the ending value. For tablefield you have to set the type in the DM_Value structure to DT_index and the index value in the union has to be assigned the ending value. For index.first you have to specify the row, for index.second you have to specify the column.
Note
If the parameter is a NULL pointer, the ending point is defined by the size of the new contents. The object contents is cut after the last modified entry.
listbox |
.itemcount is modified |
poptext |
.itemcount is modified |
tablefield |
if direction = 1, then .rowcount will be modified if direction = 2, then .colcount will be modified |
-> DM_Content *contentvec
Passes on the new contents of the object. The information in this array can be deleted after DM_SetContent has been called successfully in the application, since the DM copies the information.
For the object tablefield, the contents is specified as a list and is read according to the index. The attribute .direction determines whether the rectangular area which is defined by firstindex and lastindex, is filled over rows or columns:
.direction = 1 |
rectangular area is filled row-wise |
.direction = 2 |
rectangular area is filled column-wise |
-> DM_UInt count
Specifies the number of elements to be set by the call.
-> DM_Options options
Controls whether DM is to trigger rule processing after an attribute has been set successfully.
Option |
Meaning |
---|---|
This option means that the function call is not to trigger any internal events. If this flag is set, you can achieve a better performance in case that a lot of attribute changes have been made by the application. |
|
This option means that the function call is to trigger internal events. Then rules are triggered which have been defined for this object and which react to the changing of the specified attribute. |
|
This option means that on analyzing the attribute vector, the attribute .userdata has to be considered. If the option DMF_UseUserData is set, DM copies the userdata for each object entry. If the option is not set, the userdata will be ignored. |
|
This option means that on analyzing the attribute vector, the attribute .active is not to be considered. If the option DMF_OmitActive is set, DM will ignore the activating state for each object entry. If the object is not set, the activating state of the entries will be normally accepted. |
|
This option means that on analyzing the attribute vector, the attribute .content is not to be considered. If the option DMF_OmitStrings is set, DM will ignore the strings for each object entry. If the option is not set, the contents of the entries will normally be accepted. |
|
This option means that on analyzing the attribute vector, the attribute .sensitive is not to be considered. If the option DMF_OmitSensitive is set, DM will ignore the selectivity of each object entry. If the option is not set, the selectivity of the entries will normally be accepted. |
Return Value
TRUE |
Object was filled successfully. |
FALSE |
Object could not be filled. |
Example
Filling a tablefield:
static DM_Content *content;
static ushort ColCount;
void DML_default DM_ENTRY ContInit__2(
(DM_ID, table)
(long, fillRows))
{
DM_Value data;
ushort rowcount;
ushort rowheader;
ushort count;
DM_Value first, last;
ushort i;
DM_GetValue(table, AT_rowcount, 0, &data, 0);
rowcount = data.value.integer;
DM_GetValue(table, AT_colcount, 0, &data, 0);
colcount = data.value.integer;
DM_GetValue(table, AT_rowheader, 0, &data, 0);
rowheader = data.value.integer;
count = (rowcount-rowheader) * ColCount;
content=(DM_Content*)DM_Malloc(count*sizeof(DM_Content));
for (i=0; i<count; i++)
{
char buf[10];
sprintf(buf, "<%8d>", i);
content[i].string = DM_Strdup(buf);
content[i].active = FALSE;
content[i].sensitive = TRUE;
}
if (fillRows > (rowcount-rowheader))
fillRows = rowcount-rowheader;
if (fillRows)
{
first.type = DT_index;
first.value.index.first = rowheader + 1;
first.value.index.second = 1;
last.type = DT_index;
last.value.index.first = fillRows + rowheader;
first.value.index.second = ColCount;
DM_SetContent(table, &first, &last, content,
fillRows*ColCount,0);
}
}