Index Visual C++ and MFC Fundamentals
int StringToInt(const CString Str)
{
// First check to see if this is a valid natural number
BOOL IsValid = IsNatural(Str);
// If this number is valid, then convert it
if( IsValid == TRUE )
return atoi(Str);
else
{
// Return 0 to be nice
return 0;
}
}
double StringToFloat(const CString Str)
{
// First check to see if this is a valid number
BOOL IsValid = IsNumeric(Str);
// If this number is valid, then convert it
if( IsValid == TRUE )
return atof(Str);
else
{
// Return 0 to be nice
return 0;
}
}
}
- To create the library, on the main menu, click Build -> Build MFCExt.lib
The Output window will indicate that a file with .lib extension was created
22.3.3..MFC Static Library Test....................................................................
Like the regular static library we saw above, you can use an MFC static library either on
a console or a graphical application. The main difference is that the application must be
able use MFC. Therefore, when creating the application, specify that you will use MFC
either In A Shared DLL or In A Static DLL.
Practical Learning: Testing an MFC Static Library
- To start a new application, on the main menu, click File -> New...
- In the Projects tab of the New dialog box, click MFC AppWizard. In the Project
Name edit box, type MFCExtTest and click OK