sunpochin
sunpochin

Reputation: 338

How to show Emoji such as ☔ and 😢 in a Microsoft MFC CListCtrl?

I'm developing a desktop application with MFC CListctrl, build with Unicode.

The listctrl can correctly show !@#$%︿&*() , but not Emojis ☔ and 😢.

It's a "virtual listctrl" and the lvItem.pszText seems correctly holding in memory the UNICODE "26 14" for ☔, but not showing correctly.

I'm using Visual Studio 2012 on Windows 7. Any thoughts would be appreciated. Thanks!

[EDITED 20140929]

Thanks Werner Henze, I have found out that "Segoe UI Symbol" can show emoji correctly in Windows 7 http://www.istartedsomething.com/20120818/microsoft-backports-windows-8-emoji-for-segoe-ui-symbol-to-windows-7/

Microsoft KB2729094 titled “An update for the Segoe UI symbol font in Windows 7 and in Windows Server 2008 R2 is available” is presumed to be made available through Windows Update soon.

However "Segoe UI Symbol" seems to failed on Korean characters(which is correctly shown with "Segoe UI").

Upvotes: 2

Views: 2039

Answers (2)

sunpochin
sunpochin

Reputation: 338

Thanks Werner Henze, I have found out that "Segoe UI Symbol" can show emoji correctly in Windows 7 http://www.istartedsomething.com/20120818/microsoft-backports-windows-8-emoji-for-segoe-ui-symbol-to-windows-7/

Microsoft KB2729094 titled “An update for the Segoe UI symbol font in Windows 7 and in Windows Server 2008 R2 is available” is presumed to be made available through Windows Update soon.

However "Segoe UI Symbol" seems to failed on Korean characters(which is correctly shown with "Segoe UI").

Upvotes: 0

Werner Henze
Werner Henze

Reputation: 16726

There are a few things to keep in mind.

First your program should use RegisterWindowW and not RegisterWindowA so your window is instantiated as a Unicode window. This is done automatically for the MFC provided main window classes if you are compiling for Unicode.

Second you must choose a font that is capable of displaying the required characters. You can check which font is in use and maybe change it with this code snippet (in my code taken from OnCreate):

CFont * pFont = m_listctrl.GetFont();
ASSERT((HFONT)m_fontListLog == nullptr);
LOGFONT logfont;
VERIFY(pFont->GetLogFont(&logfont));
_tcscpy(logfont.lfFaceName, _T("my desired font"));
VERIFY(m_font.CreateFontIndirect(&logfont));
m_listctrl.SetFont(&m_font);

You can check which font supports which characters with charmap.exe.

I tested successfully with font "Segoe UI" and character 0x214e, but could not output your 0x2614 because the font does not support it.

Upvotes: 1

Related Questions