Click here to Skip to main content
13,090,678 members (45,362 online)
Click here to Skip to main content
Add your own
alternative version


37 bookmarked
Posted 30 Sep 2005

Unicode Owner Draw Button Control

, 30 Sep 2005
Rate this:
Please Sign up or sign in to vote.
Shows you how to display Unicode strings in an owner draw button control.

Sample Image


When I was writing an application for an Arabic customer in C++, I noticed that the buttons/labels in my CDialog did not understand my Arabic text. This class allows you to write any Unicode text in the button control. (And you can use it as a direction for making the same for a static label, for instance).


This article started as a simple project to display Arabic text from a MySQL database / file on images/dialogs. I noticed that when you write Unicode characters into the developer environment directly, you need to convert it to Unicode first. That's is why I make use of the function MultiByteToWideChar in the sample application.

Using the code

The implementation of the CUniButton is done in the following steps:

  1. Add a button to your dialog and set the Owner-Draw property to True.
  2. Add a member variable for your button and change CButton to CUniButton.


    CButton m_button1;


    CUniButton m_button1;
  3. Add the UniButton header file into your Dialog header:
    #include "unibutton.h"

To change text/font/reading order, use the following:

m_button1.SetText(L"Unicode text goes here");
m_button1.SetRTL(0);//no right to left

For Arabic, set the RTL to True:

Add the Usp10.lib library to your project dependencies.

The following functions are implemented:

  • void SetHilightColors (COLORREF hilight,COLORREF hilightText);
  • void SetNormalColors (COLORREF clrBkgnd,COLORREF clrText);
  • void SetText(WCHAR *szText);
  • void SetRTL(int bRTL);
  • void SetDefaultSSAFlags(DWORD dwFlags);
  • void SetFont(char *szFaceName, int height);
  • void SetHorizontalAlignment(_AlignHorz hAlign);
  • void SetVerticalAlignment(_AlignVert vAlign);

Points of Interest

I'm just starting to learn how to use Unicode characters in projects. It is possible that I forgot to implement some important features. If so, you probably want to modify the functions: PlotTXTUnicode and/or CalcTXTUnicode.


  • Version 1.0: 25/09/2005


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
Netherlands Netherlands
No Biography provided

You may also be interested in...


Comments and Discussions

Questionusp10.lib ? Pin
ArtiGujare5-Apr-06 5:04
memberArtiGujare5-Apr-06 5:04 
GeneralMSLU Pin
Anonymous2-Oct-05 11:55
sussAnonymous2-Oct-05 11:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 30 Sep 2005
Article Copyright 2005 by gizmocuz
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid