Using Other Control Features

You've seen how to customize the control class CScrollBar by adding code in the dialog's OnInitDialog member function. You can program other controls in a similar fashion. In the Microsoft Visual C++ MFC Library Reference, or in the online help under "Microsoft Foundation Class Libary and Templates," look at the control classes, particularly CListBox and CComboBox. Each has a number of features that ClassWizard does not directly support. Some combo boxes, for example, can support multiple selections. If you want to use these features, don't try to use ClassWizard to add data members. Instead, define your own data members and add your own exchange code in OnInitDialog and OnClickedOK.

For Win32 Programmers

If you've programmed controls in Win32, you'll know that parent windows communicate to controls via Windows messages. So what does a function such as CListBox::InsertString do? (You've seen this function called in your OnInitDialog function.) If you look at the MFC source code, you'll see that InsertString sends an LB_INSERTSTRING message to the designated list-box control. Other control class member functions don't send messages because they apply to all window types. The CScrollView::SetScrollRange function, for example, calls the Win32 SetScrollRange function, specifying the correct hWnd as a parameter.



Programming Visual C++
Advanced 3ds max 5 Modeling & Animating
ISBN: 1572318570
EAN: 2147483647
Year: 1997
Pages: 331
Authors: Boris Kulagin

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net