Solved

A couple CListCtrl questions

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to determine file rename from EventLog ? 2 49
string initialization in java 11 114
maven archtype selection in eclipse 1 57
wordmultiple challenge 12 136
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 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