Modify CMy1stEditApp::InitInstance()
The first step in adding syntax coloring to our application is to modify the function CMy1stEditApp::InitInstance(). Here is the procedure:
-
Open 1stEdit.cpp.
-
Add the following macro to the InitInstance() implementation:
SECEDIT_REGISTER_INI_LANGUAGE(_T("DevStudio"), _T(".\\DevStudio.ini"));
This macro sets the configuration source to be an .ini file. There are other macros that allow information to be read in from either a binary file or resources embedded in the application, and persisted to either a binary file or the registry. For example,
// Read and write from a bin configuration file
SECEDIT_REGISTER_BIN_LANGUAGE(lang, file)
// Read from a resource and then the registry, write to the
// registry
SECEDIT_REGISTER_RES_REG_LANGUAGE(lang, file, key)
// Read from an ini and then the registry, write to the
// registry
SECEDIT_REGISTER_INI_REG_LANGUAGE(lang, file, key)
// Read from a bin and then the registry, write to the
// registry
SECEDIT_REGISTER_BIN_REG_LANGUAGE(lang, file, key)
This macro can be added anywhere in the method, except after the call to ShowWindow() near the bottom of the method.
-
For clipboard support, add code to initialize the OLE libraries in the application object's InitInstance(). Add a call to AfxOleInit() at the beginning of the InitInstance().
AfxOleInit();
This call to AfxOleInit() is very important for clipboard support; its absence will result in inexplicable failures. For example, leaving this call out might generate the error message “CoInitialize has not been called.”






