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.

353 lines
5.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1994 - 1998
  3. All rights reserved.
  4. Module Name:
  5. GenWin.hxx
  6. Abstract:
  7. Generic window handler
  8. Author:
  9. Albert Ting (AlbertT) 21-May-1994
  10. Revision History:
  11. --*/
  12. #ifndef _GENWIN_HXX
  13. #define _GENWIN_HXX
  14. /********************************************************************
  15. Generic window class to transform windows into pseudo-objects.
  16. Normally, the wndprocs do not have any C++ objects associated
  17. with them (they are static functions; all instance data must be
  18. stored in HWND GetWindowLong data).
  19. This is a simple thunk that takes a message, looks up the object
  20. based on GetWindowLong( hwnd, GWL_USERDATA ) then call the object.
  21. In order to use this class, derive classes from this class then
  22. override the nHandleMessage virtual function. When your window
  23. receives a message, your derived class will get called from the
  24. virtual member function.
  25. ********************************************************************/
  26. class MGenericWin {
  27. SIGNATURE( 'genw' )
  28. ALWAYS_VALID
  29. SAFE_NEW
  30. public:
  31. MGenericWin(
  32. VOID
  33. );
  34. virtual
  35. ~MGenericWin(
  36. VOID
  37. );
  38. VAR( HWND, hwnd );
  39. BOOL
  40. bSetText(
  41. LPCTSTR pszTitle
  42. );
  43. VOID
  44. vForceCleanup(
  45. VOID
  46. );
  47. static
  48. LPARAM APIENTRY
  49. SetupWndProc(
  50. HWND hwnd,
  51. UINT uMsg,
  52. WPARAM wParam,
  53. LPARAM lParam
  54. );
  55. private:
  56. MGenericWin(
  57. const MGenericWin &
  58. );
  59. MGenericWin &
  60. operator =(
  61. const MGenericWin &
  62. );
  63. virtual
  64. LPARAM
  65. nHandleMessage(
  66. UINT uMsg,
  67. WPARAM wParam,
  68. LPARAM lParam
  69. ) = 0;
  70. static
  71. LPARAM APIENTRY
  72. ThunkWndProc(
  73. HWND hwnd,
  74. UINT uMsg,
  75. WPARAM wParam,
  76. LPARAM lParam);
  77. };
  78. /********************************************************************
  79. Generic class to transform property pages into pseudo-objects.
  80. Same as GenericWin except used for dialog boxes.
  81. ********************************************************************/
  82. class MGenericProp {
  83. SIGNATURE( 'genp' )
  84. ALWAYS_VALID
  85. SAFE_NEW
  86. public:
  87. MGenericProp(
  88. VOID
  89. );
  90. virtual
  91. ~MGenericProp(
  92. VOID
  93. );
  94. VAR( HWND, hDlg );
  95. BOOL
  96. bSetText(
  97. LPCTSTR pszTitle
  98. );
  99. VOID
  100. vForceCleanup(
  101. VOID
  102. );
  103. static
  104. INT_PTR APIENTRY
  105. SetupDlgProc(
  106. HWND hDlg,
  107. UINT uMsg,
  108. WPARAM wParam,
  109. LPARAM lParam
  110. );
  111. static
  112. UINT CALLBACK
  113. CallbackProc(
  114. HWND hDlg,
  115. UINT uMsg,
  116. LPPROPSHEETPAGE ppsp
  117. );
  118. protected:
  119. VOID
  120. vSetDlgMsgResult(
  121. LONG_PTR lResult
  122. );
  123. VOID
  124. vSetParentDlgMsgResult(
  125. LRESULT lResult
  126. );
  127. private:
  128. MGenericProp(
  129. const MGenericProp &
  130. );
  131. MGenericProp &
  132. operator =(
  133. const MGenericProp &
  134. );
  135. virtual
  136. BOOL
  137. bHandleMessage(
  138. UINT uMsg,
  139. WPARAM wParam,
  140. LPARAM lParam
  141. ) = 0;
  142. virtual
  143. BOOL
  144. bCreate(
  145. VOID
  146. );
  147. virtual
  148. VOID
  149. vDestroy(
  150. VOID
  151. );
  152. };
  153. /********************************************************************
  154. Generic class to transform dialog into pseudo-objects.
  155. Same as GenericWin except used for dialog boxes.
  156. ********************************************************************/
  157. class MGenericDialog {
  158. SIGNATURE( 'gend' )
  159. ALWAYS_VALID
  160. SAFE_NEW
  161. public:
  162. MGenericDialog(
  163. VOID
  164. );
  165. virtual
  166. ~MGenericDialog(
  167. VOID
  168. );
  169. VAR( HWND, hDlg );
  170. BOOL
  171. bSetText(
  172. LPCTSTR pszTitle
  173. );
  174. VOID
  175. vForceCleanup(
  176. VOID
  177. );
  178. static
  179. INT_PTR APIENTRY
  180. SetupDlgProc(
  181. HWND hDlg,
  182. UINT uMsg,
  183. WPARAM wParam,
  184. LPARAM lParam
  185. );
  186. protected:
  187. VOID
  188. vSetDlgMsgResult(
  189. LONG_PTR lResult
  190. );
  191. VOID
  192. vSetParentDlgMsgResult(
  193. LRESULT lResult
  194. );
  195. private:
  196. MGenericDialog(
  197. const MGenericDialog &
  198. );
  199. MGenericDialog &
  200. operator =(
  201. const MGenericDialog &
  202. );
  203. virtual
  204. BOOL
  205. bHandleMessage(
  206. UINT uMsg,
  207. WPARAM wParam,
  208. LPARAM lParam
  209. ) = 0;
  210. };
  211. /********************************************************************
  212. MSingletonWin
  213. Used to enforce a single window based on a printer name and type.
  214. (The name and type are composed to form a printer pidl.)
  215. Note: this class must be bRegisterWindowed and destroyed in
  216. the same thread--the one that owns the window.
  217. ********************************************************************/
  218. class MSingletonWin {
  219. SIGNATURE( 'siwn' )
  220. SAFE_NEW
  221. public:
  222. VAR( HWND, hwnd );
  223. VAR( TString, strPrinterName );
  224. VAR( BOOL, bModal );
  225. MSingletonWin(
  226. LPCTSTR pszPrinterName,
  227. HWND hwnd = NULL,
  228. BOOL bModal = FALSE
  229. );
  230. virtual
  231. ~MSingletonWin(
  232. VOID
  233. );
  234. BOOL
  235. bValid(
  236. VOID
  237. );
  238. BOOL
  239. bRegisterWindow(
  240. DWORD dwType
  241. );
  242. BOOL
  243. bIsWindowPresent(
  244. VOID
  245. );
  246. private:
  247. HANDLE _hClassPidl;
  248. //
  249. // Operator = and copy not defined.
  250. //
  251. MSingletonWin&
  252. operator=(
  253. MSingletonWin& rhs
  254. );
  255. MSingletonWin(
  256. MSingletonWin& rhs
  257. );
  258. };
  259. #endif