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.

330 lines
11 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // DIALERR.CPP - Functions for final Wizard pages
  7. //
  8. // HISTORY:
  9. //
  10. // 05/28/98 donaldm created
  11. //
  12. //*********************************************************************
  13. #include "pre.h"
  14. #include "htmlhelp.h"
  15. void FillModemList(HWND hDlg)
  16. {
  17. long lNumModems;
  18. long lCurrModem;
  19. long lIndex;
  20. HWND hWndMdmCmb = GetDlgItem(hDlg, IDC_DIALERR_MODEM);
  21. ComboBox_ResetContent(hWndMdmCmb);
  22. // Fill the list with the current set of installed modems
  23. gpWizardState->pRefDial->get_ModemEnum_NumDevices( &lNumModems );
  24. //RefDialSignup.ModemEnum_Reset();
  25. gpWizardState->pRefDial->ModemEnum_Reset( );
  26. for (lIndex=0; lIndex < lNumModems; lIndex++)
  27. {
  28. BSTR bstr = NULL;
  29. gpWizardState->pRefDial->ModemEnum_Next(&bstr);
  30. ComboBox_InsertString(hWndMdmCmb, lIndex, W2A(bstr));
  31. SysFreeString(bstr);
  32. }
  33. gpWizardState->pRefDial->get_CurrentModem(&lCurrModem);
  34. if (lCurrModem != -1)
  35. {
  36. ComboBox_SetCurSel(hWndMdmCmb, lCurrModem);
  37. }
  38. else
  39. {
  40. ComboBox_SetCurSel(hWndMdmCmb, 0);
  41. }
  42. }
  43. void GetSupportNumber(HWND hDlg)
  44. {
  45. HWND hwndSupport = GetDlgItem(hDlg, IDC_SERVERR_HELP);
  46. BSTR bstrSupportPhoneNum = NULL;
  47. TCHAR szFmt [MAX_MESSAGE_LEN*3];
  48. // Fill in the support number
  49. gpWizardState->pRefDial->get_SupportNumber(&bstrSupportPhoneNum);
  50. //If no support number could be found this will
  51. //be null, in which case we don't want to display the
  52. //support number string
  53. if(bstrSupportPhoneNum)
  54. {
  55. LoadString(g_hInstance, IDS_DIALERR_HELP, szFmt, ARRAYSIZE(szFmt));
  56. lstrcat(szFmt, W2A(bstrSupportPhoneNum));
  57. SetWindowText(hwndSupport, szFmt);
  58. SysFreeString(bstrSupportPhoneNum);
  59. ShowWindow(hwndSupport, SW_SHOW);
  60. }
  61. else
  62. ShowWindow(hwndSupport, SW_HIDE);
  63. }
  64. /*******************************************************************
  65. NAME: DialErrorInitProc
  66. SYNOPSIS: Called when page is displayed
  67. ENTRY: hDlg - dialog window
  68. fFirstInit - TRUE if this is the first time the dialog
  69. is initialized, FALSE if this InitProc has been called
  70. before (e.g. went past this page and backed up)
  71. ********************************************************************/
  72. BOOL CALLBACK DialErrorInitProc
  73. (
  74. HWND hDlg,
  75. BOOL fFirstInit,
  76. UINT *puNextPage
  77. )
  78. {
  79. if (!fFirstInit)
  80. {
  81. // Show the phone Number
  82. BSTR bstrPhoneNum = NULL;
  83. BSTR bstrErrMsg = NULL;
  84. gpWizardState->pRefDial->get_DialPhoneNumber(&bstrPhoneNum);
  85. SetWindowLongPtr(GetDlgItem(hDlg, IDC_DIALERR_PHONENUMBER), GWLP_USERDATA, TRUE);
  86. SetWindowText(GetDlgItem(hDlg, IDC_DIALERR_PHONENUMBER), W2A(bstrPhoneNum));
  87. SysFreeString(bstrPhoneNum);
  88. EnableWindow(GetDlgItem(hDlg, IDC_DIALING_PROPERTIES), TRUE);
  89. // Display the error text message
  90. gpWizardState->pRefDial->get_DialErrorMsg(&bstrErrMsg);
  91. SetWindowText(GetDlgItem(hDlg, IDC_DIALERR_TEXT), W2A(bstrErrMsg));
  92. SysFreeString(bstrErrMsg);
  93. // Enum Modems, and fill in list.
  94. FillModemList(hDlg);
  95. //Get the support number for the current dlg
  96. // Currently this is removed from BETA 2
  97. // GetSupportNumber(hDlg);
  98. // if we've travelled through external apprentice pages,
  99. // it's easy for our current page pointer to get munged,
  100. // so reset it here for sanity's sake.
  101. gpWizardState->uCurrentPage = ORD_PAGE_REFDIALERROR;
  102. }
  103. return TRUE;
  104. }
  105. /*******************************************************************
  106. NAME: DialErrorOKProc
  107. SYNOPSIS: Called when Next or Back btns pressed from page
  108. ENTRY: hDlg - dialog window
  109. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  110. puNextPage - if 'Next' was pressed,
  111. proc can fill this in with next page to go to. This
  112. parameter is ingored if 'Back' was pressed.
  113. pfKeepHistory - page will not be kept in history if
  114. proc fills this in with FALSE.
  115. EXIT: returns TRUE to allow page to be turned, FALSE
  116. to keep the same page.
  117. ********************************************************************/
  118. BOOL CALLBACK DialErrorOKProc
  119. (
  120. HWND hMdmCmb,
  121. BOOL fForward,
  122. UINT *puNextPage,
  123. BOOL *pfKeepHistory
  124. )
  125. {
  126. ASSERT(puNextPage);
  127. // Initialze status before connecting
  128. gpWizardState->lRefDialTerminateStatus = ERROR_SUCCESS;
  129. gpWizardState->bDoneRefServDownload = FALSE;
  130. gpWizardState->bDoneRefServRAS = FALSE;
  131. gpWizardState->bStartRefServDownload = FALSE;
  132. // Assume the user has selected a number on this page
  133. // So we will not do SetupForDialing again next time
  134. gpWizardState->bDoUserPick = TRUE;
  135. if (fForward)
  136. {
  137. *pfKeepHistory = FALSE;
  138. *puNextPage = ORD_PAGE_REFSERVDIAL;
  139. // Set the new phone Number
  140. TCHAR szPhone[MAX_RES_LEN];
  141. GetWindowText(GetDlgItem(hMdmCmb, IDC_DIALERR_PHONENUMBER), szPhone, sizeof(szPhone));
  142. gpWizardState->pRefDial->put_DialPhoneNumber(A2W(szPhone));
  143. // Set the current modem
  144. long lCurrModem = ComboBox_GetCurSel(GetDlgItem(hMdmCmb, IDC_DIALERR_MODEM));
  145. gpWizardState->pRefDial->put_CurrentModem(lCurrModem);
  146. }
  147. else
  148. {
  149. BOOL bRetVal;
  150. // Set userpick to FALSE to regenerate connectoid
  151. gpWizardState->bDoUserPick = FALSE;
  152. gpWizardState->pRefDial->RemoveConnectoid(&bRetVal);
  153. }
  154. return TRUE;
  155. }
  156. /*******************************************************************
  157. NAME: DialErrorCmdProc
  158. SYNOPSIS: Called when a command is generated from page
  159. ENTRY: hDlg - dialog window
  160. wParam - wParam
  161. lParam - lParam
  162. EXIT: returns TRUE
  163. ********************************************************************/
  164. BOOL g_bNotChildDlgUpdate = TRUE;
  165. BOOL CALLBACK DialErrorCmdProc
  166. (
  167. HWND hDlg,
  168. WPARAM wParam,
  169. LPARAM lParam
  170. )
  171. {
  172. switch(GET_WM_COMMAND_CMD(wParam, lParam))
  173. {
  174. case BN_CLICKED:
  175. {
  176. switch (GET_WM_COMMAND_ID(wParam, lParam))
  177. {
  178. case IDC_CHANGE_NUMBER:
  179. {
  180. BOOL bRetVal;
  181. g_bNotChildDlgUpdate = FALSE;
  182. // Pass current modem, because if ISDN modem we need to show different content
  183. gpWizardState->pRefDial->ShowPhoneBook(gpWizardState->cmnStateData.dwCountryCode,
  184. ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIALERR_MODEM)),
  185. &bRetVal);
  186. if (bRetVal)
  187. {
  188. // Show the phone Number as it may be changed after the popup
  189. BSTR bstrPhoneNum = NULL;
  190. gpWizardState->pRefDial->get_DialPhoneNumber(&bstrPhoneNum);
  191. SetWindowText(GetDlgItem(hDlg, IDC_DIALERR_PHONENUMBER), W2A(bstrPhoneNum));
  192. SysFreeString(bstrPhoneNum);
  193. // 10/6/98 vyung
  194. // We decided to remove this support number for beta 2
  195. // Get the support number for the current dlg
  196. // GetSupportNumber(hDlg);
  197. g_bNotChildDlgUpdate = TRUE;
  198. }
  199. break;
  200. }
  201. case IDC_DIALING_PROPERTIES:
  202. {
  203. BOOL bRetVal;
  204. g_bNotChildDlgUpdate = FALSE;
  205. gpWizardState->pRefDial->ShowDialingProperties(&bRetVal);
  206. if (bRetVal)
  207. {
  208. // Show the phone Number as it may be changed after the popup
  209. BSTR bstrPhoneNum = NULL;
  210. gpWizardState->pRefDial->get_DialPhoneNumber(&bstrPhoneNum);
  211. SetWindowText(GetDlgItem(hDlg, IDC_DIALERR_PHONENUMBER), W2A(bstrPhoneNum));
  212. SysFreeString(bstrPhoneNum);
  213. // Show the modem as it may be changed after the popup
  214. LONG lCurrModem = 0;
  215. gpWizardState->pRefDial->get_CurrentModem(&lCurrModem);
  216. if (lCurrModem == -1l)
  217. {
  218. lCurrModem = 0;
  219. }
  220. ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_DIALERR_MODEM), lCurrModem);
  221. if (gpWizardState->pTapiLocationInfo)
  222. {
  223. BOOL bRetVal;
  224. BSTR bstrAreaCode = NULL;
  225. DWORD dwCountryCode;
  226. gpWizardState->pTapiLocationInfo->GetTapiLocationInfo(&bRetVal);
  227. gpWizardState->pTapiLocationInfo->get_lCountryCode((long *)&dwCountryCode);
  228. gpWizardState->pTapiLocationInfo->get_bstrAreaCode(&bstrAreaCode);
  229. gpWizardState->cmnStateData.dwCountryCode = dwCountryCode;
  230. lstrcpy(gpWizardState->cmnStateData.szAreaCode, W2A(bstrAreaCode));
  231. SysFreeString(bstrAreaCode);
  232. }
  233. g_bNotChildDlgUpdate = TRUE;
  234. }
  235. break;
  236. }
  237. case IDC_DIAL_HELP:
  238. {
  239. HtmlHelp(NULL, ICW_HTML_HELP_TROUBLE_TOPIC, HH_DISPLAY_TOPIC, NULL);
  240. break;
  241. }
  242. default:
  243. break;
  244. }
  245. break;
  246. }
  247. case EN_UPDATE:
  248. {
  249. switch (GET_WM_COMMAND_ID(wParam, lParam))
  250. {
  251. case IDC_DIALERR_PHONENUMBER:
  252. {
  253. if (!GetWindowLongPtr(GetDlgItem(hDlg, IDC_DIALERR_PHONENUMBER), GWLP_USERDATA))
  254. {
  255. //Since when the other popups set this text this event will fire we
  256. //don't disable wanna disable the button when it's them.
  257. //more so because a race condition and caos ensues causing a lack of input
  258. //while windows figures out what the heck is going on
  259. if(g_bNotChildDlgUpdate)
  260. EnableWindow(GetDlgItem(hDlg, IDC_DIALING_PROPERTIES), FALSE);
  261. }
  262. SetWindowLongPtr(GetDlgItem(hDlg, IDC_DIALERR_PHONENUMBER), GWLP_USERDATA, FALSE);
  263. }
  264. }
  265. }
  266. default:
  267. break;
  268. } // End of switch
  269. return TRUE;
  270. }