Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use diffent fonts in CListCtrl but in dialog I see only the last font..

<pre>int					dim, nWidth;
	DWORD				dwStyles;
	RECT				rList;
	CString				strCol;

	CFont *Font = new CFont;

	Font->CreateFont(30,                            // Height
		0,                             // Width
		0,                             // Escapement
		0,                             // Orientation
		FW_THIN,                       // Weight
		FALSE,                         // Italic
		FALSE,                          // Underline
		0,                             // StrikeOut
		ANSI_CHARSET,                  // CharSet
		OUT_DEFAULT_PRECIS,            // OutPrecision
		CLIP_DEFAULT_PRECIS,           // ClipPrecision
		DEFAULT_QUALITY,               // Quality
		DEFAULT_PITCH | FF_SWISS,      // PitchAndFamily
		_T("Calibri"));                     // Facename



	CListBut *pLst = (CListBut *)GetDlgItem(IDC_LIST1);
	pLst->GetWindowRect(&rList);
	dim = rList.right - rList.left;



	strCol = _T("tttt");
	nWidth = (int)(dim * 0.3);
	pLst->InsertColumn(0, strCol, LVCFMT_RIGHT, nWidth, -1);

	strCol = _T("");
	nWidth = (int)(dim * 0.3);
	pLst->InsertColumn(1, strCol, LVCFMT_RIGHT, nWidth, -1);

	strCol = _T("");
	nWidth = (int)(dim * 0.3);
	pLst->InsertColumn(2, strCol, LVCFMT_RIGHT, nWidth, -1);

	
	LOGFONT lf;
	memset(&lf, 0, sizeof(LOGFONT));
	lf.lfHeight = 100;
	lf.lfWeight = 600;

	LOGFONT							sLogFont;
	BOOL							bCreated;
	CFont                           font;

	//font.CreatePointFont(100, _T("Arial"));

	CFont *Font1 = new CFont;

	// *Font = new CFont;

	Font1->CreateFont(100,                            // Height
		0,                             // Width
		0,                             // Escapement
		0,                             // Orientation
		FW_THIN,                       // Weight
		FALSE,                         // Italic
		FALSE,                          // Underline
		0,                             // StrikeOut
		ANSI_CHARSET,                  // CharSet
		OUT_DEFAULT_PRECIS,            // OutPrecision
		CLIP_DEFAULT_PRECIS,           // ClipPrecision
		DEFAULT_QUALITY,               // Quality
		DEFAULT_PITCH | FF_SWISS,      // PitchAndFamily
		_T("Calibri"));                     // Facename


	pLst->SetFont(Font1);

	int nTagli = 0;
	pLst->InsertItem(nTagli, _T("ciao"), -1);//data

	pLst->SetItemText(nTagli, 1, _T("ciao"));//tempo iniziale

	pLst->SetItemText(nTagli, 2, _T("ciao"));//tempo finale







What I have tried:

I tried to use the code that I wrote
Posted
Updated 17-Jul-22 21:19pm

1 solution

When you want to use different fonts, you should do some owner drawing. It is very basic, so you must fizzle out all the details.

Read the oldie but goldie article about Custom draw in List Controls to understand want you should do.
 
Share this answer
 
Comments
CPallini 18-Jul-22 3:34am    
5.
Member 14594285 18-Jul-22 3:56am    
to simplify Can I remove directly the row with title?
jeron1 19-Jul-22 10:57am    
Does 'row with title' mean column headers?
KarstenK 18-Jul-22 10:44am    
You must inserted all elements but the output is in the owner drawing. Best is to use some data model for getting the correct informations what to draw in the elements.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900