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
- Get the shell for your program by clicking here .
- Create a new menu in the resource workshop.
- Go to the resource workshop by selecting edit menu for the main window in the class expert
- Select menu in the rc window and use the right button to create a new resource.
- 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.
- Once you have your menu, create your window as explained in the notes for Week 2 .
- 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.
- Add a listbox named IDC_OUR_LISTBOX and numbered 3001. Make sure to uncheck sort in the properties for this listbox.
- Return to the main IDE and add a TDialog class called OurMain for the window you have just created.
- 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.
- Override the WM_CLOSE command to disable the close command.
- Include the header for OurMain in the main window and add the SetupWindow with the steps needed to create an example of OurMain.