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.

132 lines
3.2 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: modaldlg.h
  4. //
  5. // Module: CMDIAL32.DLL and CMMON32.EXE
  6. //
  7. // Synopsis: Definition of the classes CWindowWithHelp, CModalDlg
  8. //
  9. // Copyright (c) 1998-1999 Microsoft Corporation
  10. //
  11. // Author: fengsun Created 02/17/98
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef MODALDLG_H
  15. #define MODALDLG_H
  16. #include "CmDebug.h"
  17. //+---------------------------------------------------------------------------
  18. //
  19. // class CWindowWithHelp
  20. //
  21. // Description: A general window class that has context help
  22. //
  23. // History: fengsun Created 10/30/97
  24. //
  25. //----------------------------------------------------------------------------
  26. class CWindowWithHelp
  27. {
  28. public:
  29. CWindowWithHelp(const DWORD* pHelpPairs, const TCHAR* lpszHelpFile = NULL) ;
  30. ~CWindowWithHelp();
  31. HWND GetHwnd() const { return m_hWnd;}
  32. void SetHelpFileName(const TCHAR* lpszHelpFile);
  33. protected:
  34. HWND m_hWnd;
  35. const DWORD* m_pHelpPairs; // pairs of <resource ID, help ID>
  36. LPTSTR m_lpszHelpFile; // the help file name
  37. void OnHelp(const HELPINFO* pHelpInfo); // WM_HELP
  38. BOOL OnContextMenu( HWND hWnd, POINT& pos ); // WM_CONTEXTMENU
  39. BOOL HasContextHelp(HWND hWndCtrl) const;
  40. public:
  41. #ifdef DEBUG
  42. void AssertValid()
  43. {
  44. MYDBGASSERT(m_hWnd == NULL || IsWindow(m_hWnd));
  45. }
  46. #endif
  47. };
  48. //+---------------------------------------------------------------------------
  49. //
  50. // class CModalDlg
  51. //
  52. // Description: A general modal dialog class
  53. //
  54. // History: fengsun Created 10/30/97
  55. //
  56. //----------------------------------------------------------------------------
  57. class CModalDlg :public CWindowWithHelp
  58. {
  59. public:
  60. CModalDlg(const DWORD* pHelpPairs = NULL, const TCHAR* lpszHelpFile = NULL)
  61. : CWindowWithHelp(pHelpPairs, lpszHelpFile){};
  62. //
  63. // Create the dialog box
  64. //
  65. INT_PTR DoDialogBox(HINSTANCE hInstance,
  66. LPCTSTR lpTemplateName,
  67. HWND hWndParent);
  68. INT_PTR DoDialogBox(HINSTANCE hInstance,
  69. DWORD dwTemplateId,
  70. HWND hWndParent);
  71. virtual BOOL OnInitDialog(); // WM_INITDIALOG
  72. virtual void OnOK(); // WM_COMMAND, IDOK
  73. virtual void OnCancel(); // WM_COMMAND, IDCANCEL
  74. virtual DWORD OnOtherCommand(WPARAM wParam, LPARAM lParam );
  75. virtual DWORD OnOtherMessage(UINT uMsg, WPARAM wParam, LPARAM lParam );
  76. protected:
  77. static BOOL CALLBACK ModalDialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam, LPARAM lParam);
  78. };
  79. //
  80. // Inline functions
  81. //
  82. inline INT_PTR CModalDlg::DoDialogBox(HINSTANCE hInstance, DWORD dwTemplateId, HWND hWndParent)
  83. {
  84. return DoDialogBox(hInstance, (LPCTSTR)ULongToPtr(dwTemplateId), hWndParent);
  85. }
  86. inline BOOL CModalDlg::OnInitDialog()
  87. {
  88. //
  89. // set the default keyboard focus
  90. //
  91. return TRUE;
  92. }
  93. inline void CModalDlg::OnOK()
  94. {
  95. EndDialog(m_hWnd, IDOK);
  96. }
  97. inline void CModalDlg::OnCancel()
  98. {
  99. EndDialog(m_hWnd, IDCANCEL);
  100. }
  101. inline DWORD CModalDlg::OnOtherCommand(WPARAM , LPARAM )
  102. {
  103. return FALSE;
  104. }
  105. inline DWORD CModalDlg::OnOtherMessage(UINT , WPARAM , LPARAM )
  106. {
  107. return FALSE;
  108. }
  109. #endif