Solved

Change font in a CListBox!

Posted on 1999-01-26
3
577 Views
Last Modified: 2013-12-03
I have a ListBox ,with a control called m_CdList, on a PropertySheet and I would like to change the font face and size in that ListBox. I would like the code since I have tried different ways without success.
Thanx
0
Comment
Question by:Slask
3 Comments
 
LVL 12

Expert Comment

by:migel
ID: 1328330
Do you try m_CdList.SetFont()?
0
 
LVL 1

Accepted Solution

by:
jim_pettinato earned 80 total points
ID: 1328331
void CDialogWithListBox::OnInitDialog()
{
   CDialog::OnInitDialog;
   // create a font for the CList
   LOGFONT lf;
   ZeroMemory(&lf, sizeof(lf));
   lf.lfHeight = 10;    // use desired size
   lstrcpy(lf.lfFaceName, "MS Sans Serif"); // use desired name
   m_hFont = CreateFontIndirect(&lf);
   // access the control, send the WM_SETFONT message
   CListBox *list = (CListBox *)GetDlgItem(ID_LIST_BOX);
   ASSERT(list);
   list.SendMessage(WM_SETFONT, (WPARAM)m_hFont, TRUE);


Note: there are cleaner ways of doing this now but this works for the widest variety of MFC platforms/revisions.
0
 

Author Comment

by:Slask
ID: 1328332
Thank you
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 66
erros on link  checking 2 79
wordcount challenge 11 134
Work with App store 7 68
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question