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.

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