Compartir a través de


CListCtrl::GetStringWidth

Determina el ancho de columna mínimo necesario mostrar toda la cadena especificada.

int GetStringWidth( 
   LPCTSTR lpsz  
) const;

Parámetros

  • lpsz
    Dirección de una cadena terminada en null cuyo ancho debe determinarse.

Valor devuelto

El ancho, en píxeles, de la cadena al que lpsz.

Comentarios

El ancho devuelto tiene en cuenta los márgenes actuales de la fuente y columna del control, pero no el ancho de un pequeño icono.

Ejemplo

       CString strColumn;
        int nWidth;

        // Insert six columns in the list view control. Make the width of 
        // the column be the width of the column header plus 50%. 
        for (int i = 0; i < 6; i++)
        {
            strColumn.Format(_T("column %d"), i);
            nWidth = 3*m_myListCtrl.GetStringWidth(strColumn)/2;
            m_myListCtrl.InsertColumn(i, strColumn, LVCFMT_LEFT, nWidth);
        }

Requisitos

encabezado: afxcmn.h

Vea también

Referencia

CListCtrl Class

Gráfico de jerarquías

CListCtrl::GetColumnWidth