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.

479 lines
14 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: dialogs.h
  4. //
  5. // Module: CMDIAL32.DLL
  6. //
  7. // Synopsis: This header contains definitions for the dialog UI code.
  8. //
  9. // Copyright (c) 1996-1999 Microsoft Corporation
  10. //
  11. // Author: quintinb Created Header 08/17/99
  12. //
  13. //+----------------------------------------------------------------------------
  14. #include "cm_misc.h"
  15. #include "ModalDlg.h"
  16. //+---------------------------------------------------------------------------
  17. //
  18. // class CInetSignInDlg
  19. //
  20. // Description: The standalone "Internet Sign-In" dlg
  21. //
  22. // History: fengsun Created 10/30/97
  23. //
  24. //----------------------------------------------------------------------------
  25. class CInetSignInDlg : public CModalDlg
  26. {
  27. public:
  28. CInetSignInDlg(ArgsStruct * pArgs);
  29. virtual void OnOK();
  30. virtual BOOL OnInitDialog();
  31. virtual DWORD OnOtherCommand(WPARAM wParam, LPARAM lParam );
  32. protected:
  33. ArgsStruct *m_pArgs; // pointer to the huge structure
  34. static const DWORD m_dwHelp[]; // help id pairs
  35. };
  36. inline CInetSignInDlg::CInetSignInDlg(ArgsStruct * pArgs) : CModalDlg(m_dwHelp, pArgs->pszHelpFile)
  37. {
  38. MYDBGASSERT(pArgs);
  39. m_pArgs = pArgs;
  40. }
  41. //+---------------------------------------------------------------------------
  42. //
  43. // class CPropertiesPage
  44. //
  45. // Description: A general properties property page class
  46. //
  47. // History: fengsun Created 10/30/97
  48. //
  49. //----------------------------------------------------------------------------
  50. class CPropertiesPage : public CWindowWithHelp
  51. {
  52. friend class CPropertiesSheet;
  53. public:
  54. CPropertiesPage(UINT nIDTemplate, const DWORD* pHelpPairs = NULL,
  55. const TCHAR* lpszHelpFile = NULL);
  56. CPropertiesPage(LPCTSTR lpszTemplateName, const DWORD* pHelpPairs = NULL,
  57. const TCHAR* lpszHelpFile = NULL);
  58. virtual BOOL OnInitDialog(); // WM_INITDIALOG
  59. virtual DWORD OnCommand(WPARAM wParam, LPARAM lParam ); // WM_COMMAND
  60. virtual BOOL OnSetActive(); // PSN_SETACTIVE
  61. virtual BOOL OnKillActive(); // PSN_KILLACTIVE
  62. virtual void OnApply(); // PSN_APPLY
  63. virtual void OnReset(); // PSN_RESET
  64. // If the derived class need to overwrite thses help function, make this virtual
  65. void OnPsnHelp(HWND hwndFrom, UINT_PTR idFrom); // PSN_HELP
  66. virtual DWORD OnOtherMessage(UINT uMsg, WPARAM wParam, LPARAM lParam );
  67. protected:
  68. LPCTSTR m_pszTemplate; // the resource ID
  69. protected:
  70. void SetPropSheetResult(DWORD dwResult);
  71. static INT_PTR CALLBACK PropPageProc(HWND hwndDlg,UINT uMsg,WPARAM wParam, LPARAM lParam);
  72. };
  73. //+---------------------------------------------------------------------------
  74. //
  75. // class CPropertiesSheet
  76. //
  77. // Description: The properties property page class
  78. //
  79. // History: fengsun Created 10/30/97
  80. //
  81. //----------------------------------------------------------------------------
  82. class CPropertiesSheet
  83. {
  84. public:
  85. CPropertiesSheet(ArgsStruct *pArgs);
  86. void AddPage(const CPropertiesPage* pPage);
  87. void AddExternalPage(PROPSHEETPAGE *pPsp);
  88. BOOL HasPage(const CPropertiesPage* pPage) const;
  89. int DoPropertySheet(HWND hWndParent, LPTSTR pszCaption, HINSTANCE hInst);
  90. protected:
  91. enum {MAX_PAGES = 6};
  92. enum {CPROP_SHEET_TYPE_INTERNAL = 0,
  93. CPROP_SHEET_TYPE_EXTERNAL = 1};
  94. PROPSHEETHEADER m_psh; // propertysheet header
  95. PROPSHEETPAGE m_pages[MAX_PAGES]; // property pages array
  96. DWORD m_adwPageType[MAX_PAGES]; // property page type
  97. UINT m_numPages; // number of property pages
  98. ArgsStruct *m_pArgs;
  99. public:
  100. TCHAR* m_lpszServiceName; // the profile name, used as the mutex name for OK
  101. protected:
  102. static LRESULT CALLBACK SubClassPropSheetProc(HWND hwnd, UINT uMsg, WPARAM wParam,LPARAM lParam);
  103. static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam);
  104. static WNDPROC m_pfnOrgPropSheetProc; // Original propertysheet wnd proc before subclass
  105. // pointer to the property sheet which can be accessed by static function.
  106. // Not works quite safe, if there are multiple instance of CPropertySheet.
  107. // Should be protected by CriticalSection.
  108. static CPropertiesSheet* m_pThis;
  109. };
  110. //
  111. // Inline functions
  112. //
  113. inline CPropertiesSheet::CPropertiesSheet(ArgsStruct *pArgs)
  114. {
  115. m_pArgs = pArgs;
  116. MYDBGASSERT(m_pArgs);
  117. m_numPages = 0;
  118. ZeroMemory((LPVOID)m_adwPageType, sizeof(m_adwPageType));
  119. }
  120. inline void CPropertiesPage::SetPropSheetResult(DWORD dwResult)
  121. {
  122. SetWindowLongU(m_hWnd, DWLP_MSGRESULT, (LONG_PTR)dwResult);
  123. }
  124. class CInetPage;
  125. //+---------------------------------------------------------------------------
  126. //
  127. // class CGeneralPage
  128. //
  129. // Description: A dialing property page class
  130. //
  131. // History: fengsun Created 10/30/97
  132. //
  133. //----------------------------------------------------------------------------
  134. class CGeneralPage :public CPropertiesPage
  135. {
  136. public:
  137. CGeneralPage(ArgsStruct* pArgs, UINT nIDTemplate);
  138. void SetEventListener(CInetPage* pEventListener) {m_pEventListener = pEventListener;}
  139. protected:
  140. virtual BOOL OnInitDialog();
  141. virtual DWORD OnCommand(WPARAM wParam, LPARAM lParam );
  142. virtual void OnApply();
  143. virtual BOOL OnKillActive(); // PSN_KILLACTIVE
  144. void OnDialingProperties();
  145. void OnPhoneBookButton(UINT nPhoneIdx);
  146. BOOL DisplayMungedPhone(UINT uiPhoneIdx);
  147. BOOL CheckTapi(TapiLinkageStruct *ptlsTapiLink, HINSTANCE hInst);
  148. DWORD InitDialInfo();
  149. void EnableDialupControls(BOOL fEnable);
  150. void ClearUseDialingRules(int iPhoneNdx);
  151. void UpdateDialingRulesButton(void);
  152. void UpdateNumberDescription(int nPhoneIdx, LPCTSTR pszDesc);
  153. //
  154. // Access Points
  155. //
  156. void UpdateForNewAccessPoint(BOOL fSetPhoneNumberDescriptions);
  157. BOOL AccessPointInfoChanged();
  158. void DeleteAccessPoint();
  159. void AddNewAPToReg(LPTSTR pszNewAPName, BOOL fRefreshUiWwithCurrentValues);
  160. virtual DWORD OnOtherMessage(UINT uMsg, WPARAM wParam, LPARAM lParam );
  161. enum {WM_INITDIALINFO = WM_USER+1}; // message posted to itself to load dial info
  162. protected:
  163. ArgsStruct* m_pArgs; // pointer to the huge structure
  164. PHONEINFO m_DialInfo[MAX_PHONE_NUMBERS]; // local copy of dial info,
  165. UINT m_NumPhones; // Number of phone # to display (1 for connectoid dialing)
  166. TCHAR m_szDeviceName[RAS_MaxDeviceName+1]; // modem device name
  167. TCHAR m_szDeviceType[RAS_MaxDeviceName+1]; // device type
  168. CInetPage* m_pEventListener; // the object to receive event on this page
  169. BOOL m_bDialInfoInit; // whether we have loaded dialing information
  170. static const DWORD m_dwHelp[]; // help id pairs
  171. BOOL m_bAPInfoChanged; // whether Access point information has changed
  172. protected:
  173. static LRESULT CALLBACK SubClassEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  174. static WNDPROC m_pfnOrgEditWndProc; // the original phone # edit window proc for subclassing
  175. };
  176. //+---------------------------------------------------------------------------
  177. //
  178. // class CInetPage
  179. //
  180. // Description: The internet sign-on property page class
  181. //
  182. // History: fengsun Created 10/30/97
  183. //
  184. //----------------------------------------------------------------------------
  185. class CInetPage :public CPropertiesPage
  186. {
  187. public:
  188. CInetPage(ArgsStruct* pArgs, UINT nIDTemplate);
  189. void OnGeneralPageKillActive(BOOL fDirect);
  190. //
  191. // The following functions are shared with CInetSignInDlg,
  192. // For simplicity, we makes them static member function of class CInetPage
  193. // instead of having another class
  194. //
  195. static void OnInetInit(HWND hwndDlg, ArgsStruct *pArgs);
  196. static void OnInetOk(HWND hwndDlg, ArgsStruct *pArgs);
  197. static void AdjustSavePasswordCheckBox(HWND hwndCheckBox, BOOL fEmptyPassword,
  198. BOOL fDialAutomatically, BOOL fPasswordOptional);
  199. protected:
  200. virtual BOOL OnInitDialog();
  201. virtual DWORD OnCommand(WPARAM wParam, LPARAM lParam );
  202. virtual void OnApply();
  203. virtual BOOL OnSetActive(); // PSN_SETACTIVE
  204. protected:
  205. ArgsStruct* m_pArgs;// pointer to the huge structure
  206. BOOL m_fDirect; // the current connection type selection in General page
  207. BOOL m_fPasswordOptional; // whether the PasswordOptional flag is set in
  208. // the profile
  209. static const DWORD m_dwHelp[]; // help id pairs
  210. };
  211. //+---------------------------------------------------------------------------
  212. //
  213. // class COptionPage
  214. //
  215. // Description: The options property page class
  216. //
  217. // History: fengsun Created 10/30/97
  218. //
  219. //----------------------------------------------------------------------------
  220. class COptionPage :public CPropertiesPage
  221. {
  222. public:
  223. COptionPage(ArgsStruct* pArgs, UINT nIDTemplate);
  224. protected:
  225. virtual BOOL OnInitDialog();
  226. virtual DWORD OnCommand(WPARAM wParam, LPARAM lParam ); // WM_COMMAND
  227. virtual void OnApply();
  228. void InitIdleTimeList(HWND hwndList, DWORD dwMinutes);
  229. DWORD GetIdleTimeList(HWND hwndList);
  230. BOOL ToggleLogging();
  231. protected:
  232. ArgsStruct* m_pArgs; // pointer to the huge structure
  233. BOOL m_fEnableLog; // is logging enabled
  234. static const DWORD m_dwHelp[]; // help id pairs
  235. static const DWORD m_adwTimeConst[]; // = {0,1, 5, 10, 30, 1*60, 2*60, 4*60, 24*60};
  236. static const int m_nTimeConstElements;// = sizeof(adwTimeConst)/sizeof(adwTimeConst[0]);
  237. };
  238. //+---------------------------------------------------------------------------
  239. //
  240. // class CVpnPage
  241. //
  242. // Description: The VPN property page class
  243. //
  244. // History: quintinb Created 10/26/00
  245. //
  246. //----------------------------------------------------------------------------
  247. class CVpnPage :public CPropertiesPage
  248. {
  249. public:
  250. CVpnPage(ArgsStruct* pArgs, UINT nIDTemplate);
  251. protected:
  252. virtual BOOL OnInitDialog();
  253. virtual void OnApply();
  254. protected:
  255. ArgsStruct* m_pArgs; // pointer to the huge structure
  256. static const DWORD m_dwHelp[]; // help id pairs
  257. };
  258. //+---------------------------------------------------------------------------
  259. //
  260. // class CAboutPage
  261. //
  262. // Description: The about property page class
  263. //
  264. // History: fengsun Created 10/30/97
  265. //
  266. //----------------------------------------------------------------------------
  267. class CAboutPage :public CPropertiesPage
  268. {
  269. public:
  270. CAboutPage(ArgsStruct* pArgs, UINT nIDTemplate);
  271. protected:
  272. virtual BOOL OnInitDialog();
  273. virtual BOOL OnSetActive();
  274. virtual BOOL OnKillActive();
  275. virtual void OnApply();
  276. virtual void OnReset();
  277. virtual DWORD OnOtherMessage(UINT uMsg, WPARAM wParam, LPARAM lParam );
  278. protected:
  279. ArgsStruct *m_pArgs; // pointer to the huge structure
  280. };
  281. //+---------------------------------------------------------------------------
  282. //
  283. // class CChangePasswordDlg
  284. //
  285. // Description: The network change password dlg
  286. //
  287. // History: v-vijayb Created 7/3/99
  288. //
  289. //----------------------------------------------------------------------------
  290. class CChangePasswordDlg : public CModalDlg
  291. {
  292. public:
  293. CChangePasswordDlg(ArgsStruct *pArgs);
  294. virtual void OnOK();
  295. virtual void OnCancel();
  296. virtual BOOL OnInitDialog();
  297. virtual DWORD OnOtherCommand(WPARAM wParam, LPARAM lParam );
  298. protected:
  299. ArgsStruct *m_pArgs;
  300. };
  301. inline CChangePasswordDlg::CChangePasswordDlg(ArgsStruct *pArgs) : CModalDlg()
  302. {
  303. MYDBGASSERT(pArgs);
  304. m_pArgs = pArgs;
  305. }
  306. //+---------------------------------------------------------------------------
  307. //
  308. // class CCallbackNumberDlg
  309. //
  310. // Description: Emulation of the RAS Callback Number dialog
  311. //
  312. // History: nickball Created 3/1/00
  313. //
  314. //----------------------------------------------------------------------------
  315. class CCallbackNumberDlg : public CModalDlg
  316. {
  317. public:
  318. CCallbackNumberDlg(ArgsStruct *pArgs);
  319. virtual void OnOK();
  320. virtual void OnCancel();
  321. virtual BOOL OnInitDialog();
  322. virtual DWORD OnOtherCommand(WPARAM wParam, LPARAM lParam );
  323. protected:
  324. ArgsStruct *m_pArgs;
  325. };
  326. inline CCallbackNumberDlg::CCallbackNumberDlg(ArgsStruct *pArgs) : CModalDlg()
  327. {
  328. MYDBGASSERT(pArgs);
  329. m_pArgs = pArgs;
  330. }
  331. //+---------------------------------------------------------------------------
  332. //
  333. // class CRetryAuthenticationDlg
  334. //
  335. // Description: Emulation of the RAS Retry authentication dialog
  336. //
  337. // History: nickball Created 3/1/00
  338. //
  339. //----------------------------------------------------------------------------
  340. class CRetryAuthenticationDlg : public CModalDlg
  341. {
  342. public:
  343. CRetryAuthenticationDlg(ArgsStruct *pArgs);
  344. virtual void OnOK();
  345. virtual void OnCancel();
  346. virtual BOOL OnInitDialog();
  347. virtual DWORD OnOtherCommand(WPARAM wParam, LPARAM lParam );
  348. virtual UINT GetDlgTemplate();
  349. protected:
  350. ArgsStruct *m_pArgs;
  351. BOOL m_fInetCredentials;
  352. static const DWORD m_dwHelp[]; // help id pairs
  353. };
  354. inline CRetryAuthenticationDlg::CRetryAuthenticationDlg(ArgsStruct *pArgs)
  355. : CModalDlg(m_dwHelp, pArgs->pszHelpFile)
  356. {
  357. MYDBGASSERT(pArgs);
  358. m_pArgs = pArgs;
  359. if (m_pArgs)
  360. {
  361. //
  362. // If the phone number calls for a tunnel, and we're not using
  363. // UseSameUserName and we're not actively dialing the tunnel,
  364. // then we must be dialing the Inet portion of the connection.
  365. //
  366. m_fInetCredentials = (!m_pArgs->fUseSameUserName &&
  367. !IsDialingTunnel(m_pArgs) &&
  368. UseTunneling(m_pArgs, m_pArgs->nDialIdx));
  369. }
  370. }
  371. //+---------------------------------------------------------------------------
  372. //
  373. // class CNewAccessPointDlg
  374. //
  375. // Description: Dialog to get the name of a new Access Point from the user
  376. //
  377. // History: t-urama Created 8/2/00
  378. //
  379. //----------------------------------------------------------------------------
  380. class CNewAccessPointDlg : public CModalDlg
  381. {
  382. public:
  383. CNewAccessPointDlg(ArgsStruct *pArgs, LPTSTR *ppAPName);
  384. virtual void OnOK();
  385. virtual BOOL OnInitDialog();
  386. virtual DWORD OnOtherCommand(WPARAM wParam, LPARAM lParam );
  387. protected:
  388. LPTSTR *m_ppszAPName;
  389. ArgsStruct *m_pArgs;
  390. static LRESULT CALLBACK SubClassEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  391. static WNDPROC m_pfnOrgEditWndProc; // the original edit control window proc for subclassing
  392. };
  393. inline CNewAccessPointDlg::CNewAccessPointDlg(ArgsStruct *pArgs, LPTSTR *ppszAPName) : CModalDlg()
  394. {
  395. MYDBGASSERT(pArgs);
  396. m_pArgs = pArgs;
  397. m_ppszAPName = ppszAPName;
  398. }