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.

756 lines
22 KiB

  1. // ############################################################################
  2. #include "pch.hpp"
  3. #include "phbk.h"
  4. #include "debug.h"
  5. #include "phbkrc.h"
  6. #include "misc.h"
  7. //#include "ras.h"
  8. #include <ras.h>
  9. #pragma pack (4)
  10. //#if !defined(WIN16)
  11. //#include <rnaph.h>
  12. //#endif
  13. #pragma pack ()
  14. #include "suapi.h"
  15. #define ERROR_USER_EXIT 0x8b0bffff
  16. #define MB_MYERROR (MB_APPLMODAL | MB_ICONERROR | MB_SETFOREGROUND)
  17. #define NOTIFY_CODE (HIWORD(wParam))
  18. #define WM_SHOWSTATEMSG WM_USER+1
  19. char szTemp[100];
  20. char szValidPhoneCharacters[] = {"0123456789AaBbCcDdPpTtWw!@$ -.()+*#,&\0"};
  21. // ############################################################################
  22. BOOL CSelectNumDlg::FHasPhoneNumbers(LPLINECOUNTRYENTRY pLCE)
  23. {
  24. LPIDLOOKUPELEMENT pIDLookUp;
  25. IDLOOKUPELEMENT LookUpTarget;
  26. CPhoneBook far *pcPBTemp;
  27. PACCESSENTRY pAE = NULL, pAELast = NULL;
  28. DWORD dwCountryID;
  29. pcPBTemp = ((CPhoneBook far*)m_dwPhoneBook);
  30. LookUpTarget.dwID = pLCE->dwCountryID;
  31. pIDLookUp = NULL;
  32. pIDLookUp = (LPIDLOOKUPELEMENT)bsearch(&LookUpTarget,pcPBTemp->m_rgIDLookUp,
  33. (int)pcPBTemp->m_pLineCountryList->dwNumCountries,sizeof(IDLOOKUPELEMENT),CompareIDLookUpElements);
  34. if (!pIDLookUp) return FALSE; // no such country
  35. pAE = pIDLookUp->pFirstAE;
  36. if (!pAE) return FALSE; // no phone numbers at all
  37. dwCountryID = pAE->dwCountryID;
  38. pAELast = &(pcPBTemp->m_rgPhoneBookEntry[pcPBTemp->m_cPhoneBookEntries - 1]);
  39. while (pAELast > pAE &&
  40. pAE->dwCountryID == dwCountryID)
  41. {
  42. if ((pAE->fType & m_bMask) == m_fType) return TRUE;
  43. pAE++;
  44. }
  45. return FALSE; // no phone numbers of the right type
  46. // return ((BOOL)(pIDLookUp->pFirstAE));
  47. }
  48. // ############################################################################
  49. INT_PTR CSelectNumDlg::DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT lResult)
  50. {
  51. LRESULT lRet = TRUE;
  52. unsigned int idx;
  53. int iCurIndex;
  54. int iLastIndex;
  55. PACCESSENTRY pAE = NULL;
  56. LPSTR p, p2;
  57. switch (uMsg)
  58. {
  59. case WM_INITDIALOG:
  60. CPhoneBook far *pcPBTemp;
  61. pcPBTemp = ((CPhoneBook far *)m_dwPhoneBook);
  62. m_hwndDlg = hwndDlg;
  63. // figure out if we are in the middle of an AUTODIAL
  64. //
  65. if (m_dwFlags & AUTODIAL_IN_PROGRESS)
  66. {
  67. EnableWindow(GetDlgItem(m_hwndDlg,IDC_CMDBACK),FALSE);
  68. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLSIGNUP),SW_HIDE);
  69. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLDIALERR),SW_HIDE);
  70. } else if (m_dwFlags& DIALERR_IN_PROGRESS){
  71. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLSIGNUP),SW_HIDE);
  72. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLAUTODIAL),SW_HIDE);
  73. ShowWindow(GetDlgItem(m_hwndDlg,IDC_CMDBACK),SW_HIDE);
  74. SetDlgItemText(m_hwndDlg,IDC_CMDNEXT,GetSz(IDS_OK));
  75. }else {
  76. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLAUTODIAL),SW_HIDE);
  77. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLDIALERR),SW_HIDE);
  78. }
  79. // Fill in country list and select current country
  80. //
  81. iCurIndex = -1; // 0xFFFFFFFF
  82. // NOTE: it might be nice for INTL testing purposes to fill this combo box with
  83. // a list sorted by the country ID instead of the country name.
  84. for (idx=0;idx<pcPBTemp->m_pLineCountryList->dwNumCountries;idx++)
  85. {
  86. if (FHasPhoneNumbers(pcPBTemp->m_rgNameLookUp[idx].pLCE))
  87. {
  88. wsprintf(szTemp,"%s (%ld)",
  89. pcPBTemp->m_rgNameLookUp[idx].psCountryName,
  90. pcPBTemp->m_rgNameLookUp[idx].pLCE->dwCountryID);
  91. iLastIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBCOUNTRY,
  92. CB_ADDSTRING,0,
  93. (LPARAM)((LPSTR) &szTemp[0]));
  94. SendDlgItemMessage(m_hwndDlg,IDC_CMBCOUNTRY,CB_SETITEMDATA,
  95. (WPARAM)iLastIndex,
  96. (LPARAM)pcPBTemp->m_rgNameLookUp[idx].pLCE->dwCountryID);
  97. if (pcPBTemp->m_rgNameLookUp[idx].pLCE->dwCountryID == m_dwCountryID)
  98. {
  99. iCurIndex = iLastIndex;
  100. }
  101. }
  102. }
  103. if (iCurIndex != -1) // 0xFFFFFFFF
  104. {
  105. SendDlgItemMessage(m_hwndDlg,IDC_CMBCOUNTRY,CB_SETCURSEL,(WPARAM)iCurIndex,0);
  106. } else {
  107. SendDlgItemMessage(m_hwndDlg,IDC_CMBCOUNTRY,CB_SETCURSEL,0,0);
  108. iCurIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBCOUNTRY,CB_GETITEMDATA,0,0);
  109. if (iCurIndex != CB_ERR) m_dwCountryID = iCurIndex;
  110. }
  111. // Copy country to label
  112. //
  113. if (GetDlgItemText(m_hwndDlg,IDC_CMBCOUNTRY,szTemp,100))
  114. {
  115. SetDlgItemText(m_hwndDlg,IDC_LBLCOUNTRY,szTemp);
  116. }
  117. // Initialize Last Selection Method
  118. //
  119. m_dwFlags &= (~FREETEXT_SELECTION_METHOD);
  120. m_dwFlags |= PHONELIST_SELECTION_METHOD;
  121. // Fill in region list and select current region
  122. //
  123. FillRegion();
  124. // Fill in phone numbers
  125. //
  126. FillNumber();
  127. SetFocus(GetDlgItem(m_hwndDlg,IDC_CMBCOUNTRY));
  128. lRet = FALSE;
  129. break;
  130. case WM_SHOWSTATEMSG:
  131. if (wParam)
  132. {
  133. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLSTATEMSG),SW_SHOW);
  134. } else {
  135. ShowWindow(GetDlgItem(m_hwndDlg,IDC_LBLSTATEMSG),SW_HIDE);
  136. }
  137. break;
  138. // 1/9/96 jmazner added for Normandy #13185
  139. case WM_CLOSE:
  140. if ((m_dwFlags & (AUTODIAL_IN_PROGRESS|DIALERR_IN_PROGRESS)) == 0)
  141. {
  142. if (MessageBox(hwndDlg,GetSz(IDS_WANTTOEXIT),GetSz(IDS_TITLE),
  143. MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
  144. EndDialog(hwndDlg,IDC_CMDCANCEL);
  145. } else {
  146. EndDialog(hwndDlg,IDC_CMDCANCEL);
  147. }
  148. break;
  149. case WM_COMMAND:
  150. switch (LOWORD(wParam))
  151. {
  152. case IDC_CMBCOUNTRY:
  153. if (NOTIFY_CODE == CBN_SELCHANGE)
  154. {
  155. iCurIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBCOUNTRY,CB_GETCURSEL,0,0);
  156. if (iCurIndex == CB_ERR) break;
  157. iCurIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBCOUNTRY,CB_GETITEMDATA,(WPARAM)iCurIndex,0);
  158. if (iCurIndex == CB_ERR) break;
  159. m_dwCountryID = iCurIndex; //REVIEW: data type????
  160. FillRegion();
  161. m_wRegion = 0;
  162. FillNumber();
  163. }
  164. break;
  165. case IDC_CMBREGION:
  166. if (NOTIFY_CODE == CBN_SELCHANGE)
  167. {
  168. iCurIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_GETCURSEL,0,0);
  169. if (iCurIndex == CB_ERR) break;
  170. iCurIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_GETITEMDATA,(WPARAM)iCurIndex,0);
  171. if (iCurIndex == CB_ERR) break;
  172. m_wRegion = (WORD) iCurIndex; //REVIEW: data type???
  173. FillNumber();
  174. }
  175. break;
  176. case IDC_CMBNUMBER:
  177. if ((NOTIFY_CODE == CBN_SELCHANGE) || (NOTIFY_CODE == CBN_DROPDOWN))
  178. {
  179. //iCurIndex = SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,CB_GETCURSEL,0,0);
  180. //if (iCurIndex == CB_ERR) break;
  181. EnableWindow(GetDlgItem(m_hwndDlg,IDC_CMDNEXT),TRUE);
  182. //iCurIndex = SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,CB_GETITEMDATA,(WPARAM)iCurIndex,0);
  183. //if (iCurIndex == CB_ERR) break;
  184. //if (!lstrcpy(&m_szDunFile[0],&((PACCESSENTRY)iCurIndex)->szDataCenter[0]))
  185. //{
  186. // AssertSz(0,"Failed to copy data center from AE\n");
  187. // break;
  188. //}
  189. // Set Last Selection Method
  190. //
  191. m_dwFlags &= (~FREETEXT_SELECTION_METHOD);
  192. m_dwFlags |= PHONELIST_SELECTION_METHOD;
  193. } else if (NOTIFY_CODE == CBN_EDITCHANGE) {
  194. if (SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,WM_GETTEXTLENGTH,0,0))
  195. {
  196. EnableWindow(GetDlgItem(m_hwndDlg,IDC_CMDNEXT),TRUE);
  197. } else {
  198. EnableWindow(GetDlgItem(m_hwndDlg,IDC_CMDNEXT),FALSE);
  199. }
  200. // Set Last Selection Method
  201. //
  202. m_dwFlags &= (~PHONELIST_SELECTION_METHOD);
  203. m_dwFlags |= FREETEXT_SELECTION_METHOD;
  204. }
  205. break;
  206. case IDC_CMDNEXT:
  207. if ((m_dwFlags & PHONELIST_SELECTION_METHOD) == PHONELIST_SELECTION_METHOD)
  208. {
  209. DWORD_PTR dwItemData;
  210. iCurIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,CB_GETCURSEL,0,0);
  211. if (iCurIndex == CB_ERR) break;
  212. dwItemData = SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,CB_GETITEMDATA,(WPARAM)iCurIndex,0);
  213. if (iCurIndex == CB_ERR) break;
  214. // Get the relavant information out of the AE structures
  215. //
  216. pAE = (PACCESSENTRY)dwItemData;
  217. ((CPhoneBook far *)m_dwPhoneBook)->GetCanonical(pAE,m_szPhoneNumber);
  218. lstrcpy(m_szDunFile,pAE->szDataCenter);
  219. } else {
  220. // Parse the text that the user entered
  221. //
  222. if (GetDlgItemText(m_hwndDlg,IDC_CMBNUMBER,m_szPhoneNumber,RAS_MaxPhoneNumber))
  223. {
  224. m_szPhoneNumber[RAS_MaxPhoneNumber] = '\0';
  225. for (p = m_szPhoneNumber;*p && *p != ':';p++);
  226. if (*p)
  227. {
  228. *p = '\0';
  229. p++;
  230. lstrcpy(m_szDunFile,p);
  231. } else {
  232. m_szDunFile[0] = '\0';
  233. }
  234. // Check that the phone number on contains valid characters
  235. //
  236. for (p = m_szPhoneNumber;*p;p++)
  237. {
  238. for(p2 = szValidPhoneCharacters;*p2;p2++)
  239. {
  240. if (*p == *p2)
  241. break; // p2 for loop
  242. }
  243. if (!*p2) break; // p for loop
  244. }
  245. if (*p)
  246. {
  247. MessageBox(m_hwndDlg,GetSz(IDS_INVALIDPHONE),GetSz(IDS_TITLE),MB_MYERROR);
  248. //MsgBox(IDS_INVALIDPHONE,MB_MYERROR);
  249. break; // switch statement
  250. }
  251. } else {
  252. AssertSz(0,"You should never be able to hit NEXT with nothing in the phone number.\n");
  253. }
  254. }
  255. EndDialog(m_hwndDlg,IDC_CMDNEXT);
  256. break;
  257. case IDC_CMDCANCEL:
  258. if ((m_dwFlags & (AUTODIAL_IN_PROGRESS|DIALERR_IN_PROGRESS)) == 0)
  259. {
  260. if (MessageBox(hwndDlg,GetSz(IDS_WANTTOEXIT),GetSz(IDS_TITLE),
  261. MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
  262. EndDialog(hwndDlg,IDC_CMDCANCEL);
  263. } else {
  264. EndDialog(hwndDlg,IDC_CMDCANCEL);
  265. }
  266. break;
  267. EndDialog(m_hwndDlg,IDC_CMDCANCEL);
  268. break;
  269. case IDC_CMDBACK:
  270. EndDialog(m_hwndDlg,IDC_CMDBACK);
  271. break;
  272. }
  273. default:
  274. lRet = FALSE;
  275. break;
  276. }// switch
  277. return lRet;
  278. }
  279. // ############################################################################
  280. /***** 1/9/96 jmazner Normandy #13185
  281. CAccessNumDlg::CAccessNumDlg()
  282. {
  283. m_szDunPrimary[0] = '\0';
  284. m_szDunSecondary[0] = '\0';
  285. m_szPrimary[0] = '\0';
  286. m_szSecondary[0] = '\0';
  287. m_rgAccessEntry = NULL;
  288. m_wNumber = 0;
  289. m_dwPhoneBook=0;
  290. }
  291. *********/
  292. // ############################################################################
  293. /********* 1/9/96 jmazner Normandy #13185
  294. This was dead code, unused anywhere in icwphbk
  295. INT_PTR CAccessNumDlg::DlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
  296. LRESULT lResult)
  297. {
  298. LRESULT lRet = TRUE;
  299. switch (uMsg)
  300. {
  301. case WM_INITDIALOG:
  302. SendDlgItemMessage(hwnd,IDC_TXTPRIMARY,EM_SETLIMITTEXT,RAS_MaxPhoneNumber,0);
  303. SendDlgItemMessage(hwnd,IDC_TXTSECONDARY,EM_SETLIMITTEXT,RAS_MaxPhoneNumber,0);
  304. / *
  305. // turn AccessEntries into phone numbers
  306. if(m_szPrimary[0] == '\0')
  307. {
  308. LPIDLOOKUPELEMENT pIDLookUp;
  309. CPhoneBook *pcPBTemp;
  310. pcPBTemp = ((CPhoneBook far *)m_dwPhoneBook);
  311. AssertSz(m_dwPhoneBook,"No phonebook set");
  312. //For the primary phone number
  313. pIDLookUp = (LPIDLOOKUPELEMENT)bsearch(&m_rgAccessEntry[0]->dwCountryID,
  314. pcPBTemp->m_rgIDLookUp,pcPBTemp->m_pLineCountryList->dwNumCountries,
  315. sizeof(IDLOOKUPELEMENT),CompareIdxLookUpElements);
  316. SzCanonicalFromAE (m_szPrimary, m_rgAccessEntry[0], pIDLookUp->pLCE);
  317. if (m_rgAccessEntry[1])
  318. {
  319. if (m_rgAccessEntry[0]->dwCountryID != m_rgAccessEntry[1]->dwCountryID)
  320. {
  321. pIDLookUp = (LPIDLOOKUPELEMENT)bsearch(&m_rgAccessEntry[0]->dwCountryID,
  322. pcPBTemp->m_rgIDLookUp,pcPBTemp->m_pLineCountryList->dwNumCountries,
  323. sizeof(IDLOOKUPELEMENT),CompareIdxLookUpElements);
  324. }
  325. SzCanonicalFromAE (m_szSecondary, m_rgAccessEntry[1], pIDLookUp->pLCE);
  326. }
  327. }
  328. * /
  329. SendDlgItemMessage(hwnd,IDC_TXTPRIMARY,WM_SETTEXT,0,(LPARAM)&m_szPrimary[0]);
  330. SendDlgItemMessage(hwnd,IDC_TXTSECONDARY,WM_SETTEXT,0,(LPARAM)&m_szSecondary[0]);
  331. break;
  332. case WM_COMMAND:
  333. switch (LOWORD(wParam))
  334. {
  335. case IDC_CMDOK:
  336. // Check that we have at least one phone number
  337. // Leave dialog
  338. GetDlgItemText(hwnd,IDC_TXTPRIMARY,&m_szPrimary[0],RAS_MaxPhoneNumber);
  339. GetDlgItemText(hwnd,IDC_TXTSECONDARY,&m_szSecondary[0],RAS_MaxPhoneNumber);
  340. if (m_szPrimary[0])
  341. m_wNumber=1;
  342. else
  343. m_wNumber=0;
  344. if (m_szSecondary[0])
  345. m_wNumber++;
  346. EndDialog(hwnd,IDC_CMDOK);
  347. break;
  348. case IDC_CMDEXIT:
  349. // Verify with user
  350. // Get out of Dodge
  351. if (MessageBox(hwnd,GetSz(IDS_WANTTOEXIT),GetSz(IDS_TITLE),
  352. MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
  353. EndDialog(hwnd,IDC_CMDEXIT);
  354. break;
  355. case IDC_CMDCHANGEPRIMARY:
  356. // hide dialog
  357. ShowWindow(hwnd,SW_HIDE);
  358. // show new dialog
  359. CSelectNumDlg far *pcSelectNumDlg;
  360. pcSelectNumDlg = new CSelectNumDlg;
  361. if (!pcSelectNumDlg)
  362. {
  363. MessageBox(hwnd,GetSz(IDS_NOTENOUGHMEMORY),GetSz(IDS_TITLE),MB_MYERROR);
  364. // MsgBox(IDS_NOTENOUGHMEMORY,MB_MYERROR);
  365. ShowWindow(hwnd,SW_SHOW);
  366. break;
  367. }
  368. int irc;
  369. pcSelectNumDlg->m_dwPhoneBook = m_dwPhoneBook;
  370. pcSelectNumDlg->m_dwCountryID = m_dwCountryID;
  371. pcSelectNumDlg->m_wRegion = m_wRegion;
  372. irc = DialogBoxParam(g_hInstDll,MAKEINTRESOURCE(IDD_SELECTNUMBER),
  373. g_hWndMain,PhbkGenericDlgProc,
  374. (LPARAM)pcSelectNumDlg);
  375. ShowWindow(hwnd,SW_SHOW);
  376. switch (irc)
  377. {
  378. case -1:
  379. MessageBox(hwnd,GetSz(IDS_NOTENOUGHMEMORY),GetSz(IDS_TITLE),MB_MYERROR);
  380. // MsgBox(IDS_NOTENOUGHMEMORY,MB_MYERROR);
  381. goto DlgProcExit;
  382. // break;
  383. case IDC_CMDOK:
  384. m_dwCountryID = pcSelectNumDlg->m_dwCountryID;
  385. m_wRegion = pcSelectNumDlg->m_wRegion;
  386. lstrcpy(m_szDunPrimary,pcSelectNumDlg->m_szDunFile);
  387. SetDlgItemText(hwnd,IDC_TXTPRIMARY,pcSelectNumDlg->m_szPhoneNumber);
  388. break;
  389. }
  390. break;
  391. }
  392. break;
  393. default:
  394. lRet = FALSE;
  395. break;
  396. }
  397. DlgProcExit:
  398. return lRet;
  399. }
  400. *********************/
  401. #ifdef WIN16
  402. // ############################################################################
  403. // NAME: SetNonBoldDlg
  404. //
  405. // Set all the child controls in a window to a non-bold version of the
  406. // current control font.
  407. //
  408. // Parameters: HWND hDlg Handle to the dialog window
  409. //
  410. // Created 8/12/96 ValdonB (creatively borrowed from IE)
  411. // ############################################################################
  412. void
  413. SetNonBoldDlg(HWND hDlg)
  414. {
  415. HFONT hfontDlg = (HFONT) NULL;
  416. LOGFONT lFont;
  417. HWND hCtl;
  418. if ((hfontDlg = (HFONT) SendMessage(hDlg, WM_GETFONT, 0, 0L)))
  419. {
  420. if (GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont))
  421. {
  422. lFont.lfWeight = FW_NORMAL;
  423. if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont))
  424. {
  425. // apply the font to all the child controls
  426. for (hCtl = GetWindow(hDlg, GW_CHILD);
  427. NULL != hCtl;
  428. hCtl = GetWindow(hCtl, GW_HWNDNEXT))
  429. {
  430. SendMessage(hCtl, WM_SETFONT, (WPARAM) hfontDlg, 0);
  431. }
  432. }
  433. }
  434. }
  435. }
  436. // ############################################################################
  437. // NAME: SetNonBoldDlg
  438. //
  439. // The dialog was modified earlier by unbolding the dialog font, and
  440. // getting each control in the dialog to use that font. This function
  441. // is called when the dialog is being destroyed so the font can be
  442. // deleted
  443. //
  444. // Parameters: HWND hDlg Handle to the dialog window
  445. //
  446. // Created 8/12/96 ValdonB (creatively borrowed from IE)
  447. // ############################################################################
  448. void
  449. DeleteDlgFont
  450. (
  451. HWND hDlg
  452. )
  453. {
  454. HFONT hfont = NULL;
  455. hfont = (HFONT)SendMessage(hDlg,WM_GETFONT,0,0);
  456. if (hfont) DeleteObject(hfont);
  457. }
  458. #endif // WIN16
  459. // ############################################################################
  460. #ifdef WIN16
  461. extern "C" INT_PTR CALLBACK __export PhbkGenericDlgProc(
  462. #else
  463. extern "C" __declspec(dllexport) INT_PTR CALLBACK PhbkGenericDlgProc(
  464. #endif
  465. HWND hwndDlg, // handle to dialog box
  466. UINT uMsg, // message
  467. WPARAM wParam, // first message parameter
  468. LPARAM lParam // second message parameter
  469. )
  470. {
  471. #if defined(WIN16)
  472. RECT MyRect;
  473. RECT DTRect;
  474. #endif
  475. //#ifdef DEBUG
  476. // DebugBreak();
  477. //#endif
  478. CDialog far *pcDlg = NULL;
  479. LRESULT lRet;
  480. switch (uMsg)
  481. {
  482. case WM_DESTROY:
  483. ReleaseBold(GetDlgItem(hwndDlg,IDC_LBLTITLE));
  484. break;
  485. case WM_INITDIALOG:
  486. pcDlg = (CDialog far *)lParam;
  487. SetWindowLongPtr(hwndDlg,DWLP_USER,lParam);
  488. lRet = TRUE;
  489. #if defined(WIN16)
  490. //
  491. // Move the window to the center of the screen
  492. //
  493. GetWindowRect(hwndDlg, &MyRect);
  494. if (0 == MyRect.left && 0 == MyRect.top)
  495. {
  496. GetWindowRect(GetDesktopWindow(), &DTRect);
  497. MoveWindow(hwndDlg, (DTRect.right - MyRect.right) / 2, (DTRect.bottom - MyRect.bottom) /2,
  498. MyRect.right, MyRect.bottom, FALSE);
  499. }
  500. SetNonBoldDlg(hwndDlg);
  501. #endif
  502. MakeBold(GetDlgItem(hwndDlg,IDC_LBLTITLE));
  503. break;
  504. #if defined(WIN16)
  505. case WM_SYSCOLORCHANGE:
  506. Ctl3dColorChange();
  507. break;
  508. #endif
  509. // 1/9/96 jmazner Normandy #13185, moved to CSelectNumDlg::DlgProc
  510. //case WM_CLOSE:
  511. // if (MessageBox(hwndDlg,GetSz(IDS_WANTTOEXIT),GetSz(IDS_TITLE),
  512. // MB_APPLMODAL | MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
  513. // EndDialog(hwndDlg,IDC_CMDCANCEL);
  514. // lRet = TRUE;
  515. // break;
  516. // //PostQuitMessage(0);
  517. // EndDialog(hwndDlg,FALSE);
  518. // lRet = TRUE;
  519. // break;
  520. default:
  521. // let the system process the message
  522. lRet = FALSE;
  523. }
  524. if (!pcDlg) pcDlg = (CDialog far*)GetWindowLongPtr(hwndDlg,DWLP_USER);
  525. if (pcDlg)
  526. lRet = pcDlg->DlgProc(hwndDlg,uMsg,wParam,lParam,lRet);
  527. return (INT_PTR)lRet;
  528. }
  529. // ############################################################################
  530. HRESULT CSelectNumDlg::FillRegion()
  531. {
  532. HRESULT hr = ERROR_NOT_ENOUGH_MEMORY;
  533. int iCurIndex;
  534. int iLastIndex;
  535. unsigned int idx;
  536. CPhoneBook far *pcPBTemp;
  537. pcPBTemp = ((CPhoneBook far *)m_dwPhoneBook);
  538. int iDebugIdx;
  539. // Fill in region list
  540. //
  541. SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_RESETCONTENT,0,0);
  542. SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_ADDSTRING,0,(LPARAM)GetSz(IDS_NATIONWIDE));
  543. iCurIndex = -1; // 0xFFFFFFFF;
  544. m_fHasRegions = FALSE;
  545. for (idx=0;idx<pcPBTemp->m_cStates;idx++)
  546. {
  547. if (pcPBTemp->m_rgState[idx].dwCountryID == m_dwCountryID)
  548. {
  549. PACCESSENTRY pAE = NULL, pAELast = NULL;
  550. pAE = pcPBTemp->m_rgState[idx].paeFirst;
  551. Assert(pAE);
  552. pAELast = &(pcPBTemp->m_rgPhoneBookEntry[pcPBTemp->m_cPhoneBookEntries - 1]);
  553. while (pAELast > pAE &&
  554. pAE->dwCountryID == m_dwCountryID &&
  555. pAE->wStateID == idx+1)
  556. {
  557. if ((pAE->fType & m_bMask) == m_fType)
  558. goto AddRegion;
  559. pAE++;
  560. }
  561. continue;
  562. AddRegion:
  563. m_fHasRegions = TRUE;
  564. iLastIndex = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_ADDSTRING,0,(LPARAM)&pcPBTemp->m_rgState[idx].szStateName[0]);
  565. iDebugIdx = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_SETITEMDATA,(WPARAM)iLastIndex,(LPARAM)idx+1);
  566. if ((idx+1) == m_wRegion)
  567. {
  568. iCurIndex = iLastIndex;
  569. }
  570. }
  571. }
  572. // select current region or nation wide
  573. //
  574. if (iCurIndex != -1) // 0xFFFFFFFF
  575. {
  576. SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_SETCURSEL,(WPARAM)iCurIndex,0);
  577. } else {
  578. m_wRegion = 0; // Nationwide
  579. SendDlgItemMessage(m_hwndDlg,IDC_CMBREGION,CB_SETCURSEL,0,0);
  580. }
  581. EnableWindow(GetDlgItem(m_hwndDlg,IDC_CMBREGION),m_fHasRegions);
  582. PostMessage(m_hwndDlg,WM_SHOWSTATEMSG,m_fHasRegions,0);
  583. hr = ERROR_SUCCESS;
  584. return hr;
  585. }
  586. // ############################################################################
  587. CSelectNumDlg::CSelectNumDlg()
  588. {
  589. m_dwCountryID = 0;
  590. m_wRegion = 0;
  591. m_dwPhoneBook = 0;
  592. m_szPhoneNumber[0] = '\0';
  593. m_szDunFile[0] = '\0';
  594. m_fType = 0;
  595. m_bMask = 0;
  596. m_fHasRegions = FALSE;
  597. m_hwndDlg = NULL;
  598. m_dwFlags = 0;
  599. }
  600. // ############################################################################
  601. HRESULT CSelectNumDlg::FillNumber()
  602. {
  603. HRESULT hr = ERROR_NOT_ENOUGH_MEMORY;
  604. PACCESSENTRY pAELast, pAE = NULL;
  605. CPhoneBook far *pcPBTemp;
  606. unsigned int idx;
  607. pcPBTemp = ((CPhoneBook far *)m_dwPhoneBook);
  608. // Check if we need to look up the number from the region or from the country
  609. //
  610. if (m_fHasRegions && m_wRegion)
  611. pAE = pcPBTemp->m_rgState[m_wRegion-1].paeFirst;
  612. // Find the Access Entries for the country
  613. //
  614. if (!pAE)
  615. {
  616. LPIDLOOKUPELEMENT pIDLookUp, pLookUpTarget;
  617. pLookUpTarget = (LPIDLOOKUPELEMENT)GlobalAlloc(GPTR,sizeof(IDLOOKUPELEMENT));
  618. Assert(pLookUpTarget);
  619. if (!pLookUpTarget) goto FillNumberExit;
  620. pLookUpTarget->dwID = m_dwCountryID;
  621. pIDLookUp = NULL;
  622. pIDLookUp = (LPIDLOOKUPELEMENT)bsearch(pLookUpTarget,pcPBTemp->m_rgIDLookUp,
  623. (int)pcPBTemp->m_pLineCountryList->dwNumCountries,sizeof(IDLOOKUPELEMENT),CompareIDLookUpElements);
  624. if (pIDLookUp)
  625. pAE = pIDLookUp->pFirstAE;
  626. }
  627. // Fill the list for whatever AE's we found
  628. //
  629. SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,CB_RESETCONTENT,0,0);
  630. if (pAE)
  631. {
  632. //pAELast = pcPBTemp->m_rgPhoneBookEntry + pcPBTemp->m_cPhoneBookEntries;
  633. pAELast = &(pcPBTemp->m_rgPhoneBookEntry[pcPBTemp->m_cPhoneBookEntries - 1]);
  634. while (pAELast > pAE && pAE->dwCountryID == m_dwCountryID && pAE->wStateID == m_wRegion)
  635. {
  636. if ((pAE->fType & m_bMask) == m_fType)
  637. {
  638. wsprintf(szTemp,"%s (%s) %s",pAE->szCity,pAE->szAreaCode,
  639. pAE->szAccessNumber);
  640. idx = (int)SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,
  641. CB_ADDSTRING,0,
  642. (LPARAM)((LPSTR) &szTemp[0]));
  643. if (idx == -1) goto FillNumberExit;
  644. SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,CB_SETITEMDATA,
  645. (WPARAM)idx,(LPARAM)pAE);
  646. }
  647. pAE++;
  648. }
  649. // Select the first item
  650. //
  651. if (SendDlgItemMessage(m_hwndDlg,IDC_CMBNUMBER,CB_SETCURSEL,0,0) == CB_ERR)
  652. EnableWindow(GetDlgItem(m_hwndDlg,IDC_CMDNEXT),FALSE);
  653. else
  654. EnableWindow(GetDlgItem(m_hwndDlg,IDC_CMDNEXT),TRUE);
  655. hr = ERROR_SUCCESS;
  656. }
  657. FillNumberExit:
  658. return hr;
  659. }