The Customer Window DLL

The Main Window

We will use the resource editor to create a new window with a list box. This gives us the freedom to put headings on the columns and associate a custom menu with this window. Here is the final look of our window.

We also want to incorporate popup menus that respond to right-button clicks. In this case I used a dll with a generic right-buttton so all I had to do was incorporate the lib file in my project and put the dll and header in the same directory as the project. To get this dll click here. Once we have incorporated this and include the header in our customer window cpp file (not the header since this is a private use), we can initialize the listbox in our constructor.

CustomerList::CustomerList (CustListPtr c,TWindow* parent, TResId resId, TModule* module):
     TDialog(parent, resId, module),_custList(c)
{
//{{CustomerListXFER_USE}}
    _customers = new RightButtonListBox (this, IDC_CUSTOMERS,::Module);

    SetTransferBuffer(&CustomerListData);
//{{CustomerListXFER_USE_END}}

    // INSERT>> Your constructor code here.

}

The tabs are set in the CustomerList SetupWindow function. The add customer and edit customer functions are implemented in much the same way as those you build last semester. We use the following dialog in both.

The delete function is similar to those introduced in week 3. Notice that the deleteAt function not only deletes the customer from the customer list, it also saves the customer deleted and where it was deleted from in the customer list.

void CustomerList::cmDeleteCustomer ()
{
    // INSERT>> Your code here.
    int select = _customers->GetSelIndex();
    if (select >=0)
    {
         _custList->deleteAt(select);
         Invalidate();
         Parent->SendMessage(WM_DELETE_CUSTOMER);
    }
}

This project is not going to be a permanent program, so the message will be passed to the main program, but that program will only acknowledge the receipt of the message.


Click here
to get a copy of this program.
Click here to see how this program is converted to a dll.
Click here to return to Week 6.