Solved

A couple CListCtrl questions

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 87
How to know only "File created" with EventLog 3 29
if loop in java 3 114
canBalance challenge 34 65
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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 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

15 Experts available now in Live!

Get 1:1 Help Now