精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。”需要全文内容也请联系孙老师。中文译文
                  

                    First of all, I beg your pardon for any errors in my  English and in the content of this article (it's my first submission).
                    For a personal project (a PropertyList control), I  needed a ListBox which could display and allow selection of fonts. After  reading several articles on this subject, I decided to write my own control with  the following main behaviors:
 To manage a MRU sublist, shared or not, CFontListBox uses the services offered by an instance of the CFontListManager.  Only one instance of CFontListManager is created automatically during the  application initialization. This class is responsible for loading the font  list, managing the MRU list (private to a CFontListBox instance,  shared between two or more controls, or global to the application) through the CFontDescriptor and CFontMruList objects and its various collections. 
                    This control gets the bitmap used to display the list  from a bitmap resource of COMDLG32.DLL, so there is no specific resource  to be included in your project.
                    To allow the loading process of the font list, this  control does not use the way used by other controls. I tried to distinguish  between the font types (TrueType, OpenType and so on). It uses the flags given  by the ::EnumFontFamiliesEx API to the callback function (see EnumFontProc and CFontListManager::FillFontList() functions in FontListManager.cpp).
                    The re-creation of the base ListBox window is needed to  allow modifications of the control after its creation to follow the  modifications of the CFontListBox style flags.
                    The persistence of the MRU list needs two functions  called in the CWinApp::InitInstance and CWinApp::ExitInstance  methods. This is due to the fact that when an instance of CFontListManager is created, the CWinApp::SetCurrentHandles() is not called (this function of the MFC  library is responsible for the initialization of the data members of CWinApp  object, like m_pszRegistryKey and m_pszProfileName). Persistence acts only on the global MRU  list and the custom named ones, if these lists are marked to do so.
                    CFontListManager  has a feature that allows it to react to the system-wide broadcasted message WM_FONTCHANGE. This feature needs a top-level window to receive the message which is  created the first time a CFontListBox is created (which can only occur after  the CWinApp object and other frame or dialog windows are  initialized).