CListCtrl::GetStringWidth
指定された文字列を表示できる最小の列幅を調べます。
int GetStringWidth(
LPCTSTR lpsz
) const;
パラメーター
- lpsz
幅を調べる NULL で終わる文字列のアドレス。
戻り値
lpsz が指す文字列の幅をピクセル数で返します。
解説
返される幅を計算するときは、コントロールの現在のフォントと列マージンを考慮しますが、小さなアイコンの幅は考慮しません。
使用例
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);
}
必要条件
**ヘッダー:**afxcmn.h