News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Programming In VC++ - Developer Studio - Part II

Started by sivaji, Jan 10, 2008, 05:41 PM

Previous topic - Next topic

sivaji

Programming Stuffs in "VC++" - Technical Skills for INTERVIEW

Resources

The integrated resource editor in Developer Studio provides a comprehensive editing facility for all types of resources. This includes the new toolbar editing facility, as well as the capability to insert and edit custom resources.

Resource Editing

ResourceView

Resource editing begins with the ResourceView in the Project Workspace window . This window provides a view of all the elements in a project's resource file.

Inserting a new resource

You can insert a new resource by selecting the Resource command from the Insert menu. This command displays a dialog where you can select the type of the new resource. In addition to predefined types, user-defined types also appear in this dialog. You can use this dialog to insert a blank resource; however, when inserting a cursor or a dialog, you can also use a predefined template as the basis for your new resource.

Editing an accelerator table

Accelerators are keyboard shortcuts that generate WM_COMMAND messages; the same type of messages as those generated by menu commands and dialog controls. A project can have several accelerator tables; for example, if it uses multiple menus, it may use different accelerator tables for those. To edit a specific accelerator key, double-click the key in this window to invoke its properties.

Editing a bitmap

The bitmap editor enables you to create monochrome or color bitmaps. A variety of graphics tools can be used when drawing the bitmap. Use the mouse to select the desired tool and the foreground and background colors, and then draw the bitmap.

While a bitmap is displayed on screen, a new menu, the Image menu, becomes available in the Developer Studio menu bar. Commands in this menu can be used to manipulate the bitmap; in particular, the Grid Settings command can be used to set up a grid of guide lines. Use this grid when creating a bitmap that consists of many small pictures.

Editing a cursor

Editing a cursor is very similar to editing a bitmap. However, for cursors, the color palette also contains two special "colors"; one that corresponds to the background color, and another that corresponds to the inverse background color.

You can also specify a cursor's hotspot. The hotspot is the position in the cursor image that Windows uses to track the cursor and to generate cursor-related events.

Editing a dialog

The dialog editor is the tool for editing dialog templates. Editing a dialog template consists of selecting controls from the control palette and placing them on the template, and specifying dialog and control properties.

The dialog control palette supports all standard controls as well as most Windows 95 Common Controls. It also provides a tool for placing OLE controls in your dialog.

Guide settings for dialog editing

While a dialog is being edited, a new menu, the Layout menu, is displayed by the Developer Studio. This menu offers several commands that help to adjust the placement of controls in a dialog template. Among these is the Guide Settings command. This command invokes a dialog where you can specify rulers, guides, and grid settings to assist you during dialog template editing.

Icon editing

Editing an icon is very similar to editing a cursor. The only notable difference is the lack of a hotspot in icons. When creating an icon, you may wish to create several versions of the icon. For example, compatibility with Windows 95 requires that your application register a 16x16 icon in addition to the standard, 32x32 icon.

Menu editing

Editing menus is easy and straightforward using the graphical menu editor . To insert a new item in either a horizontal menu bar or a vertical popup menu, simply grab the blank item at the end of the menu using the mouse and move it to the desired position, then type the menu text. The menu editor will automatically assign a symbolic identifier to the menu based on the text you typed; however, should you desire another identifier, you are free to change it through the menu item's property sheet. Through this property sheet, you can also adjust the initial settings of a menu item.

To insert a separator, create a blank menu item, and check the Separator box in the item's property sheet. To insert a menu item that has a submenu, create the item and check the popup box in the item's property sheet.

For every menu item, you can also prescribe a prompt string. The prompt string consists of two parts, separated by the newline (\n) character. The first part of the prompt string appears in the status bar of standard MFC applications; the second part is used for tooltips. The string you specify as the prompt string is actually deposited in your application's string table, with an identifier that matches the identifier of the menu item.

Editing a string table

A string table is a collection of text strings used in your application. The major advantage of using a string table is that it lets you use the resource file as the depository of all language-dependent elements of your application. If such an application is localized in a foreign language, only the resource file needs to be changed and relinked; it is not necessary to modify and recompile the application's source code.

The MFC Framework uses the string table extensively for MFC text constants. To edit a string in the string table, simply double-click the item and modify it as needed using the property sheet that is displayed. You can add a new string to the table by double-clicking the blank entry at the end of the list.

The toolbar editor

A new feature in Visual C++ 4 is the toolbar editor. Previously, it was necessary to edit toolbars as bitmaps and manually adjust corresponding structures in your application's source code—a procedure that was cumbersome and error-prone. With the new toolbar editor, you can edit toolbar buttons, assign command identifiers, and prompt strings all within the resource editor.

To add a new toolbar button to the toolbar, grab the blank button at the end of the toolbar using the mouse and drag it to the desired position. To remove a toolbar button, select it with the mouse and drag it out of the toolbar window altogether (pressing the Delete key will only erase the button bitmap instead of removing the button from the toolbar altogether).

You can assign a symbolic identifier and a prompt string to a toolbar button the same way you assign them to menu items. Note that in order for a toolbar button to be functional, it is not necessary to have a menu item with the same identifier. In other words, your program may have commands that are accessible from a toolbar only.

The version information resource

The version information resource identifies the current version of your executable program or library file. This version information is used by software installation functions; it is also displayed by the Windows 95 Explorer when QuickView is selected.

Binary editor for custom resources

Lastly, the resource editor can also edit custom resources. A custom resource type is identified by a type name enclosed in double quotes. Custom resources are edited through a binary editor ; more likely, they are resources that are created using an external tool. A good example for a custom resource is a multimedia sound or video file.


Resource Localization

Setting the language for a resource

The Developer Studio supports multiple language resources in the same resource file. To specify the language for a resource, select the resource identifier in ResourceView, and invoke the Properties command from the Edit menu . Note that the resource file can contain several localized versions of the same resource sharing the same identifier. Compilation of localized resources is controlled through preprocessor directives in the resource file. You can utilize localized resources in language-specific build configurations by adding the appropriate preprocessor definitions in the configuration's resource settings in the Project Settings dialog.


Resource Templates

Using resource templates

The Developer Studio supports resource templates. Resource templates are predefined resources that are used as templates when new resources are created. For example, when you select the Resource command from the Insert menu, in addition to the default dialog, you can select from a variety of additional dialog templates .

To create custom resource templates, copy the desired resources to a new resource file, and save the file as a resource template file in your msdev\template directory using the Save As command in the File menu. The new templates will appear the next time you invoke the Resource command from the Insert menu.
Am now @ Chennai