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.

243 lines
8.8 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1994 **
  4. //*********************************************************************
  5. //
  6. // AREACODE.CPP - Functions for
  7. //
  8. // HISTORY:
  9. //
  10. // 05/13/98 donaldm Created.
  11. //
  12. //*********************************************************************
  13. #include "pre.h"
  14. #include "icwextsn.h"
  15. long lLastLocationID = -1;
  16. void CleanupCombo(HWND hDlg)
  17. {
  18. HWND hCombo = GetDlgItem(hDlg, IDC_DIAL_FROM);
  19. for (int i=0; i < ComboBox_GetCount(hCombo); i++)
  20. {
  21. DWORD *pdwTemp = (DWORD*)ComboBox_GetItemData(hCombo, i);
  22. if (pdwTemp)
  23. delete pdwTemp;
  24. }
  25. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_DIAL_FROM));
  26. }
  27. /*******************************************************************
  28. NAME: AreaCodeInitProc
  29. SYNOPSIS: Called when page is displayed
  30. ENTRY: hDlg - dialog window
  31. fFirstInit - TRUE if this is the first time the dialog
  32. is initialized, FALSE if this InitProc has been called
  33. before (e.g. went past this page and backed up)
  34. ********************************************************************/
  35. BOOL CALLBACK AreaCodeInitProc
  36. (
  37. HWND hDlg,
  38. BOOL fFirstInit,
  39. UINT *puNextPage
  40. )
  41. {
  42. if (!fFirstInit)
  43. {
  44. short wNumLocations;
  45. long lCurrLocIndex;
  46. DWORD dwCountryCode;
  47. TCHAR szTemp[MAX_MESSAGE_LEN];
  48. BOOL bRetVal;
  49. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_AUTOCONFIG)
  50. LoadString(g_hInstance, IDS_MANUALOPTS_TITLE, szTemp, MAX_MESSAGE_LEN);
  51. else
  52. LoadString(g_hInstance, IDS_STEP1_TITLE, szTemp, MAX_MESSAGE_LEN);
  53. PropSheet_SetHeaderTitle(GetParent(hDlg), ORD_PAGE_AREACODE, (LPCSTR)szTemp);
  54. // We can skip the page if we have already downloaded
  55. gpWizardState->pTapiLocationInfo->GetTapiLocationInfo(&bRetVal);
  56. gpWizardState->pTapiLocationInfo->get_wNumberOfLocations(&wNumLocations, &lCurrLocIndex);
  57. // Ensure that we only have only 1 location and we never shwon the areacode page
  58. // Second part of this check is for case where user had more than 1 location and deleted
  59. // down to one location. That case, our history told us to come to areacode page but
  60. // since wNumLocations == 1, we would go back to refdial page.
  61. if ((1 == wNumLocations) && (-1 == lLastLocationID))
  62. {
  63. // We are happy, so advance to the next page
  64. BSTR bstrAreaCode = NULL;
  65. *puNextPage = ORD_PAGE_REFSERVDIAL;
  66. gpWizardState->pTapiLocationInfo->get_lCountryCode((long *)&dwCountryCode);
  67. gpWizardState->pTapiLocationInfo->get_bstrAreaCode(&bstrAreaCode);
  68. gpWizardState->cmnStateData.dwCountryCode = dwCountryCode;
  69. lstrcpy(gpWizardState->cmnStateData.szAreaCode, W2A(bstrAreaCode));
  70. SysFreeString(bstrAreaCode);
  71. }
  72. else
  73. {
  74. // We need to have the user enter the area code
  75. if (wNumLocations)
  76. {
  77. int iIndex = 0;
  78. CleanupCombo(hDlg);
  79. for (long lIndex=0; lIndex < (long)wNumLocations; lIndex++)
  80. {
  81. BSTR bstr = NULL;
  82. if (S_OK == gpWizardState->pTapiLocationInfo->get_LocationName(lIndex, &bstr))
  83. {
  84. iIndex = ComboBox_InsertString(GetDlgItem(hDlg, IDC_DIAL_FROM), lIndex, W2A(bstr));
  85. }
  86. SysFreeString(bstr);
  87. }
  88. BSTR bstrCountry = NULL;
  89. BSTR bstrAreaCode = NULL;
  90. long lCountryCode = 0;
  91. ComboBox_SetCurSel( GetDlgItem(hDlg, IDC_DIAL_FROM), lCurrLocIndex );
  92. if (S_OK == gpWizardState->pTapiLocationInfo->get_LocationInfo(lCurrLocIndex, &gpWizardState->lLocationID, &bstrCountry, &lCountryCode, &bstrAreaCode))
  93. {
  94. if (gpWizardState->lLocationID != lLastLocationID)
  95. {
  96. gpWizardState->bDoneRefServDownload = FALSE;
  97. }
  98. if (-1 == gpWizardState->lDefaultLocationID)
  99. {
  100. gpWizardState->lDefaultLocationID = gpWizardState->lLocationID;
  101. }
  102. lLastLocationID = gpWizardState->lLocationID;
  103. gpWizardState->cmnStateData.dwCountryCode = (DWORD) lCountryCode;
  104. SetWindowText(GetDlgItem(hDlg, IDC_AREACODE), W2A(bstrAreaCode));
  105. SetWindowText(GetDlgItem(hDlg, IDC_COUNTRY), W2A(bstrCountry));
  106. }
  107. SysFreeString(bstrCountry);
  108. SysFreeString(bstrAreaCode);
  109. }
  110. }
  111. }
  112. // if we've travelled through external apprentice pages,
  113. // it's easy for our current page pointer to get munged,
  114. // so reset it here for sanity's sake.
  115. gpWizardState->uCurrentPage = ORD_PAGE_AREACODE;
  116. return TRUE;
  117. }
  118. /*******************************************************************
  119. NAME: AreaCodeOKProc
  120. SYNOPSIS: Called when Next or Back btns pressed from page
  121. ENTRY: hDlg - dialog window
  122. fForward - TRUE if 'Next' was pressed, FALSE if 'Back'
  123. puNextPage - if 'Next' was pressed,
  124. proc can fill this in with next page to go to. This
  125. parameter is ingored if 'Back' was pressed.
  126. pfKeepHistory - page will not be kept in history if
  127. proc fills this in with FALSE.
  128. EXIT: returns TRUE to allow page to be turned, FALSE
  129. to keep the same page.
  130. ********************************************************************/
  131. BOOL CALLBACK AreaCodeOKProc
  132. (
  133. HWND hDlg,
  134. BOOL fForward,
  135. UINT *puNextPage,
  136. BOOL *pfKeepHistory
  137. )
  138. {
  139. ASSERT(puNextPage);
  140. // Extract the data entered by the user and save it.
  141. if (fForward)
  142. {
  143. //BUGBUG - if we are in auto config, we need to change the title of the next page
  144. GetWindowText(GetDlgItem(hDlg, IDC_AREACODE), gpWizardState->cmnStateData.szAreaCode, MAX_AREA_CODE);
  145. gpWizardState->pTapiLocationInfo->put_LocationId(gpWizardState->lLocationID);
  146. if (gpWizardState->lLocationID != lLastLocationID)
  147. {
  148. lLastLocationID = gpWizardState->lLocationID;
  149. gpWizardState->bDoneRefServDownload = FALSE;
  150. }
  151. }
  152. return TRUE;
  153. }
  154. /*******************************************************************
  155. NAME: AreaCodeCmdProc
  156. ********************************************************************/
  157. BOOL CALLBACK AreaCodeCmdProc
  158. (
  159. HWND hDlg,
  160. WPARAM wParam,
  161. LPARAM lParam
  162. )
  163. {
  164. switch(GET_WM_COMMAND_ID(wParam, lParam))
  165. {
  166. case IDC_DIAL_FROM:
  167. {
  168. if (GET_WM_COMMAND_CMD(wParam, lParam) == CBN_SELCHANGE)
  169. {
  170. // Get the currently selected item
  171. HWND hWndDialFrom = GetDlgItem(hDlg, IDC_DIAL_FROM);
  172. int iIndex = ComboBox_GetCurSel( hWndDialFrom );
  173. BSTR bstrCountry = NULL;
  174. BSTR bstrAreaCode = NULL;
  175. long lCountryCode = 0;
  176. if (S_OK == gpWizardState->pTapiLocationInfo->get_LocationInfo( iIndex,
  177. &gpWizardState->lLocationID,
  178. &bstrCountry,
  179. &lCountryCode,
  180. &bstrAreaCode))
  181. {
  182. gpWizardState->cmnStateData.dwCountryCode = lCountryCode;
  183. if (bstrAreaCode)
  184. {
  185. SetWindowText(GetDlgItem(hDlg, IDC_AREACODE), W2A(bstrAreaCode));
  186. }
  187. else
  188. {
  189. SetWindowText(GetDlgItem(hDlg, IDC_AREACODE), NULL);
  190. }
  191. if (bstrCountry)
  192. {
  193. SetWindowText(GetDlgItem(hDlg, IDC_COUNTRY), W2A(bstrCountry));
  194. }
  195. else
  196. {
  197. SetWindowText(GetDlgItem(hDlg, IDC_COUNTRY), NULL);
  198. }
  199. }
  200. }
  201. break;
  202. }
  203. default:
  204. break;
  205. }
  206. return 1;
  207. }