There are instances when you might want to determine the width of a column
in the Details view. A function has been added to the container control
to allow you to determine the width of the data in a column. You can then
compute the width of the entire column by adding the width of the data to
the left and right margins of the column. To determine the width of a column:
- Define an attribute with a value of 0x0200 and
give it a name such as CMA_DATAWIDTH.
- Issue the CM_QUERYDETAILFIELDINFO message with
the following values:
a.
Provide a pointer to the FIELDINFO data structure
in param1.
b.
Specify
your attribute (see step 1) in param2.
c.
Request
a return value with a type of LONG, not PFIELDINFO, to retrieve the width
of the column in the FIELDINFO data structure to which you are pointing.
The value returned is the width of the data (text, icon, or bit map) in
this column.
3.
Use
GpiQueryFontMetrics to query the average character width of the font used
by the container. This value will be used to calculate the total column
width.
4.
Multiply 3 by the
average character width and add this to the data width returned from step
2 for all columns except the following:
- The first and last columns in each split window.
In these cases, multiply 2.5 by the average character width and add the
column data width returned from step 2.
- The only other special case is where there is only
1 column in either the left or right split windows. In this case, you would
multiply 2 by the average character width and add the column data width
returned from step 2.
5.
The
value returned is the total width of the column.
[Back]
[Next]