BrainDump
  Home arrow BrainDump arrow Page 2 - Using Controls in the Microsoft Foundation...
Iron Speed
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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 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? 
BRAINDUMP

Using Controls in the Microsoft Foundation Class Library
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-03-19

    Table of Contents:
  • Using Controls in the Microsoft Foundation Class Library
  • Common Controls
  • Image Handling
  • Image Handling continued

  • 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
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Using Controls in the Microsoft Foundation Class Library - Common Controls
    (Page 2 of 4 )

    The Common Controls offer a modern, stylish interface accompanied by some advanced utilities; because of this, they are more complex than the standard controls. Here we can include the evolution bar (the one that appears upon copying a file), the slide button (used for volume control, for example), the spinner (we'll cover this in a moment), image list, list view, tree view, status, and toolbar.

    The spinner is used to force the user to choose only from a range of values. This control has the advantage of occupying just a little space and can include a wide range of numbers. The user can modify the value in it with the power of a click on one of the arcs. The creation process starts, as with anything, by declaring a variable that will handle the controller. The class for this button is the CSpinButtonCtrl:

    CSpinButtonCtrl _spin;

    Just as with standard controls, now we create it in the OnCreate() section. The rest is the same as with standard controls, so I won't cover all that again. Additional information is required. Here we have some different styles that are specific to the spinner. Like the UDS_SETBUDDYINT, this tells the application that we want to create a box near it that contains int values.

    Because it isn't all that practical to create a couple of arrows, most of the time you would also show the current value near the arrows. For this we need to assign a standard control to the spinner (we'll use an edit control) in which the application will automatically draw the current value. For this you create a CEdit control and you assign it to the spinner. After this, you set it as a buddy with the SetBuddy function of the spinner.

    Build the application, if you want to see the results. A default range value of 100 to 0 will be assigned. For setting other, custom values use the SetRange function and for the start value, the SetPos. Look at the following code snippet and all should be clear.


    int CMFC_exampleView::OnCreate(LPCREATESTRUCT lpCreateStruct)

    {

    if (CView::OnCreate(lpCreateStruct) == -1)

    return -1;


    // TODO: Add your specialized creation code here

    // the spinner

     

    _edit3.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_READONLY,

    CRect(10, 110, 50, 130),this,IDC_SPINNER);



     

    _spin.Create(WS_CHILD | WS_VISIBLE | WS_BORDER |

    UDS_SETBUDDYINT | UDS_ALIGNRIGHT ,

    CRect(10, 110, 50, 130),this,IDC_SPINNER);


    _spin.SetBuddy( &_edit3);

    _spin.SetRange(1, 10);

    _spin.SetPos( 8);


    return 0;

    }


    Again, you can locate the full code and the application in the attached zip file, located in the final section of this article. This is one of the simpler controls. For  more in-depth information turn to a book or an online step-by-step tutorial, because we are moving to the final part of this article, covering image handling.

    More BrainDump Articles
    More By Gabor Bernat


       · Wellcome my friend and thanks for reading my article. As previously mentioned I...
     

    BRAINDUMP ARTICLES

    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC
    - VBScript: More Fun with the Date Functions
    - Vista Price Cuts Dissected




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway