iamsreesn
iamsreesn

Reputation: 21

CListCtrl is showing different theme for Unicode and Multi byte character set

List Control theme is showing different theme while changing the character set: Unicode vs Multi Byte

Code Snippet,

private:
CListCtrl m_list;

m_list.SetExtendedStyle(LVS_EX_GRIDLINES);
// TODO: Add extra initialization here

// Ask Mfc to create/insert a column
m_list.InsertColumn(
    0,              // Rank/order of item
    L"Name",         // Caption for this header
    LVCFMT_LEFT,    // Relative position of items under header
    100);          // Width of items under header

m_list.InsertColumn(1, L"Profession", LVCFMT_CENTER, 80);
m_list.InsertColumn(2, L"Fav. Sport", LVCFMT_LEFT, 100);
m_list.InsertColumn(3, L"Hobby", LVCFMT_LEFT, 80);

int nItem;

nItem = m_list.InsertItem(0, L"Sandra C. Anschwitz");
m_list.SetItemText(nItem, 1, L"Singer");
m_list.SetItemText(nItem, 2, L"HandBall");
m_list.SetItemText(nItem, 3, L"Beach");

nItem = m_list.InsertItem(0, L"Roger A. Miller");
m_list.SetItemText(nItem, 1, L"FootBaller");
m_list.SetItemText(nItem, 2, L"Tennis");
m_list.SetItemText(nItem, 3, L"Teaching");

How to get the Unicode theme in Multi Byte character set?

Upvotes: 0

Views: 431

Answers (1)

Joseph Willcoxson
Joseph Willcoxson

Reputation: 6050

If you generated this project using an app wizard in Visual C++, you probably have these lines in your stdafx.h file:

#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif

This is the reason you are themed differently. There are technical reasons to not use Common Controls 6 in your MBCS application. However, if you can build for UNICODE successfully, just do that. Any supported Windows OS is UNICODE capable and that is what you should be using anyways. Just say NO to MBCS.

Upvotes: 3

Related Questions