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.

117 lines
3.2 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998
  4. *
  5. * TITLE: WIACSH.CPP
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 1/20/2000
  12. *
  13. * DESCRIPTION: Helper functions for context sensitive help
  14. *
  15. *******************************************************************************/
  16. #include "precomp.h"
  17. #pragma hdrstop
  18. #include "wiacsh.h"
  19. //
  20. // If the help ID is >= this number, it must be an item that lives in windows.hlp,
  21. // otherwise, it lives in whatever the WIA help file is called (currently camera.hlp)
  22. //
  23. #define MAX_WIA_HELP_ID 20000
  24. namespace WiaHelp
  25. {
  26. static LPCTSTR DetermineHelpFileName( HWND hWnd, const DWORD *pdwContextIds )
  27. {
  28. //
  29. // Can't happen, but still...
  30. //
  31. if (!pdwContextIds)
  32. {
  33. return WIA_SPECIFIC_HELP_FILE;
  34. }
  35. //
  36. // If it isn't a window, it isn't a standard id
  37. //
  38. if (!hWnd || !IsWindow(hWnd))
  39. {
  40. return WIA_SPECIFIC_HELP_FILE;
  41. }
  42. //
  43. // If it doesn't have a window id, it isn't a standard id either
  44. //
  45. LONG nWindowId = GetWindowLong( hWnd, GWL_ID );
  46. if (!nWindowId)
  47. {
  48. return WIA_SPECIFIC_HELP_FILE;
  49. }
  50. for (const DWORD *pdwCurr = pdwContextIds;*pdwCurr;pdwCurr+=2)
  51. {
  52. //
  53. // If this is the window ID we are looking for...
  54. //
  55. if (nWindowId == static_cast<LONG>(pdwCurr[0]))
  56. {
  57. //
  58. // return true if its help id is greater than or equal to the max legal id number for wia
  59. //
  60. return (pdwCurr[1] >= MAX_WIA_HELP_ID ? WIA_STANDARD_HELP_FILE : WIA_SPECIFIC_HELP_FILE);
  61. }
  62. }
  63. //
  64. // Not found
  65. //
  66. return WIA_SPECIFIC_HELP_FILE;
  67. }
  68. LRESULT HandleWmHelp( WPARAM wParam, LPARAM lParam, const DWORD *pdwContextIds )
  69. {
  70. if (pdwContextIds)
  71. {
  72. LPHELPINFO pHelpInfo = reinterpret_cast<LPHELPINFO>(lParam);
  73. if (pHelpInfo && pHelpInfo->iContextType == HELPINFO_WINDOW)
  74. {
  75. //
  76. // Call WinHelp
  77. //
  78. WinHelp(
  79. reinterpret_cast<HWND>(pHelpInfo->hItemHandle),
  80. DetermineHelpFileName( reinterpret_cast<HWND>(pHelpInfo->hItemHandle), pdwContextIds ),
  81. HELP_WM_HELP,
  82. reinterpret_cast<ULONG_PTR>(pdwContextIds)
  83. );
  84. }
  85. }
  86. return 0;
  87. }
  88. LRESULT HandleWmContextMenu( WPARAM wParam, LPARAM lParam, const DWORD *pdwContextIds )
  89. {
  90. if (pdwContextIds)
  91. {
  92. HWND hWnd = reinterpret_cast<HWND>(wParam);
  93. if (hWnd)
  94. {
  95. //
  96. // Call WinHelp
  97. //
  98. WinHelp(
  99. hWnd,
  100. DetermineHelpFileName( hWnd, pdwContextIds ),
  101. HELP_CONTEXTMENU,
  102. reinterpret_cast<ULONG_PTR>(pdwContextIds)
  103. );
  104. }
  105. }
  106. return 0;
  107. }
  108. } // End namespace WiaHelp