Leaked source code of windows server 2003
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.

118 lines
3.2 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1998 - 1998
  3. All rights reserved.
  4. Module Name:
  5. msgbox.hxx
  6. Abstract:
  7. Message box function with help button.
  8. Author:
  9. copied from nt\printscan\ui\printui code
  10. Revision History:
  11. --*/
  12. #ifndef _MSGBOX_HXX_
  13. #define _MSGBOX_HXX_
  14. #include "resource.h"
  15. typedef struct MSG_HLPMAP
  16. {
  17. UINT uIdMessage; // Mapped message in resouce file
  18. } *PMSG_HLPMAP;
  19. int DoHelpMessageBox(HWND hWndIn, LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt);
  20. int DoHelpMessageBox(HWND hWndIn, UINT iResourceID, UINT nType, UINT nIDPrompt);
  21. //
  22. // Callback function called when the help button is clicked.
  23. //
  24. typedef BOOL (WINAPI *pfHelpCallback)( HWND hwnd, PVOID pRefData );
  25. //
  26. // Message box function that can handle the help button with
  27. // a windows that does not have a known parent.
  28. //
  29. INT
  30. MessageBoxHelper(
  31. IN HWND hWnd,
  32. IN LPCTSTR pszMsg,
  33. IN LPCTSTR pszTitle,
  34. IN UINT uFlags,
  35. IN pfHelpCallback pCallBack = NULL, OPTIONAL
  36. IN PVOID RefData = NULL OPTIONAL
  37. );
  38. //
  39. // Dialog box helper class to catch the WM_HELP
  40. // message when there is a help button on
  41. // a message box.
  42. //
  43. class TMessageBoxDialog
  44. {
  45. public:
  46. TMessageBoxDialog(
  47. IN HWND hWnd,
  48. IN UINT uFlags,
  49. IN LPCTSTR pszTitle,
  50. IN LPCTSTR pszMsg,
  51. IN pfHelpCallback pCallback,
  52. IN PVOID pRefData
  53. ) : _hWnd( hWnd ),
  54. _uFlags( uFlags ),
  55. _pszTitle( pszTitle ),
  56. _pszMsg( pszMsg ),
  57. _pCallback( pCallback ),
  58. _pRefData( pRefData ),
  59. _iRetval( 0 )
  60. {};
  61. ~TMessageBoxDialog(VOID){};
  62. inline HWND& hDlg(){return _hDlg;}
  63. inline HWND const & hDlg() const{return _hDlg;}
  64. BOOL bSetText(LPCTSTR pszTitle){return SetWindowText( _hDlg, pszTitle );};
  65. VOID vForceCleanup(VOID){SetWindowLongPtr( _hDlg, DWLP_USER, 0L );};
  66. BOOL bValid(VOID) const{return TRUE;};
  67. INT iMessageBox(VOID)
  68. {
  69. _iRetval = 0;
  70. DialogBoxParam(_Module.GetResourceInstance(),MAKEINTRESOURCE(IDD_MESSAGE_BOX_DLG),_hWnd,TMessageBoxDialog::SetupDlgProc,(LPARAM)this);
  71. return _iRetval;
  72. };
  73. static INT_PTR CALLBACK SetupDlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
  74. protected:
  75. VOID vSetDlgMsgResult(LONG_PTR lResult){SetWindowLongPtr( _hDlg, DWLP_MSGRESULT, (LPARAM)lResult);};
  76. VOID vSetParentDlgMsgResult(LRESULT lResult){SetWindowLongPtr( GetParent( _hDlg ), DWLP_MSGRESULT, (LPARAM)lResult );};
  77. private:
  78. //
  79. // Copying and assignment are not defined.
  80. //
  81. TMessageBoxDialog(const TMessageBoxDialog &);
  82. TMessageBoxDialog & operator =(const TMessageBoxDialog &);
  83. BOOL bHandleMessage(IN UINT uMsg,IN WPARAM wParam,IN LPARAM lParam);
  84. HWND _hDlg;
  85. HWND _hWnd;
  86. UINT _uFlags;
  87. LPCTSTR _pszTitle;
  88. LPCTSTR _pszMsg;
  89. INT _iRetval;
  90. PVOID _pRefData;
  91. pfHelpCallback _pCallback;
  92. };
  93. #endif