Notes for week 6

For this week's links click here.

Creating a Window With a Right-Button ListBox

Introduction

This week we will start to create a project that has multiple views of a document. Each of these views will be created as a window in its own project, then exported as a dll. Our project will be abreviated, since in its final form it would be the same size (or larger) than your final project so far to large to cover in class. Luckily, once we have created one window and linked it and its messages to our main project, the rest of the project, just repeats this process.

The Project

The project we are building our window for is an order processing program. This program will take orders and then send request for merchandise as needed. There are only two aspects to this simple program:

Customers order at most one of each type of item. There will be three types of item:

When an order is processed, the customer is found and the amount of the order is added to the customers balance. If the customer is new, the customer editor adds the new customer. Customers may asked to be removed from the list, added to the list (before ordering) and have their information changed. Click here to see some of the aspects of the Customer Class are covered in detail.

Design of The New Window

We will create the customer window as a dll. We will implement the add, edit and delete functions for this window. Since it has a listbox, we will use the dll for Right-Button ListBox to add right-button clicking to this listbox. Notice that this window will eventually recieve a message to update the balance. The function handling this message can be implemented as an add-on message for the window class.

Before we delete a customer we must check to see if there are any orders still being processed for this customer. If so we should add the customer to a list of deleted customers. This must be handled by the main window, so we must send a delete message to the main window. When an order is processed, the order window will signal the main window. If the order is for a deleted customer, the main window checks the order list to see if all orders for the deleted customer have been processed. If so, the customer is removed from the list of deleted customers.

With all of this in mind, we will construct the customer window to have functions add, delete and edit. The delete function will send a WM_DELETE_CUSTOMER message to the main window. We will also build our customer list as a class which contains the pointer to the deleted item as well as the location of the deleted item. The project used to construct the dll for our customer window will not know anything about orders, but we can display a MessageBox indicating that the window recieved the delete message and displaying the name of the customer deleted.

Coding The Test Program

The methods used to code the test program for the customer window are the same as those shown demonstrated in weeks 1 through 5. For some discussion of the interface and the intricacies click here.

Distribute The Customer Classes as a DLL

After we have tested the customer class and the customer window class, we look at a problem that will occur later in our project. We need to know about customers in the Order Window, but we don't need to know about customer windows. To make customer functions more widely available, we create a dll for the customer classes. This is not a standard windows dll, so we will build the dll using the new project command. Instead of choosing EasyWin select Dynamic Library and follow the instructions for building a stand alone dll. Get a copy of the CustDll project click here.

Creating the Customer Window DLL

Once we have created the Customer class dll, we can complete the CustomerWindow class dll. In this project, this dll, would be a bit of overkill, but there are two purposes for the dll in this case. First other programs may use the customer window and second, in the case of team projects, one part of the team can develop the CustomerWindow while other parts create the rest of the project. Click here to see how this dll was created.

The Order Window

Design the Order Class

Once we have created the CustomerWindow we must design the order class and order window. Click here for a discussion of this part of the project.

Create the OrderWindow Class

This is left to you as lab 5.