Solved

Change font in a CListBox!

Posted on 1999-01-26
3
556 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now