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

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

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

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

George Shepherd, David Kruglinski

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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








A Preview of the Resource Editors


Now that you have a complete application program, it's a good time for a quick look at the resource editors. Although the application's resource script,

Ex03a.rc , is an ASCII file, modifying it with a text editor is not a good idea. That's the resource editors' job.


The Contents of Ex03a.rc


The resource file determines much of the Ex03a application's "look and feel." The file

Ex03a.rc contains (or points to) the Windows resources listed in Table 3-2.




































Table 3-2: Windows Resources Contained in MFC Applications


Resource


Description


Accelerator


Includes definitions for keys that simulate menu and toolbar selections.


Dialog


Includes layout and contents of dialog boxes. Ex03a has only the About dialog box.


Icon


Represents icons (16-by-16-pixel and 32-by-32-pixel versions), such as the application icon you see in Windows Explorer and in the application's About dialog box. Ex03a uses the MFC logo for its application icon.


Manifest


Contains the run-time type information for the application.


Menu


Represents the application's top-level menu and associated shortcut menus.


String table


Includes strings that are not part of the C++ source code.


Toolbar


Represents the row of buttons immediately below the menu.


Version


Includes program description, version number, language, and so on.


In addition to the resources listed above,

ex03a.rc contains these statements

#include  "afxres.h"

and further in the file contains this statement

#include  "afxres.rc"

which bring in some MFC library resources common to all applications. These resources include strings, graphical buttons, and elements needed for printing and for OLE.





Note

If you're using the shared DLL version of the MFC library, the common resources are stored inside the MFC DLL.


The

Ex03a.rc file also contains this statement:

#include  "resource.h"

This statement brings in some #define constants, including IDR_MAINFRAME (which identifies the menu, icon, string list, and accelerator table), IDR_EX03ATYPE (which identifies the default document icon, which we won't use in this program), and IDD_ABOUTBOX (which identifies the About dialog box). This same

resource.h file is included indirectly by the application's source code files. If you use a resource editor to add more constants (symbols), the definitions will ultimately show up in

resource.h . Be careful if you edit this file in text mode because your changes might be removed the next time you use a resource editor.



Running the Dialog Resource Editor


The Dialog resource editor allows you to create or edit dialog box resources. To run the editor, follow these steps:



    Open the project's RC file. Choose Resource View from the View menu. If you expand each item, you'll see the following in the Resource View window:





    Examine the application's resources. Now take some time to explore the individual resources. When you select a resource by double-clicking on it, another window opens with tools appropriate for the selected resource. If you open a dialog resource, the control palette should appear. If it doesn't, click the Toolbox button on the left side of Visual Studio .NET.



    Modify the IDD_ABOUTBOX dialog box. Make some changes to the About Ex03a dialog box.

    You can change the size of the window by dragging the right and bottom borders, move the OK button, change the text, and so forth. Simply click on an element to select it, and then right-click to change its properties.



    Rebuild the project with the modified resource file. In Visual C++ .NET, choose Build from the Build menu. Notice that no actual C++ recompilation is necessary. Visual C++ .NET saves the edited resource file, and then the Resource Compiler (rc.exe) processes

    Ex03a.rc to produce a compiled version, Ex03a.res, which is fed to the linker. The linker runs quickly because it can link the project incrementally.



    Test the new version of the application. Run the Ex03a program again, and then choose About from the application's Help menu to confirm that your dialog box was changed as expected.





/ 319