Solved

A couple CListCtrl questions

Posted on 2000-04-15
5
401 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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