Solved

Change font in a CListBox!

Posted on 1999-01-26
3
540 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
Comment Utility
Do you try m_CdList.SetFont()?
0
 
LVL 1

Accepted Solution

by:
jim_pettinato earned 80 total points
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…

743 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

16 Experts available now in Live!

Get 1:1 Help Now