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.

87 lines
2.0 KiB

  1. //
  2. // html help messagebox, requires to be linked with htmlhelp.lib.
  3. //
  4. #include "userinit.h"
  5. #include <Htmlhelp.h>
  6. #pragma warning(push, 4)
  7. LPTSTR MSGPARENT_WINDOWCLASS = TEXT("MessageHelpWndClass");
  8. LRESULT CALLBACK MessageHelpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  9. {
  10. static LPTSTR szHelpFile = NULL;
  11. switch (message)
  12. {
  13. case WM_HELP:
  14. HtmlHelp(hWnd, szHelpFile, HH_DISPLAY_TOPIC, 0);
  15. return TRUE;
  16. break;
  17. case WM_CREATE:
  18. szHelpFile = (LPTSTR)((LPCREATESTRUCT)lParam)->lpCreateParams;
  19. return DefWindowProc(hWnd, message, wParam, lParam);
  20. break;
  21. default:
  22. return DefWindowProc(hWnd, message, wParam, lParam);
  23. }
  24. }
  25. ATOM RegisterHelpMessageClass(HINSTANCE hInstance)
  26. {
  27. WNDCLASSEX wcex;
  28. ZeroMemory(&wcex, sizeof(WNDCLASSEX));
  29. wcex.cbSize = sizeof(WNDCLASSEX);
  30. wcex.hInstance = hInstance;
  31. wcex.lpszClassName = MSGPARENT_WINDOWCLASS;
  32. wcex.lpfnWndProc = (WNDPROC)MessageHelpWndProc;
  33. return RegisterClassEx(&wcex);
  34. }
  35. int HelpMessageBox(
  36. HINSTANCE hInst,
  37. HWND hWnd, // handle to owner window
  38. LPCTSTR lpText, // text in message box
  39. LPCTSTR lpCaption, // message box title
  40. UINT uType, // message box style
  41. LPTSTR szHelpLine
  42. )
  43. {
  44. if (!(uType & MB_HELP) || !szHelpLine)
  45. {
  46. return MessageBox(hWnd, lpText, lpCaption, uType);
  47. }
  48. else
  49. {
  50. HWND hWndParent;
  51. int iReturn;
  52. //
  53. // create a window which will process the help message
  54. //
  55. RegisterHelpMessageClass(hInst);
  56. hWndParent = CreateWindow(
  57. MSGPARENT_WINDOWCLASS,
  58. NULL,
  59. WS_OVERLAPPEDWINDOW,
  60. 0,
  61. 0,
  62. 0,
  63. 0,
  64. hWnd,
  65. NULL,
  66. hInst,
  67. szHelpLine
  68. );
  69. iReturn = MessageBox(hWndParent, lpText, lpCaption, uType);
  70. DestroyWindow(hWndParent);
  71. return iReturn;
  72. }
  73. }
  74. #pragma warning(pop)