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.

287 lines
7.3 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (C) Microsoft Corporation, 1997 - 1999
  4. Module Name:
  5. Dialog.h
  6. Abstract:
  7. Header file for the CIASDialog template class.
  8. Author:
  9. Michael A. Maguire 02/03/98
  10. Revision History:
  11. mmaguire 02/03/98 - abstracted from CAddClientDialog class
  12. --*/
  13. //////////////////////////////////////////////////////////////////////////////
  14. #if !defined(_IAS_DIALOG_H_)
  15. #define _IAS_DIALOG_H_
  16. //////////////////////////////////////////////////////////////////////////////
  17. // BEGIN INCLUDES
  18. //
  19. // where we can find what this class derives from:
  20. //
  21. #include <atlwin.h>
  22. //
  23. //
  24. // where we can find what this class has or uses:
  25. //
  26. //
  27. // END INCLUDES
  28. //////////////////////////////////////////////////////////////////////////////
  29. //=============================================================================
  30. // Global Help Table for many Dialog IDs
  31. //
  32. #include "hlptable.h"
  33. // works with ATL dialog implementation
  34. template < class T, bool bAutoDelete = TRUE>
  35. class CIASDialog : public CDialogImpl<T>
  36. {
  37. protected:
  38. const DWORD* m_pHelpTable;
  39. public:
  40. BEGIN_MSG_MAP( (CIASDialog<T,nIDD,bAutoDelete>) )
  41. MESSAGE_HANDLER( WM_CONTEXTMENU, OnContextHelp )
  42. MESSAGE_HANDLER( WM_HELP, OnF1Help )
  43. COMMAND_ID_HANDLER( IDC_BUTTON_HELP, OnHelp )
  44. MESSAGE_HANDLER( WM_NCDESTROY, OnFinalMessage )
  45. END_MSG_MAP()
  46. CIASDialog()
  47. {
  48. SET_HELP_TABLE(T::IDD);
  49. }
  50. //////////////////////////////////////////////////////////////////////////////
  51. /*++
  52. CAddClientDialog::OnF1Help
  53. You shouldn't need to override this method in your derived class.
  54. Just initialize your static m_dwHelpMap member variable appropriately.
  55. This is called in response to the WM_HELP Notify message.
  56. This message is sent when the user presses F1 or <Shift>-F1
  57. over an item or when the user clicks on the ? icon and then
  58. presses the mouse over an item.
  59. --*/
  60. //////////////////////////////////////////////////////////////////////////////
  61. LRESULT OnF1Help(
  62. UINT uMsg
  63. , WPARAM wParam
  64. , LPARAM lParam
  65. , BOOL& bHandled
  66. )
  67. {
  68. ATLTRACE(_T("# CIASDialog::OnF1Help\n"));
  69. // Check for preconditions:
  70. // None.
  71. HELPINFO* helpinfo = (HELPINFO*) lParam;
  72. if (helpinfo->iContextType == HELPINFO_WINDOW)
  73. {
  74. ::WinHelp(
  75. (HWND) helpinfo->hItemHandle,
  76. HELPFILE_NAME,
  77. HELP_WM_HELP,
  78. (DWORD_PTR)(void*) m_pHelpTable );
  79. }
  80. return TRUE;
  81. }
  82. //////////////////////////////////////////////////////////////////////////////
  83. /*++
  84. CAddClientDialog::OnContextHelp
  85. You shouldn't need to override this method in your derived class.
  86. Just initialize your static m_dwHelpMap member variable appropriately.
  87. This is called in response to the WM_CONTEXTMENU Notify message.
  88. This message is sent when the user right clicks over an item
  89. and then clicks "What's this?"
  90. --*/
  91. //////////////////////////////////////////////////////////////////////////////
  92. LRESULT OnContextHelp(
  93. UINT uMsg
  94. , WPARAM wParam
  95. , LPARAM lParam
  96. , BOOL& bHandled
  97. )
  98. {
  99. ATLTRACE(_T("# CIASDialog::OnContextHelp\n"));
  100. // Check for preconditions:
  101. // None.
  102. WinHelp(
  103. HELPFILE_NAME
  104. , HELP_CONTEXTMENU
  105. , (DWORD_PTR)(void*) m_pHelpTable
  106. );
  107. return TRUE;
  108. }
  109. /////////////////////////////////////////////////////////////////////////////
  110. /*++
  111. CIASDialog::OnHelp
  112. Remarks:
  113. Don't override this method in your derived class.
  114. Instead, override the GetHelpPath method.
  115. This implementation calls the HtmlHelp API call with the HH_DISPLAY_TOPIC
  116. parameter, supplying the correct path to the compressed HTML help
  117. file for our application. It calls our GetHelpPath
  118. method to get the string to pass in as the fourth parameter
  119. to the HtmlHelp call.
  120. This method is called when the user presses on the Help button of a
  121. property sheet.
  122. It is an override of atlsnap.h CSnapInPropertyPageImpl::OnHelp.
  123. --*/
  124. //////////////////////////////////////////////////////////////////////////////
  125. virtual LRESULT OnHelp(
  126. UINT uMsg
  127. , WPARAM wParam
  128. , HWND hwnd
  129. , BOOL& bHandled
  130. )
  131. {
  132. ATLTRACE(_T("# CIASDialog::OnHelp -- Don't override\n"));
  133. // Check for preconditions:
  134. HRESULT hr;
  135. WCHAR szHelpFilePath[IAS_MAX_STRING*2];
  136. // Use system API to get windows directory.
  137. UINT uiResult = GetWindowsDirectory( szHelpFilePath, IAS_MAX_STRING );
  138. if( uiResult <=0 || uiResult > IAS_MAX_STRING )
  139. {
  140. return E_FAIL;
  141. }
  142. WCHAR *szTempAfterWindowsDirectory = szHelpFilePath + lstrlen(szHelpFilePath);
  143. // Load the help file name. Note: IDS_HTMLHELP_FILE = "iasmmc.chm"
  144. int nLoadStringResult = LoadString( _Module.GetResourceInstance(), IDS_HTMLHELP_PATH, szTempAfterWindowsDirectory, IAS_MAX_STRING );
  145. if( nLoadStringResult <= 0 )
  146. {
  147. return TRUE;
  148. }
  149. lstrcat( szTempAfterWindowsDirectory, L"::/" );
  150. WCHAR * szHelpFilePathAfterFileName = szHelpFilePath + lstrlen(szHelpFilePath);
  151. hr = GetHelpPath( szHelpFilePathAfterFileName );
  152. if( FAILED( hr ) )
  153. {
  154. return TRUE;
  155. }
  156. MMCPropertyHelp( szHelpFilePath );
  157. return 0;
  158. }
  159. /////////////////////////////////////////////////////////////////////////////
  160. /*++
  161. CIASDialog::GetHelpPath
  162. Remarks:
  163. Override this method in your derived class.
  164. You should return the string with the relevant path within the
  165. compressed HTML file to get help for your property page.
  166. --*/
  167. //////////////////////////////////////////////////////////////////////////////
  168. virtual HRESULT GetHelpPath( LPTSTR szHelpPath )
  169. {
  170. ATLTRACE(_T("# CIASDialog::GetHelpPath -- override in your derived class\n"));
  171. // Check for preconditions:
  172. #ifdef UNICODE_HHCTRL
  173. // ISSUE: We seemed to have a problem with passing WCHAR's to the hhctrl.ocx
  174. // installed on this machine -- it appears to be non-unicode.
  175. lstrcpy( szHelpPath, _T("") );
  176. #else
  177. strcpy( (CHAR *) szHelpPath, "" );
  178. #endif
  179. return S_OK;
  180. }
  181. /////////////////////////////////////////////////////////////////////////////
  182. /*++
  183. CAddClientDialog::OnFinalMessage
  184. This will get called when the page is sent the WM_NCDESTROY message,
  185. which is an appropriate time to delete the class implementing this dialog.
  186. --*/
  187. //////////////////////////////////////////////////////////////////////////////
  188. LRESULT OnFinalMessage(
  189. UINT uMsg
  190. , WPARAM wParam
  191. , LPARAM lParam
  192. , BOOL& bHandled
  193. )
  194. {
  195. ATLTRACE(_T("# CIASDialog::OnFinalMessage\n"));
  196. // Check for preconditions:
  197. // None.
  198. if( bAutoDelete )
  199. {
  200. // Be very careful here -- if you just do "delete this"
  201. // then destruction for the object which derives from this template
  202. // class won't occur -- this was causing some smart pointers
  203. // in a derived class not to release.
  204. T * pT = static_cast<T*> ( this );
  205. delete pT;
  206. }
  207. return 0;
  208. }
  209. };
  210. #endif // _IAS_DIALOG_H_