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.

293 lines
9.3 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltdlg.hxx
  7. Dialog support for BLT
  8. This file depends on bltcons.h, bltwin.hxx, uibuffer.hxx,
  9. and billions of other files.
  10. FILE HISTORY
  11. RustanL 20-Nov-1990 Created
  12. RustanL 04-Mar-1991 Changed DIALOG_WINDOW::Process format
  13. beng 14-May-1991 Hacked for separate compilation
  14. terryk 28-Jul-1991 Added FilterMessage to DIALOG_WINDOW
  15. beng 30-Sep-1991 Added DLGLOAD declaration
  16. KeithMo 24-Mar-1992 Moved IDRESOURCE to BLTIDRES.HXX.
  17. KeithMo 07-Aug-1992 Redesigned help file management.
  18. KeithMo 13-Oct-1992 Moved PWND2HWND to BLTPWND.HXX.
  19. DavePr 03-Jun-2002 Fixing DLGPROC for Win64
  20. */
  21. #ifndef _BLT_HXX_
  22. #error "Don't include this file directly; instead, include it through blt.hxx"
  23. #endif // _BLT_HXX_
  24. #ifndef _BLTDLG_HXX_
  25. #define _BLTDLG_HXX_
  26. #include "bltwin.hxx"
  27. #include "bltevent.hxx"
  28. #include "bltpump.hxx"
  29. #include "bltidres.hxx"
  30. #include "bltpwnd.hxx"
  31. #include "uibuffer.hxx"
  32. DLL_CLASS DIALOG_WINDOW; // forward decl's
  33. DLL_CLASS DLGLOAD;
  34. DLL_CLASS ASSOCHWNDPDLG;
  35. // Define an OWNER_WINDOW attribute which keeps the dialog hidden
  36. #define OWIN_ATTR_HIDDEN ((DWORD)0x1)
  37. enum DLG_PROCESS_STATE
  38. {
  39. // Note. The following values are assumed to be in this order, i.e.,
  40. // their values should reflect the chronological move through the
  41. // states. DLG_PROCESS_STATE_ACTIVE is defined as 0 so as to increase
  42. // the efficiency of the message loop in DIALOG_WINDOW::Process.
  43. //
  44. DLG_PROCESS_STATE_INITIALIZING = -1,
  45. DLG_PROCESS_STATE_ACTIVE = 0,
  46. DLG_PROCESS_STATE_DISMISSED = 1
  47. };
  48. #if defined(UNICODE)
  49. #define DLG_CHAR_SET_DEFAULT FALSE // unicode build
  50. #else // !UNICODE
  51. #define DLG_CHAR_SET_DEFAULT TRUE // ansi build
  52. #endif // UNICODE
  53. /*************************************************************************
  54. NAME: DLGLOAD
  55. SYNOPSIS: Loads a dialog from an application resource or template
  56. INTERFACE:
  57. DLGLOAD() - ctor
  58. ~DLGLOAD() - ctor
  59. QueryHwnd() - returns window handle
  60. PARENT: BASE
  61. USES: IDRESOURCE
  62. CAVEATS:
  63. For the private use of DIALOG_WINDOW, really
  64. HISTORY:
  65. beng 30-Sep-1991 Created
  66. beng 01-Nov-1991 Uses IDRESOURCE; remove BUFFER ctor
  67. KeithMo 07-Feb-1993 Allow override of default charset.
  68. DavePr 03-Jun-2002 Fixing DLGPROC for Win64
  69. **************************************************************************/
  70. DLL_CLASS DLGLOAD: public BASE
  71. {
  72. private:
  73. HWND _hwnd;
  74. public:
  75. DLGLOAD( const IDRESOURCE & idrsrcDlg, HWND hwndOwner,
  76. DLGPROC dlgProc,
  77. BOOL fAnsiDialog );
  78. DLGLOAD( const BYTE * pbTemplate, UINT cbTemplate, HWND hwndOwner,
  79. DLGPROC dlgProc,
  80. BOOL fAnsiDialog );
  81. ~DLGLOAD();
  82. HWND QueryHwnd() const
  83. { return _hwnd; }
  84. };
  85. /*************************************************************************
  86. NAME: ASSOCHWNDPDLG
  87. SYNOPSIS: Associate a dialog-pointer with a window
  88. INTERFACE: HwndToPdlg()
  89. PARENT: ASSOCHWNDTHIS
  90. HISTORY:
  91. beng 30-Sep-1991 Created
  92. **************************************************************************/
  93. DLL_CLASS ASSOCHWNDPDLG: private ASSOCHWNDTHIS
  94. {
  95. NEWBASE(ASSOCHWNDTHIS)
  96. public:
  97. ASSOCHWNDPDLG( HWND hwnd, const DIALOG_WINDOW * pdlg )
  98. : ASSOCHWNDTHIS( hwnd, pdlg ) { }
  99. static DIALOG_WINDOW * HwndToPdlg( HWND hwnd )
  100. { return (DIALOG_WINDOW *)HwndToThis(hwnd); }
  101. };
  102. /********************************************************************
  103. NAME: DIALOG_WINDOW
  104. SYNOPSIS: Dialog window class
  105. INTERFACE:
  106. DIALOG_WINDOW() - constructor
  107. ~DIALOG_WINDOW() - destructor
  108. QueryRobustHwnd() - virtual replacement of the
  109. owner_window class
  110. Process() - do a callback to the Dialog winproc
  111. FilterMessage() - filter out the proper message type.
  112. Dismiss() - dismiss the dialog
  113. DismissMsg() - dismisses the dialog after presenting
  114. a message
  115. MayRun() - virtual callout; return FALSE to abort
  116. dialog after painted, but before run
  117. PARENT: OWNER_WINDOW, HAS_MESSAGE_PUMP
  118. USES: DLG_PROCESS_STATE, ASSOCHWNDPDLG,
  119. DLGLOAD, IDRESOURCE
  120. HISTORY:
  121. RustanL 20-Nov-1990 Created
  122. beng 14-May-1991 Added DlgProc member
  123. terryk 28-Jul-1991 Added FilterMessage function
  124. beng 30-Sep-1991 Win32 conversion
  125. beng 07-Oct-1991 Uses HAS_MESSAGE_PUMP
  126. beng 31-Oct-1991 Added dialog validation
  127. beng 01-Nov-1991 Uses IDRESOURCE; remove BUFFER ctor
  128. beng 30-Mar-1992 Added MayRun
  129. beng 18-May-1992 Added OnScrollBar{,Thumb} members
  130. KeithMo 07-Feb-1993 Allow override of default charset.
  131. JonN 03-Aug-1995 OnCtlColor
  132. DavePr 03-Jun-2002 Fixing DLGPROC for Win64
  133. ********************************************************************/
  134. DLL_CLASS DIALOG_WINDOW : public OWNER_WINDOW, public HAS_MESSAGE_PUMP
  135. {
  136. private:
  137. // _procinstDlg is the proc instance of BltDlgProc.
  138. // CODEWORK - should really be a static object.
  139. //
  140. //PROC_INSTANCE _procinstDlg;
  141. // This object loads the dialog from the named resource.
  142. //
  143. DLGLOAD _dlg;
  144. // This object lets the window find its pwnd when it is entered
  145. // from Win (which doesn't set up This pointers, etc.)
  146. //
  147. ASSOCHWNDPDLG _assocThis;
  148. // _prstate is DLG_PROCESS_STATE_INITIALIZING until Process
  149. // is called. Then, it turns DLG_PROCESS_STATE_ACTIVE. When Dismiss
  150. // is called, the state is set to DLG_PROCESS_STATE_DISMISSED, where
  151. // the state will stay until destruction.
  152. //
  153. DLG_PROCESS_STATE _prstate;
  154. // _usRetVal indicates the return value of the dialog. Its value
  155. // is defined only if _prstate == DLG_PROCESS_STATE_DISMISSED.
  156. //
  157. UINT _nRetVal;
  158. // Respond to a request for help. This works in two phases:
  159. // answer initial control request, and actually launch the help.
  160. //
  161. BOOL OnHelp();
  162. VOID LaunchHelp();
  163. // Validate each control in the dialog.
  164. //
  165. APIERR Validate();
  166. // Layer over ASSOCHWNDPDLG: adds caching of most recent
  167. //
  168. static DIALOG_WINDOW * HwndToPwnd( HWND hwnd );
  169. protected:
  170. DIALOG_WINDOW( const BYTE * pbTemplate,
  171. UINT cbTemplate,
  172. HWND hwndOwner,
  173. BOOL fAnsiDialog = DLG_CHAR_SET_DEFAULT );
  174. // Client-defined callbacks.
  175. virtual BOOL OnCommand( const CONTROL_EVENT & event );
  176. virtual BOOL OnOK();
  177. virtual BOOL OnCancel();
  178. virtual BOOL OnTimer( const TIMER_EVENT & event );
  179. virtual BOOL OnScrollBar( const SCROLL_EVENT & );
  180. virtual BOOL OnScrollBarThumb( const SCROLL_THUMB_EVENT & );
  181. virtual BOOL OnDlgActivation( const ACTIVATION_EVENT & );
  182. virtual BOOL OnDlgDeactivation( const ACTIVATION_EVENT & );
  183. // JonN 8/3/95 This can be used to set the background color of
  184. // controls to other than the default, for example to
  185. // change the default background color for a static text control
  186. // to the same background as for an edit control. The virtual
  187. // redefinition may return an HBRUSH or may change *pmsgid; if it
  188. // returns NULL, be sure to call down to the original, otherwise
  189. // CONTROL_WINDOW::OnCtlColor will not be called.
  190. virtual HBRUSH OnCtlColor( HDC hdc, HWND hwnd, UINT * pmsgid );
  191. // JonN 8/8/95 This can be used to respond to changes in the
  192. // system colors.
  193. virtual VOID OnSysColorChange();
  194. virtual VOID OnControlError( CID cid, APIERR err );
  195. virtual VOID OnValidationError( CID cid, APIERR err );
  196. virtual const TCHAR * QueryHelpFile( ULONG nHelpContext );
  197. virtual ULONG QueryHelpContext();
  198. VOID Dismiss( UINT nRetVal = 0 );
  199. VOID DismissMsg( MSGID msgid, UINT nRetVal = 0 );
  200. virtual BOOL IsValid();
  201. // Implementations supplied for HAS_MESSAGE_PUMP controls
  202. virtual BOOL FilterMessage( MSG * );
  203. virtual BOOL IsPumpFinished();
  204. // Another client-defined callback
  205. virtual BOOL MayRun();
  206. public:
  207. DIALOG_WINDOW( const IDRESOURCE & idrsrcDialog,
  208. const PWND2HWND & wndOwner,
  209. BOOL fAnsiDialog = DLG_CHAR_SET_DEFAULT );
  210. ~DIALOG_WINDOW();
  211. // Replacement (virtual) from the OWNER_WINDOW class
  212. //
  213. virtual HWND QueryRobustHwnd() const;
  214. APIERR Process( UINT * pnRetVal = NULL ); // UINT variant
  215. APIERR Process( BOOL * pfRetVal ); // BOOL variant
  216. static INT_PTR DlgProc( HWND hdlg, UINT nMsg, WPARAM wParam, LPARAM lParam );
  217. };
  218. #endif // _BLTDLG_HXX_ - end of file