Programming with Microsoft Visual C++.NET 6ed [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Programming with Microsoft Visual C++.NET 6ed [Electronic resources] - نسخه متنی

George Shepherd, David Kruglinski

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید








Ex03a: The "Do-Nothing" Application


The MFC Application Wizard generates the code for a functioning MFC library application. This working application simply brings up an empty window with a menu attached. Later, you add code that draws inside the window. You take the following steps to build an application:



    Run the MFC Application Wizard to generate SDI application source code. Choose New Project from Visual C++'s File menu. Select Visual C++ Projects, and then select MFC Application from the list of templates, as shown here.


    Type C:\vcppnet\ in the Location box. Type Ex03a in the Name box, and then click OK. Use the links on the left side of the dialog box to move through the various Application Wizard pages to set up project options.

    On the Application Type page, select the Single Document option and accept the defaults for the rest of the application, as shown here:


    On the Generated Classes page, shown below, notice that the class names and source-file names have been generated based on the project name Ex03a. You can make changes to these names at this point if you want to. Click Finish. The wizard will create your application's subdirectory (Ex03a under \vcppnet) and a series of files in that subdirectory. When the wizard is finished, look in the application's subdirectory.


    Table 3-1 lists the files that are of interest (for now).

































    Table 3-1: Important Files in the Application's Subdirectory


    File


    Description


    Ex03a.vcproj


    A project file that allows Visual C++ .NET to build your application


    Ex03a.sln


    A solution file that contains a single entry for

    ex03a.vcproj


    Ex03a.rc


    An ASCII resource script file


    Ex03aView.cpp


    A view class implementation file that contains CEx03aView class member functions


    Ex03aView.h


    A view class header file that contains the CEx03aView class declaration


    ReadMe.txt


    A text file that explains the purpose of the generated files


    resource.h


    A header file that contains #define constant definitions


    Open the

    ex03aView.cpp and

    ex03aView.h files and look at the source code. Together, these files define the CEx03aView class, which is central to the application. An object of class CEx03aView corresponds to the application's view window, where all the "action" takes place.



    Compile and link the generated code. In addition to generating code, the MFC Application Wizard creates custom project and workspace files for your application. The project file,

    ex03a.vcproj , specifies all the file dependencies along with the compile and link option flags. Because the new project becomes Visual C++ .NET's current project, you can now build the application by choosing Build from the Build menu or by clicking the Build toolbar button, shown here:

    If the build is successful, an executable program named Ex03a.exe will be created in a new Debug subdirectory underneath \vcppnet\Ex03a. The OBJ files and other intermediate files are also stored in Debug. Compare the file structure on disk with the structure in Solution Explorer, shown on the next page.


    Solution Explorer contains a logical view of your project. The header files show up under Header Files, even though they are in the same subdirectory as the CPP files. The resource files are stored in the \res subdirectory.



    Test the resulting application. Choose Start Without Debugging from the Debug menu. Experiment with the program. It doesn't do much, does it? (What do you expect with no coding?) Actually, as you might guess, the program has a lot of features—you simply haven't activated them yet. Close the program window when you've finished experimenting.



    Browse the application. Press CTRL+ALT+J to bring up the Object Browser. If your project settings don't specify browser database creation, Visual C++ .NET will offer to change the settings and recompile the program for you. (To change the settings yourself, choose Properties from the Project menu. Open the C/C++ folder, click on the Browse Information property page, and change the Enable Browse Information property to Include All Browse Information (/ FR).)

    After you expand the hierarchy, you should see output similar to this:






    Compare the browser output to Class View:




    Class View shows the class hierarchy, much like the Object Browser does. But the Object Browser shows all the functions available on a class, and Class View shows only those that have been overridden. If Class View is sufficient for you, don't bother building the browser database.




/ 319