PDA

View Full Version : SECTreeCtrl - Change font for 1 column only



OldForumPost
03-24-2008, 02:00 PM
Basically, I'm trying to have a checkbox column, and it seems to me the easiest way would be to display some wingdings characters.

I tried to overload the method ** void CTreeListCtrl::PickTextFont(LvPaintContext* pPC) ** to change the pPC->pFont object with a wingdings font, but it causes a crash. I also tried overloading ** void CTreeListCtrl::DrawSubItem(LvPaintContext* pPC) ** method, and I got the same crash.

I also tried to call SetLabelFont(CFont* newfont) to change the Font before calling the CTreeListCtrl::DrawSubItem and then calling SetLabelFont(CFont* newfont) to restore the old Font, with no result.

So my question is: How can I change the Font for only 1 column and leave the other columns untouched.

Thanks

Terry
03-24-2008, 02:22 PM
Most problems with PickTextFont() and LvPaintContext are related to Platform Targeting. Here's the discussion of Platform Targeting from the Objective Toolkit Readme file:



Platform Targeting

Objective Toolkit 8.03 uses certain functions and structures that depend on a particular version of Windows. These functions and structures are declared using conditional code. To compile the library for a particular platform, the appropriate macros should be defined. Otherwise, applications may crash if they are built with a Toolkit library compiled for another platform. ... (The macros are defined in the Src\Toolkit\StdAfx.h file. The default targeting is for Windows 2000 with the Internet Explorer 6.0)

Specifically, what happens is that the Objective Toolkit libraries are built for the Windows 2000 platform, while your application will default to the platform on which it is built. This is controlled by the WINVER macro, which in ...src\toolkit\stdafx.h is defined as 0x0500, but it is typically not defined in your application, so when you build your application on WinXP, WINVER is defaulted to 0x0501. If you examine the build output, you may find a message to this effect. The result is the mismatched structures mentioned in the Readme file.

The solution to this is to be certain that both the Toolkit and your application are built with the same targeting by setting WINVER either in the project settings or in your application's stdafx.h. Some people will create separate builds targeted for different platforms and let their installer handle the distinction, but it is generally satisfactory to set WINVER to match the oldest platform on which you expect your application to run. That is, you can set WINVER to 0x0500 and your application should still run properly on any platform since Win2K, but if you set it to 0x0501, it may not run properly on any platform prior to WinXP.