Text Extent in CListCtrl (AUTOSIZE)
-
Hello, I'm trying to change my CListCtrl text for each line. With the following code, I've been able to do it successfully. However, when it comes time to AUTOSIZE (GetListCtrl().SetColumnWidth(col, LVSCW_AUTOSIZE_USEHEADER)), it seems to use the system default font to determine how wide to make each column. So to get the widths right, do I have to bite-the-bullet and calculate it all myself? Or is there a way to tell CListCtrl what type of text is in the columns? Thanks! JennyP ...else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage ) { .... CFont newFont; newFont.CreateFont(15,0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, "Arial"); CDC* pListDC; pListDC = pListDC->FromHandle(pLVCD->nmcd.hdc); pListDC->SelectObject(&newFont); newFont.Detach(); newFont.DeleteObject(); pListDC->SaveDC();