BrainDump
  Home arrow BrainDump arrow Page 2 - Using Controls in the Microsoft Foundation...
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? 
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
     
     
    ADVERTISEMENT


    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

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT