One way we can improve our interface is to reduce the amount of mouse motion necessary to perform an operation. In a typical operation in our course program we select an item in one of the windows, them move the mouse to the menu bar to select an operation. If we allowed the use to select and display the menu by a click of the right button, we would save time and motion. We will implement the right-button select as described in the Borland notes.
Once you have a right button list box, you want to have the parent respond to the right-button click. In this case we display a menu and enable choice of operations from that menu. This is covered in the Borland notes.
Now that we have the boiler plate code complete we need only look at the constructor and SetupWindow function (if it exists) for our professor window to see where the listbox was created. In this case we have two constructors where we replace TListBox with RButtonListBox.
ProfWindow::ProfWindow (TWindow* parent, TResId resId, TModule* module):
TDialog(parent, resId, module)
{
//{{ProfWindowXFER_USE}}
_professors = new RButtonListBox(this, IDC_PROFESSORS);
SetTransferBuffer(&ProfWindowData);
//{{ProfWindowXFER_USE_END}}
// INSERT>> Your constructor code here.
}
ProfWindow::ProfWindow (ProfListPtr profs,TWindow* parent, TResId resId, TModule* module):
TDialog(parent, resId, module),_profList(profs)
{
//{{ProfWindowXFER_USE}}
_professors = new RButtonListBox(this, IDC_PROFESSORS);
SetTransferBuffer(&ProfWindowData);
//{{ProfWindowXFER_USE_END}}
// INSERT>> Your constructor code here.
}
Now a right button click inside the professor window displays and activates a popup menu.