Print Page | Close Window

How To Set Font int CXTListCtrl

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2592
Printed Date: 08 November 2025 at 7:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How To Set Font int CXTListCtrl
Posted By: njyjm
Subject: How To Set Font int CXTListCtrl
Date Posted: 18 July 2005 at 10:29pm

   Like Vc6.0, We want to output some messages in OutputPane, it works well, but how to set the font of the ListCtrl, the following set Font segment in OnCreate(...) did not work. Please give us some help !

// CompileOutputPane.h
class CCompileOutputPane : public CWnd
{

...

public:
 CDockPaneWnd<CXTListCtrl> m_lcCompileOutput;

...

}


// CompileOutputPane.cpp
int CCompileOutputPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...

  LOGFONT logFont;
  CFont   *pFont;
 
  CXTListCtrl *pListCtrl = &m_lcCompileOutput;
  pListCtrl->GetFont()->GetLogFont(&logFont);
  _tcscpy(logFont.lfFaceName, _T("Verdana"));  pFont = new CFont;
  pFont->CreateFontIndirect(&logFont);
  pListCtrl->SetFont(pFont);

...
}

void CCompileOutputPane::AppendCompileInfoLine(CString strInfo, DWORD dwItemData)
{
 CXTListCtrl *pListCtrl = &m_lcCompileOutput;
 int nCount = pListCtrl->GetItemCount();
 int nIndex = pListCtrl->InsertItem(nCount, strInfo, GetImageIndex(dwItemData));
 pListCtrl->SetItemData(nIndex, dwItemData);

 //Set Line Color

 if (dwItemData)
 {
  const COLORREF COMPILE_ERROR_TEXT_COLOR   = RGB(255, 0, 0); 
  const COLORREF COMPILE_ERROR_BACKGROUND_COLOR = pListCtrl->GetListBackColor();//RGB(198, 198, 198); 
  pListCtrl->SetRowColor(nIndex,
   COMPILE_ERROR_TEXT_COLOR,
   COMPILE_ERROR_BACKGROUND_COLOR);
 }

 pListCtrl->SendMessage(WM_VSCROLL, SB_BOTTOM);

}




Replies:
Posted By: Oleg
Date Posted: 19 July 2005 at 7:49am

add

pListCtrl->SetAutoFont(FALSE);

 

before set font.



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jlee
Date Posted: 23 August 2005 at 11:39am

Hi Oleg,

I was trying to do a similar thing to set the font for the header using the 'SetFont' function, but it didn't seem to work. Could you please give me some help here? My code is something like this:

m_userList.GetFont()->GetLogFont(&logFont);

logFont.lfHeight = -15;

pFont = new CFont;

pFont->CreateFontIndirect(&logFont);

HWND hWndHeader = m_userList.GetDlgItem(0)->GetSafeHwnd();

m_header.SubclassWindow(hWndHeader);

m_header.SetFont(pFont);

// enable auto sizing.

m_header.EnableAutoSize(TRUE);

m_header.ResizeColumnsToFit();

m_header.SetTheme(new CXTHeaderThemeOffice2003());

...

 

Thanks alot,

JLee




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net