Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.6 KiB

  1. /*++
  2. *
  3. * WOW v1.0
  4. *
  5. * Copyright (c) 1991, Microsoft Corporation
  6. *
  7. * FONTRES.C
  8. * WOW16 user resource services
  9. *
  10. * History:
  11. *
  12. * Created 05-Apr-1993 by Craig Jones (v-cjones)
  13. *
  14. * This file provides support for the Win 3.1 AddFontResource &
  15. * RemoveFontResource API's.
  16. *
  17. --*/
  18. #include <windows.h>
  19. int WINAPI WOWAddFontResource (LPCSTR lpszFileName);
  20. BOOL WINAPI WOWRemoveFontResource (LPCSTR lpszFileName);
  21. WORD WINAPI WOWCreateDIBPatternBrush(LPVOID lpData, UINT fColor);
  22. int WINAPI IAddFontResource (LPCSTR lpszFileName)
  23. {
  24. int ret;
  25. char sz[128];
  26. LPSTR lpsz;
  27. // if the app passed a handle instead of a file name - get the file name
  28. if(HIWORD((DWORD)lpszFileName) == 0) {
  29. if(GetModuleFileName((HINSTANCE)LOWORD((DWORD)lpszFileName), sz, 128)) {
  30. lpsz = sz;
  31. }
  32. else {
  33. lpsz = NULL;
  34. ret = 0;
  35. }
  36. }
  37. else {
  38. lpsz = (LPSTR)lpszFileName;
  39. }
  40. // we're really calling wg32AddFontResource here
  41. if(lpsz) {
  42. ret = WOWAddFontResource((LPCSTR)lpsz);
  43. }
  44. // ALDUS PM5 expects AddFontResource to succeed if given the base name of
  45. // a font that it previously did a LoadLibrary on. The full path name was
  46. // passed to LoadLibrary. So if AddFontResouce failed then find out if
  47. // there is a loaded module already. If so then get the full path name
  48. // and retry the AddFontResource. - MarkRi 6/93
  49. if( !ret && (HIWORD((DWORD)lpszFileName) != 0) ) {
  50. HMODULE hmod ;
  51. hmod = GetModuleHandle( lpszFileName ) ;
  52. if( hmod ) {
  53. if( GetModuleFileName( (HINSTANCE)hmod, sz, sizeof(sz) ) ) {
  54. ret = WOWAddFontResource( (LPCSTR)sz ) ;
  55. }
  56. }
  57. }
  58. return(ret);
  59. }
  60. BOOL WINAPI IRemoveFontResource (LPCSTR lpszFileName)
  61. {
  62. BOOL ret;
  63. char sz[128];
  64. LPSTR lpsz;
  65. // if the app passed a handle instead of a file name - get the file name
  66. if(HIWORD((DWORD)lpszFileName) == 0) {
  67. if(GetModuleFileName((HINSTANCE)LOWORD((DWORD)lpszFileName), sz, 128)) {
  68. lpsz = sz;
  69. }
  70. else {
  71. lpsz = NULL;
  72. ret = FALSE;
  73. }
  74. }
  75. else {
  76. lpsz = (LPSTR)lpszFileName;
  77. }
  78. // we're really calling wg32RemoveFontResource here
  79. if(lpsz) {
  80. ret = (BOOL)WOWRemoveFontResource((LPCSTR)lpsz);
  81. }
  82. return(ret);
  83. }
  84. WORD WINAPI ICreateDIBPatternBrush (HGLOBAL hMem, UINT fColor)
  85. {
  86. LPVOID lpT;
  87. WORD wRet = 0;
  88. if (lpT = LockResource(hMem)) {
  89. wRet = WOWCreateDIBPatternBrush(lpT, fColor);
  90. UnlockResource(hMem);
  91. }
  92. return wRet;
  93. }