Solved

Change font in a CListBox!

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
Can someone Identify This font 4 88
Problem to event 3 94
Problem to open Excel file 15 130
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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…

774 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