.NET
  Home arrow .NET arrow Font, Shell and Masked Edit Controls for M...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Font, Shell and Masked Edit Controls for MFC
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-10-22

    Table of Contents:
  • Font, Shell and Masked Edit Controls for MFC
  • Shell controls
  • Masked Edit
  • Edit browse controls
  • CVSListBox

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Font, Shell and Masked Edit Controls for MFC


    (Page 1 of 5 )

    Great communication is a de facto standard for anything aiming for success nowadays. We can talk about a business meeting or an application; this is equally important. Every application first must establish reliable and effortless communication with the user, and afterward with the operating system itself. With the introduction of common controls, doing this got a lot more straightforward.

    Now you can use these already-optimized controls to resolve the communication between the user and the operating system directly. This assures a consistent working environment for the user across multiple programs and fast application creation for the programmer. All that remains unrevealed is how to pull this off.

    While the MSDN contains a lot of information, it is far from perfect. Most of the time you will have the feeling that you are flooded with a massive amount of information while you just want to know what a tool can do and how you can use it. In this article, I will try to fill this gap. 

    I will use the MSDN example application, which is quite good. If you want to see it for yourself, you can download it from here. The controls I am going to explain are the ones introduced, or at least improved upon, with the launch of the MFC Feature Pack. Therefore, you will need to install this. If you have service pack one for Visual Studio 2008, you already have it. So let's get started.

    The font tool allows the user to pick a font from a list. To illustrate the fonts and present as much as possible in a space as small as possible, it uses a combo box. In one of my earlier articles entitled New Controls for MFC, I presented how to create property sheets inside a dialog and use these to add controls. We will use the same approach now. If you are not familiar with this topic, feel free to read that article first.

    As the image above already shows, we have four main options we can set in the case of this control. First, at the creation process, because a font combo box in its essence remains a combo box (with custom initial items), you can add a combo box inside the resource editor, and afterward add it as a class of the dialog. Afterward, change the CComboBox to CMFCFontComboBox.

    Now the fonts can be of three types: true type, raster or device fonts. Raster fonts are in fact bitmap fonts. Bitmap fonts are simply collections of raster images of glyphs. Therefore, for every character it displays (small, large, italic, bold, and etcetera), there must be another image of it.

    True type is an outline font standard developed in the 1980 by Apple. Device, or hardware, fonts are fonts that are provided directly by your system's hardware or by software other than IDL (interface description language). Most of these have a different image icon in front of them: true type fonts get a TT letter, raster fonts get something that resembles a page with writing on it, and the device fonts get no icon.

     

    Item

    Effect

    GetSelFont

    Returns a CMFCFontInfo pointer about the currently-selected font.

    SelectFont

    Select the specified font inside the combo box. You can specify the name of the font with the character set or with a CMFCFontInfo pointer.

    Setup

    Initializes the combo box with the corresponding items. The first parameter is an int that contains bitwise or which of the three font types to show; the second is a byte of the character set; the third is a byte that tells the font's pitch and family. Every one of these are optional parameters and have defaults.

    m_bDrawUsingFont

    Draws inside the combo box using the specific font.

     

     

    In practice, it all looks like this:

    CMFCFontComboBox m_wndFont;

    m_wndFont.SelectFont (_T ("Arial"));

    int nFontType = 0;

     

    if (m_bTrueType)

    {

    nFontType |= TRUETYPE_FONTTYPE;

    }

     

    if (m_bRaster)

    {

    nFontType |= RASTER_FONTTYPE;

    }

     

    if (m_bDeviceFont)

    {

    nFontType |= DEVICE_FONTTYPE;

    }

     

    CWaitCursor wait;

    m_wndFont.Setup (nFontType);

    CMFCFontComboBox::m_bDrawUsingFont = m_bDrawUsingFont;

    With this effect:

    More .NET Articles
    More By Gabor Bernat


     

    .NET ARTICLES

    - Introducing .NET
    - Building Business Objects for an Application
    - Methods for an Application`s Business Logic ...
    - Properties of an Application`s Business Logi...
    - Classes and Properties in an Application`s B...
    - Organizing Code for the Business Logic Layer...
    - Building the Business Logic Layer
    - Completing a Business Layer with Windows Wor...
    - Building Applications with Windows Workflow ...
    - Building the Data and Business Layers Using ...
    - The Transformed XML Explorer in MFC
    - List Control and Property Grid with the MFC ...
    - Font, Shell and Masked Edit Controls for MFC
    - Color, Link and Image Editor Controls for M...
    - New Controls for MFC





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek