Graphics Reference
In-Depth Information
class CSliderCtrlWithEcho : public CSliderCtrl {
A: public interface functions
void Initialize( float min, float max, float init); // initialization
bool SetSliderValue( float userValue); // set the slider bar for output
float GetSliderValue();
// get user input value from the slider bar
B: Internal representation and impelementation
int UserToMFCPos( float userValue); // translation from user (float) to MFC values (integer)
float MFCToUserPos( int mfcValue);
// translation from MFC (integer) to user (float) values
void UpdateSliderEcho();
// update current slider value to numeric echo area
CStatic m _ MessageWnd;
// control varaible for the echo area
C: Override MFC event service routines
afx _ msg void HScroll(UINT nSBCode, UINT nPos); // horizonatl scroll service routine
afx _ msg void VScroll(UINT nSBCode, UINT nPos); // vertical scroll service routine
};
Source file.
SliderCtrlWithEcho.h file
in the Controls folder of the
MFC _ SliderCtrlWithEcho
project.
Listing 2.10. The CSliderCtrlWithEcho class (Tutorial 2.6).
Tutorial 2.7. The MFC Library
Tutorial 2.7.
Project Name:
MFC _ UseLibrary1
Library Support:
MFC _ Library1
Goal. Demonstrate the advantage of collecting functionally related files
into a separate software library.
Approach. Gather all GUI API-specific functions and create a customized
GUI library for our application.
The source code of Tutorial 2.7 is identical to that of Tutorial 2.6. The only dif-
ference here is in the organization of the source code listings. When we examine
the source code for Tutorial 2.7, we see that we have collected all MFC-specific
utilities and created the MFC _ Library1 software library. As the number of files
grows in our development environment, creation of libraries to group functionally
related files will become very important in maintaining a manageable source code
structure. In all of our implementations, we call functions from MFC _ Library1
whenever possible. In this way, we have customized the GUI API, where instead
of calling the underlying MFC functions, we call our library functions where the
support is customized specifically for our applications.
As the developer of a software library, we must provide the following.
Manual and sample code. This is to support ease of use by developers
using our library. The manual should describe the functionality and docu-
ment all classes/functions in the library. The sample code should illustrate
Search WWH ::




Custom Search