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.

392 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. help.c
  5. Abstract:
  6. This module contains function when user hit help button or F1
  7. Author:
  8. 28-Aug-1995 Mon 14:55:07 created -by- Daniel Chou (danielc)
  9. [Environment:]
  10. NT Windows - Common Printer Driver UI DLL.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #define DBG_CPSUIFILENAME DbgHelp
  17. #define DBG_HELP_MSGBOX 0x00000001
  18. DEFINE_DBGVAR(0);
  19. extern HINSTANCE hInstDLL;
  20. WCHAR CPSUIHelpFile[] = L"compstui.hlp";
  21. #define MAX_HELPFILE_SIZE 300
  22. #define TMP_HELP_WND_ID 0x7fff
  23. #if DBG
  24. INT
  25. HelpMsgBox(
  26. HWND hDlg,
  27. PTVWND pTVWnd,
  28. LPTSTR pHelpFile,
  29. POPTITEM pItem,
  30. UINT HelpIdx
  31. )
  32. /*++
  33. Routine Description:
  34. Arguments:
  35. Return Value:
  36. Author:
  37. 26-Sep-1995 Tue 13:20:25 created -by- Daniel Chou (danielc)
  38. Revision History:
  39. --*/
  40. {
  41. UINT Count;
  42. UINT Style;
  43. GSBUF_DEF(pItem, 360);
  44. if (DbgHelp & DBG_HELP_MSGBOX) {
  45. if (pHelpFile) {
  46. Style = MB_ICONINFORMATION | MB_OKCANCEL;
  47. GSBUF_GETSTR(L"HelpFile=");
  48. GSBUF_GETSTR(pHelpFile);
  49. GSBUF_GETSTR(L"\nOption=");
  50. } else {
  51. GSBUF_GETSTR(L"HelpFile= -None-\nOption=");
  52. Style = MB_ICONSTOP | MB_OK;
  53. }
  54. if ((pItem) && (HelpIdx)) {
  55. GSBUF_GETSTR(pItem->pName);
  56. GSBUF_GETSTR(L"HelpIdx=");
  57. GSBUF_ADDNUM(HelpIdx, FALSE);
  58. } else {
  59. GSBUF_GETSTR(L"<NONE, General Help>");
  60. }
  61. return(MessageBox(hDlg,
  62. GSBUF_BUF,
  63. TEXT("DBG: Common Property Sheet UI"),
  64. Style));
  65. } else {
  66. return(TRUE);
  67. }
  68. }
  69. #endif
  70. BOOL
  71. CommonPropSheetUIHelp(
  72. HWND hDlg,
  73. PTVWND pTVWnd,
  74. HWND hWndHelp,
  75. DWORD MousePos,
  76. POPTITEM pItem,
  77. UINT HelpCmd
  78. )
  79. /*++
  80. Routine Description:
  81. This function initialize/display/end the plotter help system
  82. Arguments:
  83. hDlg - Handle to the dialog box need help
  84. pTVWnd - Our instance data
  85. hWndHelp - the window cause the context help
  86. MousePos - Mouse position where the right click happened
  87. x=LOWORD(MousePos), y=HIWORD(MousePos)
  88. pItem - Pointer to the OPTITEM for the context help
  89. HelpCmd - Help type
  90. Return Value:
  91. VOID
  92. Author:
  93. 28-Aug-1995 Mon 15:24:27 updated -by- Daniel Chou (danielc)w
  94. Revision History:
  95. --*/
  96. {
  97. LPWSTR pHelpFile = NULL;
  98. DWORD HelpIdx;
  99. BOOL Ok = FALSE;
  100. GSBUF_DEF(pItem, MAX_HELPFILE_SIZE);
  101. if (pItem) {
  102. if (HelpIdx = (DWORD)_OI_HELPIDX(pItem)) {
  103. if (!LoadString(hInstDLL,
  104. IDS_INT_CPSUI_HELPFILE,
  105. pHelpFile = GSBUF_BUF,
  106. MAX_HELPFILE_SIZE)) {
  107. pHelpFile = CPSUIHelpFile;
  108. }
  109. } else if (GSBUF_GETSTR(_OI_PHELPFILE(pItem))) {
  110. pHelpFile = GSBUF_BUF;
  111. HelpIdx = pItem->HelpIndex;
  112. }
  113. }
  114. if ((!pHelpFile) &&
  115. (GSBUF_GETSTR(pTVWnd->ComPropSheetUI.pHelpFile))) {
  116. pHelpFile = GSBUF_BUF;
  117. HelpIdx = 0;
  118. }
  119. /*
  120. * Quite easy - simply call the WinHelp function with the parameters
  121. * supplied to us. If this fails, then put up a stock dialog box.
  122. * BUT the first time we figure out what the file name is. We know
  123. * the actual name, but we don't know where it is located, so we
  124. * need to call the spooler for that information.
  125. */
  126. if (pHelpFile) {
  127. HWND hWndTmp;
  128. POINT pt;
  129. DWORD HelpID[4];
  130. ULONG_PTR Data;
  131. CPSUIDBGBLK(
  132. {
  133. if (HelpMsgBox(hDlg,
  134. pTVWnd,
  135. pHelpFile,
  136. pItem,
  137. HelpIdx) == IDCANCEL) {
  138. return(TRUE);
  139. }
  140. })
  141. //
  142. // Try to pop-up help on the right click position, where we will create
  143. // a temp button window and do the help, this way we can do context
  144. // sensitive help on any type of window (static, icon) and even it is
  145. // disabled. We need to destroy this temp window before we exit from
  146. // this fucntion
  147. //
  148. pt.x = LOWORD(MousePos);
  149. pt.y = HIWORD(MousePos);
  150. ScreenToClient(hDlg, &pt);
  151. if (hWndTmp = CreateWindowEx(WS_EX_NOPARENTNOTIFY | WS_EX_CONTEXTHELP,
  152. L"button",
  153. L"",
  154. WS_CHILD | BS_CHECKBOX,
  155. pt.x,
  156. pt.y,
  157. 1,
  158. 1,
  159. hDlg,
  160. (HMENU)TMP_HELP_WND_ID,
  161. hInstDLL,
  162. 0)) {
  163. hWndHelp = hWndTmp;
  164. } else {
  165. CPSUIERR(("CommonPropSheetUIHelp: Create temp. help window failed"));
  166. }
  167. HelpID[0] = (hWndHelp) ? (DWORD)GetWindowLongPtr(hWndHelp, GWLP_ID) : 0;
  168. HelpID[1] = HelpIdx;
  169. HelpID[2] =
  170. HelpID[3] = 0;
  171. switch (HelpCmd) {
  172. case HELP_WM_HELP:
  173. if ((!HelpID[0]) || (!HelpID[1])) {
  174. HelpCmd = HELP_CONTENTS;
  175. hWndHelp = hDlg;
  176. Data = 0;
  177. break;
  178. }
  179. case HELP_CONTEXTMENU:
  180. SetWindowContextHelpId(hWndHelp, HelpID[1]);
  181. Data = (ULONG_PTR)&HelpID[0];
  182. break;
  183. case HELP_CONTEXT:
  184. case HELP_CONTEXTPOPUP:
  185. Data = (ULONG_PTR)HelpID[1];
  186. break;
  187. default:
  188. Data = 0;
  189. break;
  190. }
  191. CPSUIINT(("Help: hWnd=%08lx, Cmd=%ld, ID=[%ld, %ld]",
  192. hWndHelp, HelpCmd, HelpID[0], HelpID[1]));
  193. Ok = WinHelp(hWndHelp, pHelpFile, HelpCmd, Data);
  194. if (hWndTmp) {
  195. DestroyWindow(hWndTmp);
  196. }
  197. } else {
  198. CPSUIDBGBLK({ HelpMsgBox(hDlg, pTVWnd, NULL, pItem, HelpIdx); })
  199. }
  200. return(Ok);
  201. }
  202. VOID
  203. CommonPropSheetUIHelpSetup(
  204. HWND hDlg,
  205. PTVWND pTVWnd
  206. )
  207. /*++
  208. Routine Description:
  209. This function will setup or remove the plotter UI help system
  210. Arguments:
  211. hDlg - Handle to the dialog interested, if hDlg != NULL then it will
  212. quit the help
  213. pTVWnd - Pointer to the instance data for the common UI
  214. Return Value:
  215. VOID
  216. Author:
  217. 28-Aug-1995 Mon 15:21:20 updated -by- Daniel Chou (danielc)
  218. Revision History:
  219. --*/
  220. {
  221. #if 0
  222. GSBUF_DEF(MAX_HELPFILE_SIZE);
  223. if ((hDlg) &&
  224. (GSBUF_GETSTR(pTVWnd->ComPropSheetUI.pHelpFile))) {
  225. WinHelp(hDlg, GSBUF_BUF, HELP_QUIT, 0);
  226. }
  227. #endif
  228. return;
  229. }