Leaked source code of windows server 2003
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.

248 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 1990-2003 Microsoft Corporation
  3. Module Name:
  4. help.c
  5. Abstract:
  6. This module contains all help functions for the plotter user interface
  7. Development History:
  8. 06-Dec-1993 Mon 14:25:45 created
  9. [Environment:]
  10. GDI Device Driver - Plotter.
  11. [Notes:]
  12. Revision History:
  13. 31-Jan-1994 Mon 09:47:56 updated
  14. Change help file location from the system32 directory to the current
  15. plotui.dll directory
  16. --*/
  17. #include "precomp.h"
  18. #pragma hdrstop
  19. #define DBG_PLOTFILENAME DbgHelp
  20. extern HMODULE hPlotUIModule;
  21. #define DBG_SHOW_HELP 0x00000001
  22. DEFINE_DBGVAR(0);
  23. #define MAX_HELPFILE_NAME 64
  24. #define MAX_IDS_STR_LEN 160
  25. #define cbWSTR(wstr) ((wcslen(wstr) + 1) * sizeof(WCHAR))
  26. LPWSTR
  27. GetPlotHelpFile(
  28. PPRINTERINFO pPI
  29. )
  30. /*++
  31. Routine Description:
  32. This function setup the directory path for the driver Help file
  33. Arguments:
  34. hPrinter - Handle to the printer
  35. Return Value:
  36. LPWSTR to the full path HelpFile, NULL if failed
  37. Development History:
  38. 01-Nov-1995 Wed 18:43:40 created
  39. Revision History:
  40. --*/
  41. {
  42. PDRIVER_INFO_3 pDI3 = NULL;
  43. LPWSTR pHelpFile = NULL;
  44. WCHAR HelpFileName[MAX_HELPFILE_NAME];
  45. DWORD cb;
  46. DWORD cb2;
  47. HRESULT hr = E_FAIL;
  48. if (pPI->pHelpFile) {
  49. return(pPI->pHelpFile);
  50. }
  51. if ((!GetPrinterDriver(pPI->hPrinter, NULL, 3, NULL, 0, &cb)) &&
  52. (GetLastError() == ERROR_INSUFFICIENT_BUFFER) &&
  53. (pDI3 = (PDRIVER_INFO_3)LocalAlloc(LMEM_FIXED, cb)) &&
  54. (GetPrinterDriver(pPI->hPrinter, NULL, 3, (LPBYTE)pDI3, cb, &cb)) &&
  55. (pDI3->pHelpFile) &&
  56. (pHelpFile = (LPWSTR)LocalAlloc(LMEM_FIXED,
  57. cbWSTR(pDI3->pHelpFile)))) {
  58. hr = StringCchCopyW(pHelpFile, cbWSTR(pDI3->pHelpFile)/sizeof(WCHAR), (LPWSTR)pDI3->pHelpFile);
  59. } else if ((cb2 = LoadString(hPlotUIModule,
  60. IDS_HELP_FILENAME,
  61. &HelpFileName[1],
  62. COUNT_ARRAY(HelpFileName) - 1)) &&
  63. (cb2 = (cb2 + 1) * sizeof(WCHAR)) &&
  64. (!GetPrinterDriverDirectory(NULL, NULL, 1, NULL, 0, &cb)) &&
  65. (GetLastError() == ERROR_INSUFFICIENT_BUFFER) &&
  66. (pHelpFile = (LPWSTR)LocalAlloc(LMEM_FIXED, cb + cb2)) &&
  67. (GetPrinterDriverDirectory(NULL,
  68. NULL,
  69. 1,
  70. (LPBYTE)pHelpFile,
  71. cb,
  72. &cb))) {
  73. HelpFileName[0] = L'\\';
  74. hr = StringCchCatW(pHelpFile, (cb + cb2) /sizeof(WCHAR), HelpFileName);
  75. }
  76. if (pDI3) {
  77. LocalFree((HLOCAL)pDI3);
  78. pDI3 = NULL;
  79. }
  80. if (pHelpFile && !SUCCEEDED(hr))
  81. {
  82. LocalFree(pHelpFile);
  83. pHelpFile = NULL;
  84. }
  85. PLOTDBG(DBG_SHOW_HELP, ("GetlotHelpFile: '%ws",
  86. (pHelpFile) ? pHelpFile : L"Failed"));
  87. return(pPI->pHelpFile = pHelpFile);
  88. }
  89. INT
  90. cdecl
  91. PlotUIMsgBox(
  92. HWND hWnd,
  93. LONG IDString,
  94. LONG Style,
  95. ...
  96. )
  97. /*++
  98. Routine Description:
  99. This function pop up a simple message and let user to press key to
  100. continue
  101. Arguments:
  102. hWnd - Handle to the caller window
  103. IDString - String ID to be output with
  104. ... - Parameter
  105. Return Value:
  106. Development History:
  107. 06-Dec-1993 Mon 21:31:41 created
  108. Revision History:
  109. 24-Jul-2000 Mon 12:18:12 updated
  110. Fix for someone's change due to the fact that NULL character is not
  111. counted for the string
  112. --*/
  113. {
  114. va_list vaList;
  115. LPWSTR pwTitle;
  116. LPWSTR pwFormat;
  117. LPWSTR pwMessage;
  118. INT i;
  119. INT MBRet = IDCANCEL;
  120. HRESULT hr;
  121. //
  122. // We assume that UNICODE flag is turn on for the compilation, bug the
  123. // format string passed to here is ASCII version, so we need to convert
  124. // it to LPWSTR before the wvsprintf()
  125. //
  126. // 24-Jul-2000 Mon 13:17:13 updated
  127. // 1 MAX_IDS_STR_LEN for pwTitle,
  128. // 1 MAX_IDS_STR_LEN for pwFormat
  129. // 2 MAX_IDS_STR_LEN for pwMessage (wvsprintf)
  130. //
  131. if (!(pwTitle = (LPWSTR)LocalAlloc(LMEM_FIXED,
  132. sizeof(WCHAR) * MAX_IDS_STR_LEN * 4))) {
  133. return(0);
  134. }
  135. if (i = LoadString(hPlotUIModule,
  136. IDS_PLOTTER_DRIVER,
  137. pwTitle,
  138. MAX_IDS_STR_LEN - 1)) {
  139. pwFormat = pwTitle + i + 1;
  140. if (i = LoadString(hPlotUIModule,
  141. IDString,
  142. pwFormat,
  143. MAX_IDS_STR_LEN - 1)) {
  144. pwMessage = pwFormat + i + 1;
  145. va_start(vaList, Style);
  146. hr = StringCchVPrintfW(pwMessage, MAX_IDS_STR_LEN - 1, pwFormat, vaList);
  147. va_end(vaList);
  148. MBRet = MessageBox(hWnd, pwMessage, pwTitle, MB_APPLMODAL | Style);
  149. }
  150. }
  151. LocalFree((HLOCAL)pwTitle);
  152. return(MBRet);
  153. }