<!-- Add the rest of your HTML here -->
In some apps, the user may want to select how to display certain characters. For example, in text editors, it is common to have option to display whitespace (space and tab). When I had this requirement recently, I tried to use Microsoft's Character Map
to allow user to select the display characters. Unfortunately, unless you are willing to use clipboard, there is no way to seamlessly integrate Character Map into your app. So here is
, my implementation of Character Map as a convenient dialog that you can customize to meet your needs.
The XCharMap Dialog
dialog displays 256 characters in selected font. In dialog caption, the character code under the cursor is displayed in hex, octal, and decimal. Below character grid are optional UI elements, which you can remove from the display by calling
APIs. When user left-clicks (or right-clicks) a character, it is displayed in left-click/right-click box. The last character that was left-clicked may be copied to Characters to copy edit box by clicking on Select. Clicking on Copy will then transfer contents of edit box to clipboard.
To remove Characters to copy UI elements, you can call
To remove left-click/right-click UI elements, you can call
When both sets of UI elements are removed, the
XCharMap dialog will be shrunk to fit character grid. To remove character code display in dialog caption, you can call
Here is code from XCharMapTestDlg.cpp that shows how to call
CXCharMap and disable all optional UI elements:
if (dlg.DoModal() == IDOK)
How To Use
IsOpenType() into your app, you first need to add following files to your project:
Next, include the header file XCharMap.h in appropriate project files. Now you are ready to start using
implementation does not support Unicode.
Acknowledgments and references
Version 1.0 - 2003 June 4
This software is released into the public domain. You are free to use it in any way you like. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.