In Class Exercise 1

Introduction

This exercise will trace the steps use to create a stand-alone window in Borland c++. We will follow the process outlinedin the Week 2 notes. This window will contain a listbox and a menu. You will be able to add and delete strings from the list box. I would suggest doing steps 1 through 4 before class.

The Process

  1. Get the shell for your program by clicking here .
  2. Create a new menu in the resource workshop.
    1. Go to the resource workshop by selecting edit menu for the main window in the class expert
    2. Select menu in the rc window and use the right button to create a new resource.
    3. Name the menu SDI_SUB_MENU and set this id to 3010 (our window will be numbered 3000) and each menu item will be numbered consecutively starting at 3011.
  3. Once you have your menu, create your window as explained in the notes for Week 2 .
  4. In the properties dialog for this window set the menu to be SDI_SUB_MENU, and rename the window IDD_OUR_MAINand number it 3000.
  5. Add a listbox named IDC_OUR_LISTBOX and numbered 3001. Make sure to uncheck sort in the properties for this listbox.
  6. Return to the main IDE and add a TDialog class called OurMain for the window you have just created.
  7. Add an instance variable for the listbox and handlers for the add and delete. For add use a TInputDialog to get a string then use AddString to add it to the listbox. Use GetSelIndex to get the index of the currently selected item. If the value returned is >=0 the call DeleteString to delete the item.
  8. Override the WM_CLOSE command to disable the close command.
  9. Include the header for OurMain in the main window and add the SetupWindow with the steps needed to create an example of OurMain.