IPB

> Loading Resources into an Application
Чат
Форум
Загрузка...
 

Язык:
Русский
English

   Loading Resources into an Application


After a resource has been added to the executable file, the application must explicitly load the resource before using it. The specific way to load a resource depends on the resource type.

Menu Resources

Load menu resources by calling the LoadMenu function with the menu ID string when a new window object is constructed.

Accelerator Resources

Accelerator resources are stored in an accelerator table.

To load an accelerator table, use the LoadAccelerators function, which returns a handle to the table.

  - Each application can have only one accelerator table.
  - Application objects reserve one object field, HAccTable, to store a
    handle to the accelerator resource.
  - You will usually load the accelerator resource in the application
    object's InitInstance method

Dialog-box Resources

Dialog boxes are the only resource type to have directly-corresponding ObjectWindows object types.

TDialog and its descendant types, including TDlgWindow, define interface objects that use dialog box resources.

Each dialog box object is typically associated with one dialog box resource, which specifies its size, location, and assortment of controls, such as buttons and list boxes.

Cursor and Icon Resources

Each window-object type has special attributes called registration attributes, including the window's cursors and icons.

To set these attributes for a window type, you must define a method called GetWindowClass and one called GetClassName.

The cursor is specified for one window, while the icon represents the entire application.

(One exception to the one-icon-per-application rule is an application that follows the multiple document interface (MDI) standard, for which each MDI child window has its own icon.)

String Resources

Two principal reasons for defining an application's strings as resources are to make it easy to

  - customize the application for particular uses.
  - translate the application into other languages.

If the strings are defined as resources, they are stored in a string table within the application's executable file.

Each executable file can have only one string table.

To load a string from the string table into a buffer in your application's data segment, use the LoadString function. You can use a string resource to

  - display text within a message box.
  - add or append items to a menu in your source code.

Bitmap Resources

The LoadBitmap function loads bitmap resources by loading the bitmap into memory and returning its handle.

Once a bitmap is loaded, it will stay in memory until you explicitly delete it (with DeleteObject).

Windows supplies predefined bitmaps as part of the Windows graphical interface. Your application can load these bitmaps by substituting 0 for HInstance in the LoadBitmap call:

Once the bitmap is loaded, your application can use it in several principal ways:

  - To draw a picture on the display
  - To create a brush used to fill an area of the display or to serve as a
    window's background
  - To display pictures rather than text for menu or list box items

See Also

 
 К началу страницы 
 

Код для вставки: :: :: :: ГОСТ ::
Поделиться: //
 



-
Хостинг предоставлен компанией "Веб Сервис Центр" при поддержке компании "ДокЛаб"