home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / ccdata.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  2KB  |  74 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_INIT_SEG
  14. #pragma code_seg(AFX_INIT_SEG)
  15. #endif
  16.  
  17. #pragma comment(lib, "imagehlp.lib")
  18. #pragma comment(lib, "comctl32.lib")
  19. #pragma comment(lib, "shell32.lib")
  20. #pragma comment(lib, "comdlg32.lib")
  21. #pragma comment(lib, "winspool.lib")
  22. #pragma comment(lib, "advapi32.lib")
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // AfxGetPropSheetFont
  26.  
  27. struct _AFX_PROPPAGEFONTINFO : public CNoTrackObject
  28. {
  29.     LPTSTR m_pszFaceName;
  30.     WORD m_wSize;
  31.     _AFX_PROPPAGEFONTINFO() : m_pszFaceName(NULL), m_wSize(0) {}
  32.     ~_AFX_PROPPAGEFONTINFO() { GlobalFree(m_pszFaceName); }
  33. };
  34.  
  35. PROCESS_LOCAL(_AFX_PROPPAGEFONTINFO, _afxPropPageFontInfo)
  36.  
  37. #define IDD_PROPSHEET   1006
  38. #define IDD_WIZARD      1020
  39.  
  40. BOOL AFXAPI AfxGetPropSheetFont(CString& strFace, WORD& wSize, BOOL bWizard)
  41. {
  42.     _AFX_PROPPAGEFONTINFO* pFontInfo = _afxPropPageFontInfo.GetData();
  43.  
  44.     // determine which font property sheet will use
  45.     if (pFontInfo->m_wSize == 0)
  46.     {
  47.         ASSERT(pFontInfo->m_pszFaceName == NULL);
  48.  
  49.         HINSTANCE hInst = GetModuleHandleA("COMCTL32.DLL");
  50.         if (hInst != NULL)
  51.         {
  52.             HRSRC hResource = ::FindResource(hInst,
  53.                 MAKEINTRESOURCE(bWizard ? IDD_WIZARD : IDD_PROPSHEET),
  54.                 RT_DIALOG);
  55.             HGLOBAL hTemplate = LoadResource(hInst, hResource);
  56.             if (hTemplate != NULL)
  57.                 CDialogTemplate::GetFont((DLGTEMPLATE*)hTemplate, strFace,
  58.                     wSize);
  59.         }
  60.  
  61.         pFontInfo->m_pszFaceName = (LPTSTR)GlobalAlloc(GPTR, sizeof(TCHAR) *
  62.             (strFace.GetLength() + 1));
  63.         lstrcpy(pFontInfo->m_pszFaceName, strFace);
  64.         pFontInfo->m_wSize = wSize;
  65.     }
  66.  
  67.     strFace = pFontInfo->m_pszFaceName;
  68.     wSize = pFontInfo->m_wSize;
  69.  
  70.     return (wSize != 0xFFFF);
  71. }
  72.  
  73. /////////////////////////////////////////////////////////////////////////////
  74.