CCharSetBtn Control

Environment: VC6 SP4, NT4 SP3

I needed a control to choose a character from a specific charset and the options to use bold and/or italic font. Therefore I derived an ownerdrawn control from CButton based on the work of Shekar Narayanan and S. D. Rajan which opens a popup dialog as a drop-down window. The Dialog itself holds a ComboBox derived font-ComboBox (which includes some code-snippets of Norm Almond) and a custom control which performs the character selection.

To use the control, do the following:

  1. Import the header files (including in the attached source code) and add the .cpp files (also attached to this article) from the section CharSetBtn.
  2. Import the resources IDB_GLYPHS (printer-images) and IDD_CHARSET_DLG (the popup-window including the CharSetCtrl).
  3. On your dialog insert a button (set style-flag ownerdraw).
  4. Add a CButton control-member-variable in the class-wizard. Change the CButton class in the dialog-header-file to CCharSetBtn and that's it.

The class CCharSetBtn has got the member-variables

  int      m_nChar;
  CString  m_strFaceName;
  BOOL     m_bItalic;
  BOOL     m_bBold;

which perform the data-exchange.

With a little modification you can also use the complete LOFGONT structure.

If you decide to use this code please do not remove copyright notices from the source and header files and give me a short e-mail.

Downloads

Download demo project - 40 Kb
Download source - 29 Kb


Comments

  • very good

    Posted by Legacy on 12/21/2001 12:00am

    Originally posted by: hhk

    i m so glad to read this article

    Reply
  • A tip for you

    Posted by Legacy on 09/26/2001 12:00am

    Originally posted by: Rui Lopes

    You don't need to declare a new windowproc. You can handle the WM_ACTIVATE message in the CCharSetDlg message-map.

    Rui Lopes
    PS: Relpy also to my email.

    Reply
  • thanx, I learned something new :-)

    Posted by Legacy on 09/20/2001 12:00am

    Originally posted by: Dieter Hammer

    the way to close a dialog, when the user clicks outside, with the >NewWndProc< is super. I used SetCapture for this, but this way is better and easier. Good idea!

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds