BrainDump
  Home arrow BrainDump arrow Page 4 - Introduction to MFC
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

Introduction to MFC
By: Gabor Bernat
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2008-02-27

    Table of Contents:
  • Introduction to MFC
  • Windows and Event Handling
  • The First MFC Program and the Basics
  • Explaining the File Names and Extending the Application
  • Conclusion

  • 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


    Introduction to MFC - Explaining the File Names and Extending the Application


    (Page 4 of 5 )

    MFC_example.h – The main header file for the application; here the About dialog class is also defined.

    MFC_example.cpp – The implementation file of the application. This class manages the New, Open, and Print Setup among the About dialog.

    MainFrm.h – Yes, this exists under this name regardless of the name of the application. This defines the functions that will create the main window.

    MainFrm.cpp – As you can predict, here we implement the upper header functions. This is the place where the main window is created, then the Status Bar, and the Toolbar or the splitter view, if that’s the case.

    MFC_exampleDoc.h – Header file for opening, saving, and loading files.

    MFC_exampleDoc.cpp - The implementation of the upper file. Here we manage the serialization process.

    MFC_exampleView.h – This represents the header file for the window shown. An invisible territory (window) is positioned by MFC in the client area of the frame.

    MFC_exampleView.cpp – This is the place where we manage the client area. If something needs to be updated, this class will be called. For example, if the client modifies something and the output date has to be updated, then these classes’ OnDraw function will be called. The Print command and the Print preview content is also placed in the default settings.

    Stdafx.h – Include file for frequently used headers that aren’t changed often.

    Stdafx.cpp – When we create a header we need to implement it, and this helps. 

    Resource.h – Here the resources are defined.

    MFC_example.rc – The resource file containing the resources. For a start, it contains the status bar, toolbar, menu, about dialog box, and the icons of the application. For additional information on this subject I advise you to check out the third part of this series (as soon as it goes live, that is).

    Now we will extend our application with some individual touches, so it’s the perfect time to demonstrate the way we can manage this. It’s all about modifying the parameters to which the window creation is called. For this we will venture into the Mainframe.cpp. Once in there, search for the following code snippet:


    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)

    {

    if( !CMDIFrameWnd::PreCreateWindow(cs) )

    return FALSE;

    // TODO: Modify the Window class or styles here by //modifying

    // the CREATESTRUCT cs


    return TRUE;

    }


    Now you must know that the cs structure holds many parameters that will be transmitted forward when the window is created for the first time. It is safe to say that at the creation process when the message is sent, it’s time to create the window. This function will be called and a result will be returned carrying all the information that is required. So let’s alter the initial cs settings. After the comments add the following:


    cs.cx = 720; // width of the new window

    cs.cy = 780; // height of the new window

    cs.x = 100; // initial position of the window, on the x axis

    cs.y = 200; // on the y axis


    Save the file and run the solution. Congratulations, we are damn good; you can already see the results happening in front of your eyes!

    More BrainDump Articles
    More By Gabor Bernat


       · MFC is the article stated the tool of the lazy programmer who don't want to write a...
     

    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 2 Hosted by Hostway
    Stay green...Green IT