?
Solved

A couple CListCtrl questions

Posted on 2000-04-15
5
Medium Priority
?
418 Views
Last Modified: 2013-11-20
1. How can I change the font in a list control?  I try creating a font and using CWnd::SetFont(), but this doesn't seem to work right...
2. How can I change the highlight color?

0
Comment
Question by:Mournblade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Accepted Solution

by:
MT_MU earned 150 total points
ID: 2719896
CFont* pFont = m_List.GetFont(); // get the current font
LOGFONT logfont;
pFont->GetLogFont(&logfont);  // and it's characteristics - for me this returns lfHeight = -11;

logfont.lfHeight = -14;  // set a new height

m_NewFont = new CFont;  // create a new font
m_NewFont->CreateFontIndirect(&logfont); // with the appro characteristics
m_List.SetFont(m_NewFont); // and tell the list control to use it

0
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 2720308
I hope you do not think that I used CWnd::SetFont() without supplying a font.  Both this and CreateFont() do not work. Thanks, anyway.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2720802
> Both this and CreateFont() do not work.

ACtually, CreateFont() and SetFont() work fine, if you use them right. Odds are, you're doing something wrong. The most common mistake is destroying the CFont object (and the font, with it!) after telling the list control to use that font.

If you show us your code, we should be able to tell you exactly what you've done wrong.

..B ekiM
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 2721284
yeup .. best to make the font a member of your dialog or list-control class (depending on whether the dialog is trying to tell a list control what to do, or you've subclassed the list control and it is telling itself what to do).

As for the highlight colour ... go to http://www.codeguru.com and look at the list control articles there.  You'll see also sorts of CListCtrl-based examples that do all sorts of things to list control.  Really useful stuff.
0
 

Author Comment

by:Mournblade
ID: 2721384
Thanks for the suggestion on scope; makes perfect sense, but missed it anyway.  I had already looked through the list view articles in Codeguru, and didn't see these answers.  However, upon looking again I did find something about highlighting...

Anyhow, I suppose I will give the points to MT_MU since he did actually include the "m_" prefix in his variables, suggesting member vars.  Thanks.

By the way, sorry about the second name.  I sometimes accidentally get on here under my roommate's account.  hehe.
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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

719 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