ccdata.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #include "stdafx.h"
  11. #ifdef AFX_INIT_SEG
  12. #pragma code_seg(AFX_INIT_SEG)
  13. #endif
  14. #pragma comment(lib, "imagehlp.lib")
  15. #pragma comment(lib, "comctl32.lib")
  16. #pragma comment(lib, "shell32.lib")
  17. #pragma comment(lib, "comdlg32.lib")
  18. #pragma comment(lib, "winspool.lib")
  19. #pragma comment(lib, "advapi32.lib")
  20. /////////////////////////////////////////////////////////////////////////////
  21. // AfxGetPropSheetFont
  22. struct _AFX_PROPPAGEFONTINFO : public CNoTrackObject
  23. {
  24. LPTSTR m_pszFaceName;
  25. WORD m_wSize;
  26. _AFX_PROPPAGEFONTINFO() : m_pszFaceName(NULL), m_wSize(0) {}
  27. ~_AFX_PROPPAGEFONTINFO() { GlobalFree(m_pszFaceName); }
  28. };
  29. PROCESS_LOCAL(_AFX_PROPPAGEFONTINFO, _afxPropPageFontInfo)
  30. #define IDD_PROPSHEET 1006
  31. #define IDD_WIZARD 1020
  32. BOOL AFXAPI AfxGetPropSheetFont(CString& strFace, WORD& wSize, BOOL bWizard)
  33. {
  34. _AFX_PROPPAGEFONTINFO* pFontInfo = _afxPropPageFontInfo.GetData();
  35. // determine which font property sheet will use
  36. if (pFontInfo->m_wSize == 0)
  37. {
  38. ASSERT(pFontInfo->m_pszFaceName == NULL);
  39. HINSTANCE hInst = GetModuleHandleA("COMCTL32.DLL");
  40. if (hInst != NULL)
  41. {
  42. HRSRC hResource = ::FindResource(hInst,
  43. MAKEINTRESOURCE(bWizard ? IDD_WIZARD : IDD_PROPSHEET),
  44. RT_DIALOG);
  45. HGLOBAL hTemplate = LoadResource(hInst, hResource);
  46. if (hTemplate != NULL)
  47. CDialogTemplate::GetFont((DLGTEMPLATE*)hTemplate, strFace,
  48. wSize);
  49. }
  50. pFontInfo->m_pszFaceName = (LPTSTR)GlobalAlloc(GPTR, sizeof(TCHAR) *
  51. (strFace.GetLength() + 1));
  52. lstrcpy(pFontInfo->m_pszFaceName, strFace);
  53. pFontInfo->m_wSize = wSize;
  54. }
  55. strFace = pFontInfo->m_pszFaceName;
  56. wSize = pFontInfo->m_wSize;
  57. return (wSize != 0xFFFF);
  58. }
  59. /////////////////////////////////////////////////////////////////////////////