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.

869 lines
30 KiB

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