RESOURCES - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

RESOURCES

Description:

Menu's and menu items can be defined with Borland's Resource Workshop. Borland's Resource Workshop. Create or Edit resource script (.rc) files ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 11
Provided by: gae5
Category:

less

Transcript and Presenter's Notes

Title: RESOURCES


1
RESOURCES
  • Borland Resource Workshop

2
Resources
  • Menus
  • Menu Items
  • Dialog Boxes or Child Windows
  • Buttons or other Controls
  • Bitmaps or other Graphics

3
Menu
  • A POPUP menu, also known as a drop down menu,
    appears in the menu bar of an application.
  • The popup menu has Menu items, defined with the
    keyword MENUITEM.
  • Menus and menu items can be defined with
    Borlands Resource Workshop.

4
Borlands Resource Workshop
  • Create or Edit resource script (.rc) files
  • Create or Edit graphic files (.bmp .ico .fnt)
  • Automatically generates the binary code
    represented by your resources
  • Automatically makes entries to your projects
    header file - ex proj10.h recording the IDs of
    your resources

5
Creating a Menu
  • Double click on the .rc file in the project tree
    - or select Tool, Resource Workshop.
  • Select Resource, New, then select Menu.
  • Edit the menu ID and name, Menu Items, etc.
  • an in front of a letter in a menu item name
    causes that letter to be underlined and gives
    access to the menu object by using the keyboard.
    Called a mnemonic.

6
Save the Resource File
  • The resource file project must be saved each
    time changes are made.
  • The first time you save the resource project, you
    will be prompted to add the file to the project.
    You are adding a header file with resource
    identification numbers defined in it. Name the
    file the same as your source code with the .h
    extension.
  • When you compile your source code, the resources
    will be linked in and compiled, too.

7
Add the Menu to Your Program in Your Class
Definition
  • WNDCLASS wc
  • wc.style CS_HREDRAW CS_VREDRAW
  • wc.lpfnWndProc MainWndProc
  • wc.cbClsExtra 0
  • wc.cbWndExtra 0
  • wc.hInstance hInstance
  • wc.hIcon LoadIcon ( hInstance,
    IDI_APPLICATION )
  • wc.hCursor LoadCursor ( NULL, IDC_ARROW
    )
  • wc.hbrBackground GetStockObject ( WHITE_BRUSH
    )
  • wc.lpszMenuName PIZZA_MENU"
  • wc.lpszClassName szAppName
  • if ( !RegisterClass ( wc ) )
  • return ( FALSE )
  • return ( TRUE )

8
Add Processing Code to the MainWndProc
  • case WM_COMMAND
  • switch (wParam)
  • case CM_EXIT / Menu Item ID
    /
  • DestroyWindow ( hWnd )
  • case CM_ORDER / Menu Item ID /
  • MessageBox( hWnd, "You Want to Order Pizza!",
    "Pizza Order",
  • MB_OK MB_ICONEXCLAMATION)
  • default
  • return ( DefWindowProc ( hWnd, message, wParam,
    lParam ) )

9
Include Your New Header File In Your Program
  • Add the following preprocessor directive to your
    program code
  • include projXX.h

10
Thats All You Have To Do
  • Once you have included the header file that
    contains the IDs for your resources and the Menu
    Name is part of the class description for your
    window class, the CreateWindow function does not
    need the menu name again. NULL is used as the
    argument for a menu or child window when the
    class defined menu is to be used. Actually, the
    argument in the CreateWindow function for the
    menu or child window (argument 9) is used to
    override the class menu if necessary.
Write a Comment
User Comments (0)
About PowerShow.com