Solved

A couple CListCtrl questions

Posted on 2000-04-15
5
384 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
5 Comments
 
LVL 1

Accepted Solution

by:
MT_MU earned 50 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:Slimfinger
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

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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