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.

297 lines
9.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. bltclwin.hxx
  7. Client window class for BLT - definition
  8. A "client window" is any window into which the app may draw
  9. directly, as opposed to those windows into which BLT does the drawing
  10. for the app, such as DIALOG.
  11. Client windows inherit from OWNER_WINDOW, since they may receive
  12. notifications from owned controls.
  13. FILE HISTORY:
  14. beng 14-Mar-1991 Created
  15. beng 14-May-1991 Made dependent on blt.hxx
  16. beng 04-Oct-1991 Relocated type MID to bltglob
  17. */
  18. #ifndef _BLT_HXX_
  19. #error "Don't include this file directly; instead, include it through blt.hxx"
  20. #endif // _BLT_HXX_
  21. #ifndef _BLTCLWIN_HXX_
  22. #define _BLTCLWIN_HXX_
  23. #include "base.hxx"
  24. #include "bltevent.hxx"
  25. #include "bltidres.hxx"
  26. // forward refs
  27. //
  28. DLL_CLASS NLS_STR;
  29. DLL_CLASS CLIENT_WINDOW;
  30. /*************************************************************************
  31. NAME: ASSOCHWNDPWND
  32. SYNOPSIS: Associate a window-pointer with a window
  33. INTERFACE: HwndToPwnd()
  34. PARENT: ASSOCHWNDTHIS
  35. HISTORY:
  36. beng 30-Sep-1991 Created
  37. **************************************************************************/
  38. DLL_CLASS ASSOCHWNDPWND: private ASSOCHWNDTHIS
  39. {
  40. NEWBASE(ASSOCHWNDTHIS)
  41. public:
  42. ASSOCHWNDPWND( HWND hwnd, const CLIENT_WINDOW * pwnd )
  43. : ASSOCHWNDTHIS( hwnd, pwnd ) { }
  44. static CLIENT_WINDOW * HwndToPwnd( HWND hwnd )
  45. { return (CLIENT_WINDOW *)HwndToThis(hwnd); }
  46. };
  47. /*************************************************************************
  48. NAME: CLIENT_WINDOW
  49. SYNOPSIS: Drawing window, with explicit control over responses
  50. to owned controls. A client window may
  51. INTERFACE:
  52. CaptureMouse() - captures all mouse input for this window
  53. ReleaseMouse() - releases the captured mouse
  54. IsMinimized() - returns TRUE if window is iconized
  55. IsMaximized() - returns TRUE if window is maximized
  56. A client window defines most of its behavior through
  57. notification methods, which are invoked in response to
  58. system actions or local events. A client of the class
  59. should supply definitions for these classes as appropriate
  60. where the default behavior doesn't suffice.
  61. All notifications return a Boolean value "fHandled,"
  62. which should be TRUE to suppress system default behavior.
  63. PARENT: OWNER_WINDOW
  64. USES: ASSOCHWNDPWND, EVENT
  65. CAVEATS:
  66. NOTES:
  67. This class needs more internal doc.
  68. HISTORY:
  69. beng 14-Mar-1991 Created
  70. beng 14-May-1991 Renamed several methods; added
  71. OnUserMessage
  72. beng 15-May-1991 Pruned constructor
  73. beng 08-Jul-1991 Changed return of DispatchMessage
  74. beng 18-Sep-1991 Changed return of Init
  75. beng 30-Sep-1991 Win32 conversion
  76. beng 13-Feb-1992 Added IsMinimized, IsMaximized; relocated
  77. Repaint, RepaintNow to WINDOW ancestor
  78. KeithMo 14-Oct-1992 Relocated OnUserMessage to OWNER_WINDOW.
  79. **************************************************************************/
  80. DLL_CLASS CLIENT_WINDOW : public OWNER_WINDOW
  81. {
  82. private:
  83. // This object lets the window find its pwnd when it is entered
  84. // from Win (which doesn't set up This pointers, etc.)
  85. //
  86. ASSOCHWNDPWND _assocThis;
  87. static CLIENT_WINDOW * HwndToPwnd( HWND hwnd )
  88. { return ASSOCHWNDPWND::HwndToPwnd(hwnd); }
  89. static const TCHAR * _pszClassName; // used by Init
  90. protected:
  91. CLIENT_WINDOW();
  92. // Following ctor form is dll-client safe because it's protected,
  93. // and so inaccessible to the apps.
  94. CLIENT_WINDOW( ULONG flStyle,
  95. const WINDOW * pwndOwner,
  96. const TCHAR * pszClassName = _pszClassName );
  97. virtual LRESULT DispatchMessage( const EVENT & );
  98. virtual BOOL OnPaintReq();
  99. virtual BOOL OnActivation( const ACTIVATION_EVENT & );
  100. virtual BOOL OnDeactivation( const ACTIVATION_EVENT & );
  101. virtual BOOL OnResize( const SIZE_EVENT & );
  102. virtual BOOL OnMove( const MOVE_EVENT & );
  103. virtual BOOL OnCloseReq();
  104. virtual BOOL OnDestroy();
  105. virtual BOOL OnKeyDown( const VKEY_EVENT & );
  106. virtual BOOL OnKeyUp( const VKEY_EVENT & );
  107. virtual BOOL OnChar( const CHAR_EVENT & );
  108. virtual BOOL OnMouseMove( const MOUSE_EVENT & );
  109. virtual BOOL OnLMouseButtonDown( const MOUSE_EVENT & );
  110. virtual BOOL OnLMouseButtonUp( const MOUSE_EVENT & );
  111. virtual BOOL OnLMouseButtonDblClick( const MOUSE_EVENT & );
  112. #if 0
  113. // following methods elided to reduce vtable congestion
  114. virtual BOOL OnMMouseButtonDown( const MOUSE_EVENT & );
  115. virtual BOOL OnMMouseButtonUp( const MOUSE_EVENT & );
  116. virtual BOOL OnMMouseButtonDblClick( const MOUSE_EVENT & );
  117. virtual BOOL OnRMouseButtonDown( const MOUSE_EVENT & );
  118. virtual BOOL OnRMouseButtonUp( const MOUSE_EVENT & );
  119. virtual BOOL OnRMouseButtonDblClick( const MOUSE_EVENT & );
  120. #endif
  121. virtual BOOL OnFocus( const FOCUS_EVENT & );
  122. virtual BOOL OnDefocus( const FOCUS_EVENT & );
  123. virtual BOOL OnTimer( const TIMER_EVENT & );
  124. virtual BOOL OnCommand( const CONTROL_EVENT & );
  125. virtual BOOL OnClick( const CONTROL_EVENT & );
  126. virtual BOOL OnDblClick( const CONTROL_EVENT & );
  127. virtual BOOL OnChange( const CONTROL_EVENT & );
  128. virtual BOOL OnSelect( const CONTROL_EVENT & );
  129. virtual BOOL OnEnter( const CONTROL_EVENT & );
  130. virtual BOOL OnDropDown( const CONTROL_EVENT & );
  131. #if 0 // unimplemented
  132. virtual BOOL OnScrollBar( const SCROLL_EVENT & );
  133. virtual BOOL OnScrollBarThumb( const SCROLL_THUMB_EVENT & );
  134. #endif
  135. virtual BOOL OnOther( const EVENT & );
  136. public:
  137. static APIERR Init();
  138. static VOID Term();
  139. VOID CaptureMouse();
  140. VOID ReleaseMouse();
  141. BOOL IsMinimized() const
  142. { return ::IsIconic(QueryHwnd()); }
  143. BOOL IsMaximized() const
  144. { return ::IsZoomed(QueryHwnd()); }
  145. // Replacement (virtual) from the OWNER_WINDOW class
  146. //
  147. virtual HWND QueryRobustHwnd() const;
  148. static LRESULT WndProc( HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
  149. };
  150. /*************************************************************************
  151. NAME: APP_WINDOW
  152. SYNOPSIS: Main application window with menu and frame controls.
  153. INTERFACE:
  154. QueryIcon() - return a HICON of the current window icon
  155. SetIcon() - set that icon from a resource name
  156. QueryMenu() - return a HMENU of the current app menu
  157. SetMenu() - set that menu from a named resource
  158. PARENT: CLIENT_WINDOW
  159. USES: QMINMAX_EVENT, MENU_EVENT, MENUITEM_EVENT, SYSCHANGE_EVENT,
  160. IDRESOURCE
  161. HISTORY:
  162. beng 14-Mar-1991 Created
  163. beng 15-May-1991 Made thoroughly modern
  164. beng 17-May-1991 Added OnMenuCommand member
  165. beng 08-Jul-1991 Implemented icons; withdrew redundant
  166. Query/SetCaption members
  167. rustanl 05-Sep-1991 Added Close
  168. beng 03-Aug-1992 SetIcon and Menu use IDRESOURCE
  169. **************************************************************************/
  170. DLL_CLASS APP_WINDOW: public CLIENT_WINDOW
  171. {
  172. private:
  173. HMENU _hmenu;
  174. HICON _hicon;
  175. BOOL DrawIcon();
  176. protected:
  177. APP_WINDOW(XYPOINT xyPos,
  178. XYDIMENSION dxySize,
  179. const NLS_STR & nlsTitle,
  180. const IDRESOURCE & idIcon,
  181. const IDRESOURCE & idMenu );
  182. APP_WINDOW(const NLS_STR & nlsTitle,
  183. const IDRESOURCE & idIcon,
  184. const IDRESOURCE & idMenu );
  185. ~APP_WINDOW();
  186. // Notification methods
  187. virtual BOOL OnMenuInit( const MENU_EVENT & );
  188. virtual BOOL OnMenuSelect( const MENUITEM_EVENT & );
  189. virtual BOOL OnMenuCommand( MID mid );
  190. virtual BOOL OnSystemChange( const SYSCHANGE_EVENT & );
  191. virtual BOOL MayRestore();
  192. virtual BOOL MayShutdown();
  193. virtual VOID OnShutdown();
  194. virtual BOOL OnQMinMax( QMINMAX_EVENT & );
  195. // Notifications redefined from parent
  196. virtual LRESULT DispatchMessage( const EVENT & );
  197. virtual BOOL OnCloseReq();
  198. virtual BOOL OnPaintReq();
  199. public:
  200. HMENU QueryMenu() const;
  201. BOOL SetMenu( const IDRESOURCE & idMenu );
  202. HICON QueryIcon() const;
  203. BOOL SetIcon( const IDRESOURCE & idIcon );
  204. APIERR GetPlacement( WINDOWPLACEMENT * pwp ) const;
  205. APIERR SetPlacement( const WINDOWPLACEMENT * pwp ) const;
  206. APIERR DrawMenuBar( VOID ) const;
  207. VOID Close();
  208. };
  209. #endif // _BLTCLWIN_HXX_ - end of file