Click here to Skip to main content
Click here to Skip to main content
Go to top

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

Introduction

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).

Background

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.

    Change:

        CButton m_button1;

    to:

        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
    m_button1.SetFont("Tahoma",30);

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.

History

  • Version 1.0: 25/09/2005

License

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

Share

About the Author

gizmocuz
Web Developer
Netherlands Netherlands
No Biography provided

Comments and Discussions

 
Questionusp10.lib ? PinmemberArtiGujare5-Apr-06 5:04 
GeneralMSLU PinsussAnonymous2-Oct-05 11:55 

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 30 Sep 2005
Article Copyright 2005 by gizmocuz
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid