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.

427 lines
7.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995 - 1995.
  5. //
  6. // File: shrpage.hxx
  7. //
  8. // Contents: "Sharing" shell property page extension
  9. //
  10. // History: 6-Apr-95 BruceFo Created
  11. // 12-Jul-00 JonN fixed 140878, MSG_MULTIDEL debounce
  12. // 06-Oct-00 jeffreys Split CShareBase out of CSharingPropertyPage
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef __SHRPAGE_HXX__
  16. #define __SHRPAGE_HXX__
  17. class CShareInfo;
  18. void _MyShow( HWND hwndParent, INT idControl, BOOL fShow );
  19. class CShareBase : public IOleWindow
  20. {
  21. DECLARE_SIG;
  22. public:
  23. // IUnknown
  24. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  25. STDMETHODIMP_(ULONG) AddRef(void) ;
  26. STDMETHODIMP_(ULONG) Release(void);
  27. // IOleWindow
  28. STDMETHODIMP GetWindow(HWND *phwnd);
  29. STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
  30. //
  31. // Page callback function for delete
  32. //
  33. static
  34. UINT CALLBACK
  35. PageCallback(
  36. IN HWND hwnd,
  37. IN UINT uMsg,
  38. IN LPPROPSHEETPAGE ppsp
  39. );
  40. //
  41. // Main page dialog procedure: static
  42. //
  43. static
  44. INT_PTR CALLBACK
  45. DlgProcPage(
  46. HWND hWnd,
  47. UINT msg,
  48. WPARAM wParam,
  49. LPARAM lParam
  50. );
  51. //
  52. // constructor, destructor, 2nd phase constructor
  53. //
  54. CShareBase(
  55. IN PWSTR pszPath,
  56. IN BOOL bDialog // called as a dialog, not a property page?
  57. );
  58. virtual ~CShareBase();
  59. virtual HRESULT
  60. InitInstance(
  61. VOID
  62. );
  63. protected:
  64. //
  65. // Main page dialog procedure: non-static
  66. //
  67. virtual BOOL
  68. _PageProc(
  69. IN HWND hWnd,
  70. IN UINT msg,
  71. IN WPARAM wParam,
  72. IN LPARAM lParam
  73. );
  74. //
  75. // Window messages and notifications
  76. //
  77. virtual BOOL
  78. _OnInitDialog(
  79. IN HWND hwnd,
  80. IN HWND hwndFocus,
  81. IN LPARAM lInitParam
  82. )
  83. {
  84. return TRUE;
  85. }
  86. virtual BOOL
  87. _OnCommand(
  88. IN HWND hwnd,
  89. IN WORD wNotifyCode,
  90. IN WORD wID,
  91. IN HWND hwndCtl
  92. );
  93. virtual BOOL
  94. _OnNotify(
  95. IN HWND hwnd,
  96. IN int idCtrl,
  97. IN LPNMHDR phdr
  98. );
  99. virtual BOOL
  100. _OnPropertySheetNotify(
  101. IN HWND hwnd,
  102. IN LPNMHDR phdr
  103. );
  104. virtual BOOL
  105. _OnHelp(
  106. IN HWND hwnd,
  107. IN LPHELPINFO lphi
  108. )
  109. {
  110. return FALSE;
  111. }
  112. virtual BOOL
  113. _OnContextMenu(
  114. IN HWND hwnd,
  115. IN HWND hwndCtl,
  116. IN int xPos,
  117. IN int yPos
  118. )
  119. {
  120. return FALSE;
  121. }
  122. //
  123. // Other helper methods
  124. //
  125. virtual BOOL
  126. _ValidatePage(
  127. IN HWND hwnd
  128. )
  129. {
  130. return TRUE;
  131. }
  132. virtual BOOL
  133. _DoApply(
  134. IN HWND hwnd,
  135. IN BOOL bClose
  136. );
  137. virtual BOOL
  138. _DoCancel(
  139. IN HWND hwnd
  140. );
  141. VOID
  142. _MarkPageDirty(
  143. VOID
  144. );
  145. HRESULT
  146. _ConstructShareList(
  147. VOID
  148. );
  149. HRESULT
  150. _ConstructNewShareInfo(
  151. VOID
  152. );
  153. HWND
  154. _GetFrameWindow(
  155. VOID
  156. )
  157. {
  158. return GetParent(_hwndPage);
  159. }
  160. BOOL
  161. _ValidateNewShareName(
  162. VOID
  163. );
  164. VOID
  165. _CommitShares(
  166. IN BOOL bNotShared
  167. );
  168. //
  169. // Protected class variables
  170. //
  171. LONG _cRef;
  172. PWSTR _pszPath;
  173. HWND _hwndPage; // HWND to the property page
  174. BOOL _bDialog; // called as a dialog, not a property page?
  175. BOOL _bDirty; // Dirty flag: anything changed?
  176. // JonN 7/12/00 140878
  177. // I changed this from BOOL to ULONG, and started accessing it with
  178. // increment/decrement rather than set, to prevent it from being
  179. // cleared prematurely.
  180. ULONG _fInitializingPage; // JonN 7/11/00 140878
  181. BOOL _bNewShare;
  182. CShareInfo* _pInfoList; // doubly-linked circular w/dummy head node
  183. CShareInfo* _pReplaceList; // list of shares to delete: share names replaced with new shares.
  184. CShareInfo* _pCurInfo;
  185. ULONG _cShares; // count of shares, not incl. removed shares
  186. };
  187. class CSharingPropertyPage : public CShareBase
  188. {
  189. DECLARE_SIG;
  190. public:
  191. static
  192. LRESULT CALLBACK
  193. SizeWndProc(
  194. IN HWND hwnd,
  195. IN UINT wMsg,
  196. IN WPARAM wParam,
  197. IN LPARAM lParam
  198. );
  199. //
  200. // constructor, destructor
  201. //
  202. CSharingPropertyPage(
  203. IN PWSTR pszPath,
  204. IN BOOL bDialog // called as a dialog, not a property page?
  205. );
  206. ~CSharingPropertyPage();
  207. private:
  208. // Does the operating system support caching on this share?
  209. // This method initializes _bIsCachingSupported, if it is not already true
  210. bool
  211. IsCachingSupported(
  212. VOID
  213. );
  214. //
  215. // Main page dialog procedure: non-static
  216. //
  217. virtual BOOL
  218. _PageProc(
  219. IN HWND hWnd,
  220. IN UINT msg,
  221. IN WPARAM wParam,
  222. IN LPARAM lParam
  223. );
  224. //
  225. // Window messages and notifications
  226. //
  227. virtual BOOL
  228. _OnInitDialog(
  229. IN HWND hwnd,
  230. IN HWND hwndFocus,
  231. IN LPARAM lInitParam
  232. );
  233. virtual BOOL
  234. _OnCommand(
  235. IN HWND hwnd,
  236. IN WORD wNotifyCode,
  237. IN WORD wID,
  238. IN HWND hwndCtl
  239. );
  240. virtual BOOL
  241. _OnHelp(
  242. IN HWND hwnd,
  243. IN LPHELPINFO lphi
  244. );
  245. virtual BOOL
  246. _OnContextMenu(
  247. IN HWND hwnd,
  248. IN HWND hwndCtl,
  249. IN int xPos,
  250. IN int yPos
  251. );
  252. BOOL
  253. _OnPermissions(
  254. IN HWND hwnd
  255. );
  256. BOOL
  257. _OnRemove(
  258. IN HWND hwnd
  259. );
  260. BOOL
  261. _OnNewShare(
  262. IN HWND hwnd
  263. );
  264. BOOL
  265. _OnCaching(
  266. IN HWND hwnd
  267. );
  268. //
  269. // Other helper methods
  270. //
  271. VOID
  272. _InitializeControls(
  273. IN HWND hwnd
  274. );
  275. VOID
  276. _SetControlsToDefaults(
  277. IN HWND hwnd
  278. );
  279. VOID
  280. _SetFieldsFromCurrent(
  281. IN HWND hwnd
  282. );
  283. VOID
  284. _CacheMaxUses(
  285. IN HWND hwnd
  286. );
  287. VOID
  288. _HideControls(
  289. IN HWND hwnd,
  290. IN int cShares
  291. );
  292. VOID
  293. _EnableControls(
  294. IN HWND hwnd,
  295. IN BOOL bEnable
  296. );
  297. BOOL
  298. _ReadControls(
  299. IN HWND hwnd
  300. );
  301. VOID
  302. _SetControlsFromData(
  303. IN HWND hwnd,
  304. IN PWSTR pszPreferredSelection
  305. );
  306. virtual BOOL
  307. _ValidatePage(
  308. IN HWND hwnd
  309. );
  310. virtual BOOL
  311. _DoApply(
  312. IN HWND hwnd,
  313. IN BOOL bClose
  314. );
  315. virtual BOOL
  316. _DoCancel(
  317. IN HWND hwnd
  318. );
  319. VOID
  320. _MarkItemDirty(
  321. VOID
  322. );
  323. #if DBG == 1
  324. VOID
  325. Dump(
  326. IN PWSTR pszCaption
  327. );
  328. #endif // DBG == 1
  329. //
  330. // Private class variables
  331. //
  332. // JonN 7/12/00 140878
  333. // This is the ID of the radio button last selected,
  334. // so that we can "debounce" the MSG_MULTIDEL dialog.
  335. WORD _wIDSelected; // JonN 7/12/00 140878
  336. BOOL _bItemDirty; // Dirty flag: this item changed
  337. BOOL _bShareNameChanged;
  338. BOOL _bCommentChanged;
  339. BOOL _bUserLimitChanged;
  340. WORD _wMaxUsers;
  341. WNDPROC _pfnAllowProc;
  342. bool _bIsCachingSupported; // Does the operating system support caching on this share?
  343. };
  344. #endif // __SHRPAGE_HXX__