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.

1537 lines
44 KiB

  1. //-------------------------------------------------------------------
  2. //
  3. // FILE: Config.cpp
  4. //
  5. // Summary;
  6. // This file contains the dialog proc for IDD_CPADLG_LCACONF
  7. //
  8. // History;
  9. // Feb-06-95 ChandanS Created
  10. // Mar-14-95 MikeMi Added F1 Message Filter and PWM_HELP message
  11. // Mar-30-95 MikeMi Added Replication Help Context
  12. // Dec-15-95 JeffParh Disallowed local server as own enterprise server.
  13. // Feb-28-96 JeffParh Moved from private cpArrow window class to
  14. // Up-Down common ctrl, in the process fixing the
  15. // multi-colored background problems
  16. // Apr-17-96 JeffParh Imported variable definitions that were in the
  17. // config.hpp header file.
  18. //
  19. //-------------------------------------------------------------------
  20. #include <windows.h>
  21. #include <commctrl.h>
  22. #include "resource.h"
  23. #include <stdlib.h>
  24. #include <tchar.h>
  25. #include <wchar.h>
  26. #include <htmlhelp.h>
  27. #include "liccpa.hpp"
  28. #include "config.hpp"
  29. #include <strsafe.h>
  30. extern "C"
  31. {
  32. #include <lmcons.h>
  33. #include <icanon.h>
  34. INT_PTR CALLBACK dlgprocLICCPACONFIG( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  35. }
  36. static BOOL OnEnSetFocus( HWND hwndDlg, short nID );
  37. static BOOL OnDeltaPosSpinTime( HWND hwndDlg, NM_UPDOWN * pnmud );
  38. static HBRUSH OnCtlColorStatic( HWND hwndDlg, HDC hDC, HWND hwndStatic );
  39. DWORD HOUR_MIN = HOUR_MIN_24;
  40. DWORD HOUR_MAX = HOUR_MAX_24;
  41. DWORD HOUR_PAGE = HOUR_PAGE_24;
  42. SERVICEPARAMS ServParams;
  43. static PSERVICEPARAMS pServParams = &ServParams;
  44. // JBP 96/04/17 : This #ifdef should not be necessary; the default is only used
  45. // in the event that GetLocalInfo() fails.
  46. //
  47. // #ifdef JAPAN
  48. // INTLSTRUCT IntlDefault = { 1,
  49. // 0,
  50. // TEXT(""),
  51. // TEXT(""),
  52. // TEXT(":")
  53. // };
  54. // #else
  55. INTLSTRUCT IntlDefault = { 0,
  56. 0,
  57. TEXT("AM"),
  58. TEXT("PM"),
  59. TEXT(":")
  60. };
  61. // #endif
  62. INTLSTRUCT IntlCurrent;
  63. //-------------------------------------------------------------------
  64. // Function: GetLocaleValue
  65. //
  66. // Summary:
  67. //
  68. // In:
  69. // lcid :
  70. // lcType :
  71. // pszStr :
  72. // size :
  73. // pszDefault :
  74. // Out:
  75. // Returns:
  76. //
  77. // Caveats:
  78. //
  79. // History:
  80. // Feb-07-95 ChandanS Created
  81. //-------------------------------------------------------------------
  82. int GetLocaleValue(
  83. LCID lcid,
  84. LCTYPE lcType,
  85. WCHAR *pszStr,
  86. int chSize,
  87. LPWSTR pszDefault )
  88. {
  89. /*
  90. * Initialize the output buffer.
  91. */
  92. if (NULL == pszStr)
  93. return (-1);
  94. *pszStr = (WCHAR) 0;
  95. /*
  96. * Get the locale information.
  97. */
  98. if (!GetLocaleInfo ( lcid,
  99. lcType,
  100. pszStr,
  101. chSize ))
  102. {
  103. /*
  104. * Couldn't get info from GetLocaleInfo.
  105. */
  106. if (pszDefault)
  107. {
  108. /*
  109. * Return the default info.
  110. */
  111. HRESULT hr = StringCchCopy(pszStr, chSize, pszDefault);
  112. if (FAILED(hr))
  113. return (-1);
  114. }
  115. else
  116. {
  117. /*
  118. * Return error.
  119. */
  120. return (-1);
  121. }
  122. }
  123. /*
  124. * Convert the string to an integer and return the result.
  125. * This will only be used by the caller of this routine when
  126. * appropriate.
  127. */
  128. return ( _wtoi(pszStr) );
  129. }
  130. //-------------------------------------------------------------------
  131. // Function: TimeInit
  132. //
  133. // Summary:
  134. //
  135. // In:
  136. // Out:
  137. // Returns:
  138. //
  139. // Caveats:
  140. //
  141. // History:
  142. // Feb-07-95 ChandanS Created
  143. //-------------------------------------------------------------------
  144. VOID TimeInit()
  145. {
  146. WCHAR szTemp[128];
  147. GetLocaleValue (0,
  148. LOCALE_STIME,
  149. IntlCurrent.szTime,
  150. sizeof(IntlCurrent.szTime)/sizeof(IntlCurrent.szTime[0]),
  151. IntlDefault.szTime);
  152. GetLocaleValue (0,
  153. LOCALE_ITLZERO,
  154. szTemp,
  155. sizeof(szTemp)/sizeof(szTemp[0]),
  156. TEXT("0"));
  157. IntlCurrent.iTLZero = _wtoi(szTemp);
  158. GetLocaleValue (0,
  159. LOCALE_ITIME,
  160. szTemp,
  161. sizeof(szTemp)/sizeof(szTemp[0]),
  162. TEXT("0"));
  163. IntlCurrent.iTime = _wtoi(szTemp);
  164. if (!IntlCurrent.iTime)
  165. {
  166. GetLocaleValue (0,
  167. LOCALE_S1159,
  168. IntlCurrent.sz1159,
  169. sizeof(IntlCurrent.sz1159)/sizeof(IntlCurrent.sz1159[0]),
  170. IntlDefault.sz1159);
  171. GetLocaleValue (0,
  172. LOCALE_S2359,
  173. IntlCurrent.sz2359,
  174. sizeof(IntlCurrent.sz2359)/sizeof(IntlCurrent.sz2359[0]),
  175. IntlDefault.sz2359);
  176. HOUR_MIN = HOUR_MIN_12;
  177. HOUR_MAX = HOUR_MAX_12;
  178. HOUR_PAGE = HOUR_PAGE_12;
  179. }
  180. }
  181. //-------------------------------------------------------------------
  182. // Function: ReadRegistry
  183. //
  184. // Summary:
  185. // Opens the registry & reads in the key values
  186. //
  187. // In:
  188. // Out:
  189. // Returns:
  190. //
  191. // Caveats:
  192. //
  193. // History:
  194. // Feb-07-95 ChandanS Created
  195. //-------------------------------------------------------------------
  196. LONG ReadRegistry()
  197. {
  198. DWORD dwDisposition;
  199. LONG lrt;
  200. BOOL fNew;
  201. HKEY hKey;
  202. fNew = FALSE;
  203. lrt = ::RegCreateKeyEx( HKEY_LOCAL_MACHINE,
  204. szLicenseKey,
  205. 0,
  206. NULL,
  207. REG_OPTION_NON_VOLATILE,
  208. KEY_ALL_ACCESS,
  209. NULL,
  210. &hKey,
  211. &dwDisposition );
  212. if ((ERROR_SUCCESS == lrt) &&
  213. (REG_CREATED_NEW_KEY == dwDisposition) )
  214. {
  215. fNew = TRUE;
  216. // Set normal values
  217. //
  218. lrt = ::RegSetValueEx( hKey,
  219. szUseEnterprise,
  220. 0,
  221. REG_DWORD,
  222. (PBYTE)&dwUseEnterprise,
  223. sizeof( DWORD ) );
  224. if (ERROR_SUCCESS == lrt)
  225. {
  226. lrt = ::RegSetValueEx( hKey,
  227. szReplicationType,
  228. 0,
  229. REG_DWORD,
  230. (PBYTE)&dwReplicationType,
  231. sizeof( DWORD ) );
  232. if (ERROR_SUCCESS == lrt)
  233. {
  234. lrt = ::RegSetValueEx( hKey,
  235. szReplicationTime,
  236. 0,
  237. REG_DWORD,
  238. (PBYTE)&dwReplicationTimeInSec, // In seconds
  239. sizeof( DWORD ) );
  240. if (ERROR_SUCCESS == lrt)
  241. {
  242. WCHAR szNull[] = L"";
  243. lrt = ::RegSetValueEx( hKey,
  244. szEnterpriseServer,
  245. 0,
  246. REG_SZ,
  247. (PBYTE)szNull,
  248. sizeof(WCHAR));
  249. }
  250. }
  251. }
  252. }
  253. if (ERROR_SUCCESS == lrt)
  254. { // read values into pServParams
  255. DWORD dwSize = sizeof( DWORD );
  256. DWORD dwRegType = REG_DWORD;
  257. lrt = ::RegQueryValueEx( hKey,
  258. (LPWSTR)szUseEnterprise,
  259. 0,
  260. &dwRegType,
  261. (PBYTE)&(pServParams->dwUseEnterprise),
  262. &dwSize );
  263. if (lrt == REG_OPENED_EXISTING_KEY)
  264. {
  265. lrt = ::RegSetValueEx( hKey,
  266. szUseEnterprise,
  267. 0,
  268. REG_DWORD,
  269. (PBYTE)&dwUseEnterprise,
  270. sizeof( DWORD ) );
  271. pServParams->dwUseEnterprise = dwUseEnterprise;
  272. }
  273. else if ((dwRegType != REG_DWORD) ||
  274. (dwSize != sizeof( DWORD )) )
  275. {
  276. lrt = ERROR_BADDB;
  277. }
  278. if (!lrt )
  279. {
  280. dwSize = sizeof( DWORD );
  281. dwRegType = REG_DWORD;
  282. lrt = ::RegQueryValueEx( hKey,
  283. (LPWSTR)szReplicationType,
  284. 0,
  285. &dwRegType,
  286. (PBYTE)&(pServParams->dwReplicationType),
  287. &dwSize );
  288. if (lrt == REG_OPENED_EXISTING_KEY)
  289. {
  290. lrt = ::RegSetValueEx( hKey,
  291. szReplicationType,
  292. 0,
  293. REG_DWORD,
  294. (PBYTE)&dwReplicationType,
  295. sizeof(DWORD));
  296. pServParams->dwReplicationType = dwReplicationType;
  297. }
  298. else if ( lrt || (dwRegType != REG_DWORD) ||
  299. (dwSize != sizeof( DWORD )) )
  300. {
  301. lrt = ERROR_BADDB;
  302. }
  303. if (!lrt)
  304. {
  305. dwSize = sizeof( DWORD );
  306. dwRegType = REG_DWORD;
  307. lrt = ::RegQueryValueEx( hKey,
  308. (LPWSTR)szReplicationTime,
  309. 0,
  310. &dwRegType,
  311. (PBYTE)&(pServParams->dwReplicationTime),
  312. &dwSize );
  313. if (lrt == REG_OPENED_EXISTING_KEY)
  314. {
  315. lrt = ::RegSetValueEx( hKey,
  316. szReplicationTime,
  317. 0,
  318. REG_DWORD,
  319. (PBYTE)&dwReplicationTimeInSec,
  320. sizeof(DWORD));
  321. pServParams->dwReplicationTime = dwReplicationTimeInSec;
  322. }
  323. else if ( (dwRegType != REG_DWORD) ||
  324. (dwSize != sizeof( DWORD )) )
  325. {
  326. lrt = ERROR_BADDB;
  327. }
  328. if (!lrt)
  329. {
  330. dwRegType = REG_SZ;
  331. lrt = RegQueryValueEx( hKey,
  332. (LPWSTR)szEnterpriseServer,
  333. 0,
  334. &dwRegType,
  335. (PBYTE)NULL, //request for size
  336. &dwSize );
  337. if (lrt == REG_OPENED_EXISTING_KEY)
  338. {
  339. WCHAR szNull[] = L"";
  340. lrt = ::RegSetValueEx( hKey,
  341. szEnterpriseServer,
  342. 0,
  343. REG_SZ,
  344. (PBYTE)szNull,
  345. sizeof(WCHAR));
  346. HRESULT hr;
  347. size_t cch = wcslen(szNull) + 1;
  348. pServParams->pszEnterpriseServer = (LPWSTR)GlobalAlloc(GPTR, cch * sizeof(WCHAR));
  349. hr = StringCchCopy(pServParams->pszEnterpriseServer, cch, szNull);
  350. if (S_OK != hr)
  351. lrt = ERROR_BADDB;
  352. }
  353. else if (dwRegType != REG_SZ)
  354. {
  355. lrt = ERROR_BADDB;
  356. }
  357. else
  358. {
  359. pServParams->pszEnterpriseServer = (LPWSTR) GlobalAlloc(GPTR, dwSize);
  360. if (pServParams->pszEnterpriseServer)
  361. {
  362. lrt = ::RegQueryValueEx( hKey,
  363. (LPWSTR)szEnterpriseServer,
  364. 0,
  365. &dwRegType,
  366. (PBYTE)(pServParams->pszEnterpriseServer),
  367. &dwSize );
  368. if ( (dwRegType != REG_SZ) ||
  369. (dwSize != (wcslen(pServParams->pszEnterpriseServer ) + 1) * sizeof(WCHAR)))
  370. {
  371. lrt = ERROR_BADDB;
  372. }
  373. }
  374. else
  375. {
  376. lrt = ERROR_BADDB;
  377. }
  378. }
  379. }
  380. }
  381. }
  382. }
  383. if (hKey && lrt == ERROR_SUCCESS)
  384. {
  385. // Init the globals
  386. if (pServParams->dwReplicationType)
  387. {
  388. DWORD dwTemp = pServParams->dwReplicationTime;
  389. pServParams->dwHour = dwTemp / (60 * 60);
  390. pServParams->dwMinute = (dwTemp - (pServParams->dwHour * 60 * 60)) / 60;
  391. pServParams->dwSecond = dwTemp - (pServParams->dwHour * 60 * 60) -
  392. (pServParams->dwMinute * 60);
  393. if (!IntlCurrent.iTime)
  394. { // it's in 12 hour format
  395. if (pServParams->dwHour > 12)
  396. {
  397. pServParams->fPM = TRUE;
  398. pServParams->dwHour -= 12;
  399. }
  400. else if (pServParams->dwHour == 12)
  401. {
  402. pServParams->fPM = TRUE;
  403. }
  404. else
  405. {
  406. if (pServParams->dwHour == 0)
  407. pServParams->dwHour = HOUR_MAX;
  408. pServParams->fPM = FALSE;
  409. }
  410. }
  411. }
  412. else
  413. {
  414. pServParams->dwReplicationTime = pServParams->dwReplicationTime / (60 * 60);
  415. if (!IntlCurrent.iTime)
  416. // it's in 12 hour format
  417. pServParams->dwHour = HOUR_MAX;
  418. else
  419. pServParams->dwHour = HOUR_MIN;
  420. pServParams->dwMinute = MINUTE_MIN;
  421. pServParams->dwSecond = SECOND_MIN;
  422. pServParams->fPM = FALSE;
  423. }
  424. return (RegCloseKey(hKey));
  425. }
  426. else if (hKey)
  427. RegCloseKey(hKey);
  428. return( lrt );
  429. }
  430. //-------------------------------------------------------------------
  431. // Function: ConfigAccessOk
  432. //
  433. // Summary:
  434. // Checks access rights form reg call and raise dialog as needed
  435. //
  436. // In:
  437. // hDlg - Handle to working dialog to raise error dlgs with
  438. // lrc - the return status from a reg call
  439. // Out:
  440. // Returns:
  441. //
  442. // Caveats:
  443. //
  444. // History:
  445. // Feb-07-95 ChandanS Created
  446. //-------------------------------------------------------------------
  447. inline BOOL ConfigAccessOk( HWND hDlg, LONG lrc )
  448. {
  449. BOOL frt = TRUE;
  450. if (ERROR_SUCCESS != lrc)
  451. {
  452. WCHAR szText[TEMPSTR_SIZE];
  453. WCHAR szTitle[TEMPSTR_SIZE];
  454. UINT wId;
  455. if (ERROR_ACCESS_DENIED == lrc)
  456. {
  457. wId = IDS_NOACCESS;
  458. }
  459. else
  460. {
  461. wId = IDS_BADREG;
  462. }
  463. LoadString(g_hinst, IDS_CPCAPTION, szTitle, TEMPSTR_SIZE);
  464. LoadString(g_hinst, wId, szText, TEMPSTR_SIZE);
  465. MessageBox (hDlg, szText, szTitle, MB_OK|MB_ICONSTOP);
  466. frt = FALSE;
  467. }
  468. return( frt );
  469. }
  470. //-------------------------------------------------------------------
  471. // Function: ConfigInitUserEdit
  472. //
  473. // Summary:
  474. // Initializes and defines user count edit control behaviour
  475. //
  476. // In:
  477. // hwndDlg - Parent dialog of user count edit dialog
  478. // Out:
  479. // Returns:
  480. //
  481. // Caveats:
  482. //
  483. // History:
  484. // Feb-07-95 ChandanS Created
  485. //-------------------------------------------------------------------
  486. void ConfigInitUserEdit( HWND hwndDlg )
  487. {
  488. HWND hwndCount = GetDlgItem( hwndDlg, IDC_HOURS);
  489. SendMessage( hwndCount, EM_LIMITTEXT, cchEDITLIMIT, 0 );
  490. hwndCount = GetDlgItem( hwndDlg, IDC_HOUR);
  491. SendMessage( hwndCount, EM_LIMITTEXT, cchEDITLIMIT, 0 );
  492. hwndCount = GetDlgItem( hwndDlg, IDC_MINUTE);
  493. SendMessage( hwndCount, EM_LIMITTEXT, cchEDITLIMIT, 0 );
  494. hwndCount = GetDlgItem( hwndDlg, IDC_SECOND);
  495. SendMessage( hwndCount, EM_LIMITTEXT, cchEDITLIMIT, 0 );
  496. hwndCount = GetDlgItem( hwndDlg, IDC_AMPM);
  497. SendMessage( hwndCount, EM_LIMITTEXT, max(wcslen(IntlCurrent.sz1159),
  498. wcslen(IntlCurrent.sz2359)), 0 );
  499. SetDlgItemText (hwndDlg, IDC_TIMESEP1, IntlCurrent.szTime);
  500. SetDlgItemText (hwndDlg, IDC_TIMESEP2, IntlCurrent.szTime);
  501. }
  502. //-------------------------------------------------------------------
  503. // Function: ConfigInitDialogForService
  504. //
  505. // Summary:
  506. // Initialize dialog controls to the service state
  507. //
  508. // In:
  509. // hwndDlg - Parent dialog to init controls in
  510. // Out:
  511. // Returns:
  512. //
  513. // Caveats:
  514. //
  515. // History:
  516. // Feb-07-95 ChandanS Created
  517. // Feb-28-96 JeffParh Added range set for interval spin ctrl
  518. //-------------------------------------------------------------------
  519. void ConfigInitDialogForService( HWND hwndDlg, DWORD dwGroup )
  520. {
  521. HRESULT hr;
  522. HWND hwndHour = GetDlgItem( hwndDlg, IDC_HOUR);
  523. HWND hwndMinute = GetDlgItem( hwndDlg, IDC_MINUTE);
  524. HWND hwndSecond = GetDlgItem( hwndDlg, IDC_SECOND);
  525. HWND hwndAMPM = GetDlgItem( hwndDlg, IDC_AMPM);
  526. HWND hwndInterval = GetDlgItem( hwndDlg, IDC_HOURS);
  527. HWND hwndIntervalSpin = GetDlgItem( hwndDlg, IDC_HOURARROW );
  528. HWND hwndTimeSpin = GetDlgItem( hwndDlg, IDC_TIMEARROW );
  529. BOOL fReplAtTime = (pServParams->dwReplicationType);
  530. if (dwGroup == ATINIT || dwGroup == FORTIME)
  531. {
  532. if (fReplAtTime)
  533. {
  534. WCHAR szTemp[3];
  535. CheckDlgButton( hwndDlg, IDC_REPL_TIME, fReplAtTime);
  536. CheckDlgButton( hwndDlg, IDC_REPL_INT, !fReplAtTime);
  537. if (IntlCurrent.iTLZero)
  538. {
  539. hr = StringCbPrintf(szTemp, sizeof(szTemp), TEXT("%02u"), pServParams->dwHour);
  540. if (S_OK != hr)
  541. return;
  542. szTemp[2] = UNICODE_NULL;
  543. SetDlgItemText( hwndDlg, IDC_HOUR, szTemp);
  544. }
  545. else
  546. {
  547. SetDlgItemInt( hwndDlg, IDC_HOUR, pServParams->dwHour, FALSE );
  548. }
  549. hr = StringCbPrintf(szTemp, sizeof(szTemp), TEXT("%02u"), pServParams->dwMinute);
  550. if (S_OK != hr)
  551. return;
  552. szTemp[2] = UNICODE_NULL;
  553. SetDlgItemText( hwndDlg, IDC_MINUTE, szTemp);
  554. hr = StringCbPrintf(szTemp, sizeof(szTemp), TEXT("%02u"), pServParams->dwSecond);
  555. if (S_OK != hr)
  556. return;
  557. szTemp[2] = UNICODE_NULL;
  558. SetDlgItemText( hwndDlg, IDC_SECOND, szTemp);
  559. if (pServParams->fPM)
  560. SetDlgItemText( hwndDlg, IDC_AMPM, IntlCurrent.sz2359);
  561. else
  562. SetDlgItemText( hwndDlg, IDC_AMPM, IntlCurrent.sz1159);
  563. SetDlgItemText( hwndDlg, IDC_HOURS, L"");
  564. SetFocus(GetDlgItem(hwndDlg, IDC_REPL_TIME));
  565. }
  566. else
  567. {
  568. CheckDlgButton( hwndDlg, IDC_REPL_INT, !fReplAtTime);
  569. CheckDlgButton( hwndDlg, IDC_REPL_TIME, fReplAtTime);
  570. SetDlgItemInt( hwndDlg, IDC_HOURS, pServParams->dwReplicationTime, FALSE);
  571. SetDlgItemText( hwndDlg, IDC_HOUR, L"");
  572. SetDlgItemText( hwndDlg, IDC_MINUTE, L"");
  573. SetDlgItemText( hwndDlg, IDC_SECOND, L"");
  574. SetDlgItemText( hwndDlg, IDC_AMPM, L"");
  575. SetFocus(GetDlgItem(hwndDlg, IDC_REPL_INT));
  576. }
  577. EnableWindow( hwndTimeSpin, fReplAtTime);
  578. EnableWindow( hwndHour, fReplAtTime);
  579. EnableWindow( hwndMinute, fReplAtTime);
  580. EnableWindow( hwndSecond, fReplAtTime);
  581. if ( IntlCurrent.iTime )
  582. {
  583. ShowWindow( hwndAMPM, SW_HIDE );
  584. }
  585. else
  586. {
  587. EnableWindow( hwndAMPM, fReplAtTime );
  588. }
  589. EnableWindow( hwndInterval, !fReplAtTime);
  590. EnableWindow( hwndIntervalSpin, !fReplAtTime);
  591. SendMessage( hwndIntervalSpin, UDM_SETRANGE, 0, (LPARAM) MAKELONG( (short) INTERVAL_MAX, (short) INTERVAL_MIN ) );
  592. }
  593. }
  594. //-------------------------------------------------------------------
  595. // Function: ConfigFreeServiceEntry
  596. //
  597. // Summary:
  598. // Free all allocated memory when a service structure is created
  599. //
  600. // In:
  601. // pServParams - The Service structure to free
  602. // Out:
  603. // Returns:
  604. //
  605. // Caveats:
  606. //
  607. // History:
  608. // Feb-07-95 ChandanS Created
  609. //-------------------------------------------------------------------
  610. void ConfigFreeServiceEntry( )
  611. {
  612. if (pServParams->pszEnterpriseServer)
  613. GlobalFree( pServParams->pszEnterpriseServer );
  614. }
  615. //-------------------------------------------------------------------
  616. // Function: ConfigSaveServiceToReg
  617. //
  618. // Summary:
  619. // Save the given Service structure to the registry
  620. //
  621. // In:
  622. // pServParams - Service structure to save
  623. // Out:
  624. // Returns:
  625. //
  626. // Caveats:
  627. //
  628. // History:
  629. // Feb-07-95 ChandanS Created
  630. //-------------------------------------------------------------------
  631. void ConfigSaveServiceToReg( )
  632. {
  633. DWORD dwDisposition;
  634. LONG lrt;
  635. HKEY hKey;
  636. if (!pServParams->dwReplicationType)
  637. pServParams->dwReplicationTime = pServParams->dwReplicationTime * 60 *60;
  638. lrt = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
  639. szLicenseKey,
  640. 0,
  641. NULL,
  642. REG_OPTION_NON_VOLATILE,
  643. KEY_ALL_ACCESS,
  644. NULL,
  645. &hKey,
  646. &dwDisposition );
  647. if (ERROR_SUCCESS == lrt)
  648. {
  649. lrt = RegSetValueEx( hKey,
  650. szUseEnterprise,
  651. 0,
  652. REG_DWORD,
  653. (PBYTE)&(pServParams->dwUseEnterprise),
  654. sizeof( DWORD ) );
  655. if (ERROR_SUCCESS == lrt)
  656. {
  657. lrt = RegSetValueEx( hKey,
  658. szEnterpriseServer,
  659. 0,
  660. REG_SZ,
  661. (PBYTE)pServParams->pszEnterpriseServer,
  662. (DWORD)(wcslen (pServParams->pszEnterpriseServer) + 1) * sizeof(WCHAR));
  663. if (ERROR_SUCCESS == lrt)
  664. {
  665. lrt = RegSetValueEx( hKey,
  666. szReplicationTime,
  667. 0,
  668. REG_DWORD,
  669. (PBYTE)&(pServParams->dwReplicationTime),
  670. sizeof( DWORD ) );
  671. if (ERROR_SUCCESS == lrt)
  672. {
  673. lrt = ::RegSetValueEx( hKey,
  674. szReplicationType,
  675. 0,
  676. REG_DWORD,
  677. (PBYTE)&(pServParams->dwReplicationType),
  678. sizeof( DWORD ) );
  679. }
  680. }
  681. }
  682. }
  683. if (hKey && lrt == ERROR_SUCCESS)
  684. lrt = RegCloseKey(hKey);
  685. else if (hKey)
  686. lrt = RegCloseKey(hKey);
  687. }
  688. //-------------------------------------------------------------------
  689. // Function: ConfigEditInvalidDlg
  690. //
  691. // Summary:
  692. // Display Dialog when user count edit control value is invalid
  693. //
  694. // In:
  695. // hwndDlg - hwnd of dialog
  696. // Out:
  697. // Returns:
  698. //
  699. // Caveats:
  700. //
  701. // History:
  702. // Feb-07-95 ChandanS Created
  703. //-------------------------------------------------------------------
  704. void ConfigEditInvalidDlg( HWND hwndDlg, short nID, BOOL fBeep)
  705. {
  706. HWND hwnd = GetDlgItem( hwndDlg, nID);
  707. if (fBeep) //If we've already put up a MessageBox, we shouldn't beep
  708. MessageBeep( MB_VALUELIMIT );
  709. SetFocus(hwnd);
  710. SendMessage(hwnd, EM_SETSEL, 0, -1 );
  711. }
  712. //-------------------------------------------------------------------
  713. // Function: ConfigEditValidate
  714. //
  715. // Summary:
  716. // Handle when the value within the user count edit control changes
  717. //
  718. // In:
  719. // hwndDlg - hwnd of dialog
  720. // pserv - currently selected service
  721. // Out:
  722. // Returns: FALSE if Edit Value is not valid, TRUE if it is
  723. //
  724. // Caveats:
  725. //
  726. // History:
  727. // Feb-07-95 ChandanS Created
  728. //-------------------------------------------------------------------
  729. #pragma warning (push)
  730. #pragma warning (disable : 4127) //avoid warning on while false
  731. BOOL ConfigEditValidate( HWND hwndDlg, short *pnID, BOOL *pfBeep)
  732. {
  733. UINT nValue;
  734. BOOL fValid = FALSE;
  735. WCHAR szTemp[MAX_PATH + 1];
  736. DWORD NumberOfHours, SecondsinHours;
  737. *pfBeep = TRUE;
  738. // only do this if license info is replicated to an ES
  739. do {
  740. if (IsDlgButtonChecked(hwndDlg, IDC_REPL_INT))
  741. {
  742. nValue = GetDlgItemInt( hwndDlg, IDC_HOURS, &fValid, FALSE);
  743. *pnID = IDC_HOURS;
  744. if (fValid)
  745. {
  746. if (nValue < INTERVAL_MIN)
  747. {
  748. fValid = FALSE;
  749. pServParams->dwReplicationTime = INTERVAL_MIN;
  750. SetDlgItemInt(hwndDlg, IDC_HOURS, INTERVAL_MIN, FALSE);
  751. break;
  752. }
  753. else if (nValue > INTERVAL_MAX)
  754. {
  755. fValid = FALSE;
  756. pServParams->dwReplicationTime = INTERVAL_MAX;
  757. SetDlgItemInt(hwndDlg, IDC_HOURS, INTERVAL_MAX, FALSE);
  758. break;
  759. }
  760. else
  761. pServParams->dwReplicationTime = nValue;
  762. }
  763. else
  764. {
  765. fValid = FALSE;
  766. break;
  767. }
  768. pServParams->dwReplicationType = FALSE;
  769. }
  770. else
  771. {
  772. nValue = GetDlgItemInt( hwndDlg, IDC_HOUR, &fValid, FALSE);
  773. if (fValid)
  774. pServParams->dwHour = nValue;
  775. else
  776. {
  777. *pnID = IDC_HOUR;
  778. break;
  779. }
  780. nValue = GetDlgItemInt( hwndDlg, IDC_MINUTE, &fValid, FALSE);
  781. if (fValid)
  782. pServParams->dwMinute = nValue;
  783. else
  784. {
  785. *pnID = IDC_MINUTE;
  786. break;
  787. }
  788. nValue = GetDlgItemInt( hwndDlg, IDC_SECOND, &fValid, FALSE);
  789. if (fValid)
  790. pServParams->dwSecond = nValue;
  791. else
  792. {
  793. *pnID = IDC_SECOND;
  794. break;
  795. }
  796. if (!IntlCurrent.iTime)
  797. {
  798. *pnID = IDC_AMPM;
  799. nValue = GetDlgItemText( hwndDlg, IDC_AMPM, szTemp, MAX_PATH);
  800. if (nValue == 0)
  801. {
  802. fValid = FALSE;
  803. break;
  804. }
  805. szTemp[nValue] = UNICODE_NULL;
  806. if (!_wcsicmp(szTemp, IntlCurrent.sz1159))
  807. {
  808. pServParams->fPM = FALSE;
  809. }
  810. else if (!_wcsicmp(szTemp, IntlCurrent.sz2359))
  811. {
  812. pServParams->fPM = TRUE;
  813. }
  814. else
  815. {
  816. fValid = FALSE;
  817. break;
  818. }
  819. }
  820. if (!IntlCurrent.iTime)
  821. { // It's in 12 hour format
  822. if (pServParams->fPM)
  823. {
  824. NumberOfHours = 12 + pServParams->dwHour -
  825. ((pServParams->dwHour / 12) * 12);
  826. }
  827. else
  828. {
  829. NumberOfHours = pServParams->dwHour -
  830. ((pServParams->dwHour / 12) * 12);
  831. }
  832. }
  833. else
  834. { // It's in 24 hour format
  835. NumberOfHours = pServParams->dwHour;
  836. }
  837. SecondsinHours = NumberOfHours * 60 * 60;
  838. pServParams->dwReplicationTime = SecondsinHours +
  839. (pServParams->dwMinute * 60) + pServParams->dwSecond;
  840. pServParams->dwReplicationType = TRUE;
  841. }
  842. } while(FALSE);
  843. return( fValid );
  844. }
  845. #pragma warning (pop) //4127
  846. //-------------------------------------------------------------------
  847. // Function: OnCpaConfigClose
  848. //
  849. // Summary:
  850. // Do work needed when the Control Panel applet is closed.
  851. // Free all Service structures alloced and possible save.
  852. //
  853. // In:
  854. // hwndDlg - Dialog close was requested on
  855. // fSave - Save Services to Registry
  856. // Out:
  857. // Returns:
  858. //
  859. // Caveats:
  860. //
  861. // History:
  862. // Feb-07-95 ChandanS Created
  863. //-------------------------------------------------------------------
  864. void OnCpaConfigClose( HWND hwndDlg, BOOL fSave , WPARAM wParam)
  865. {
  866. UNREFERENCED_PARAMETER(wParam);
  867. short nID;
  868. BOOL fBeep = TRUE;
  869. if (fSave)
  870. {
  871. if ( ConfigEditValidate(hwndDlg, &nID, &fBeep))
  872. {
  873. ConfigSaveServiceToReg( );
  874. ConfigFreeServiceEntry( );
  875. EndDialog( hwndDlg, fSave );
  876. }
  877. else
  878. {
  879. ConfigEditInvalidDlg(hwndDlg, nID, fBeep);
  880. }
  881. }
  882. else
  883. {
  884. ConfigFreeServiceEntry( );
  885. EndDialog( hwndDlg, fSave );
  886. }
  887. }
  888. //-------------------------------------------------------------------
  889. // Function: OnSetReplicationTime
  890. //
  891. // Summary:
  892. // Handle the users request to change replication time
  893. //
  894. // In:
  895. // hwndDlg - hwnd of dialog
  896. // idCtrl - the control id that was pressed to make this request
  897. // Out:
  898. // Returns:
  899. //
  900. // Caveats:
  901. //
  902. // History:
  903. // Feb-07-95 ChandanS Created
  904. // Feb-28-96 JeffParh Added code to modify time bg color
  905. //-------------------------------------------------------------------
  906. void OnSetReplicationTime( HWND hwndDlg, WORD idCtrl )
  907. {
  908. if (idCtrl == IDC_REPL_INT)
  909. {
  910. pServParams->dwReplicationType = dwReplicationType;
  911. }
  912. else
  913. {
  914. pServParams->dwReplicationType = !dwReplicationType;
  915. }
  916. // Edit control within this IDC_TIMEEDIT_BORDER should be subclassed and
  917. // use some other backgroup brush to repaint the background.
  918. // following code works but...
  919. // change the background color of the time edit control
  920. HWND hwndTimeEdit = GetDlgItem( hwndDlg, IDC_TIMEEDIT_BORDER );
  921. InvalidateRect( hwndTimeEdit, NULL, TRUE );
  922. UpdateWindow( hwndTimeEdit );
  923. HWND hwndTimeSep1 = GetDlgItem( hwndDlg, IDC_TIMESEP1 );
  924. InvalidateRect( hwndTimeSep1, NULL, TRUE );
  925. UpdateWindow( hwndTimeSep1 );
  926. HWND hwndTimeSep2 = GetDlgItem( hwndDlg, IDC_TIMESEP2 );
  927. InvalidateRect( hwndTimeSep2, NULL, TRUE );
  928. UpdateWindow( hwndTimeSep2 );
  929. InvalidateRect(
  930. GetDlgItem(hwndDlg, IDC_TIMEARROW),
  931. NULL,
  932. FALSE
  933. );
  934. UpdateWindow( GetDlgItem(hwndDlg, IDC_TIMEARROW) );
  935. ConfigInitDialogForService( hwndDlg, FORTIME);
  936. }
  937. //-------------------------------------------------------------------
  938. // Function: OnCpaConfigInitDialog
  939. //
  940. // Summary:
  941. // Handle the initialization of the Control Panel Applet Dialog
  942. //
  943. // In:
  944. // hwndDlg - the dialog to initialize
  945. // Out:
  946. // iSel - the current service selected
  947. // pServParams - the current service
  948. // Returns:
  949. // TRUE if succesful, otherwise false
  950. //
  951. // Caveats:
  952. //
  953. // History:
  954. // Feb-07-95 ChandanS Created
  955. //-------------------------------------------------------------------
  956. BOOL OnCpaConfigInitDialog( HWND hwndDlg)
  957. {
  958. BOOL frt;
  959. LONG lrt;
  960. TimeInit();
  961. // Do Registry stuff
  962. lrt = ReadRegistry();
  963. frt = ConfigAccessOk( hwndDlg, lrt );
  964. if (frt)
  965. {
  966. CenterDialogToScreen( hwndDlg );
  967. // Set edit text chars limit
  968. ConfigInitUserEdit( hwndDlg );
  969. ConfigInitDialogForService( hwndDlg, ATINIT);
  970. if (pServParams->dwReplicationType)
  971. SetFocus(GetDlgItem(hwndDlg, IDC_HOUR));
  972. else
  973. SetFocus(GetDlgItem(hwndDlg, IDC_HOURS));
  974. }
  975. else
  976. {
  977. EndDialog( hwndDlg, -1 );
  978. }
  979. return( frt );
  980. }
  981. //-------------------------------------------------------------------
  982. // Function: CheckNum
  983. //
  984. // Summary:
  985. //
  986. // In:
  987. // Out:
  988. // Returns:
  989. //
  990. // Caveats:
  991. //
  992. // History:
  993. // Feb-07-95 ChandanS Created
  994. //-------------------------------------------------------------------
  995. BOOL CheckNum (HWND hDlg, WORD nID)
  996. {
  997. short i;
  998. WCHAR szNum[4];
  999. BOOL bReturn;
  1000. INT iVal;
  1001. UINT nValue;
  1002. bReturn = TRUE;
  1003. // JonN 5/15/00: PREFIX 112120
  1004. ::ZeroMemory( szNum, sizeof(szNum) );
  1005. nValue = GetDlgItemText (hDlg, nID, szNum, 3);
  1006. for (i = 0; szNum[i]; i++)
  1007. if (!_istdigit (szNum[i]))
  1008. return (FALSE);
  1009. iVal = _wtoi(szNum);
  1010. switch (nID)
  1011. {
  1012. case IDC_HOURS:
  1013. if (!nValue)
  1014. {
  1015. pServParams->dwReplicationTime = dwReplicationTime;
  1016. break;
  1017. }
  1018. if (iVal < 9)
  1019. {
  1020. pServParams->dwReplicationTime = (DWORD)iVal;
  1021. break;
  1022. }
  1023. if ((iVal < INTERVAL_MIN) || (iVal > INTERVAL_MAX))
  1024. bReturn = FALSE;
  1025. else
  1026. pServParams->dwReplicationTime = (DWORD)iVal;
  1027. break;
  1028. case IDC_HOUR:
  1029. if (!nValue)
  1030. {
  1031. if (IntlCurrent.iTime)
  1032. { // 24 hour format
  1033. pServParams->dwHour = 0;
  1034. pServParams->fPM = FALSE;
  1035. }
  1036. else
  1037. { // 12 hour format
  1038. pServParams->dwHour = HOUR_MAX;
  1039. pServParams->fPM = FALSE;
  1040. }
  1041. break;
  1042. }
  1043. if ((iVal < (int)HOUR_MIN) || (iVal > (int)HOUR_MAX))
  1044. bReturn = FALSE;
  1045. break;
  1046. case IDC_MINUTE:
  1047. if (!nValue)
  1048. {
  1049. pServParams->dwMinute = MINUTE_MIN;
  1050. break;
  1051. }
  1052. if ((iVal < MINUTE_MIN) || (iVal > MINUTE_MAX))
  1053. bReturn = FALSE;
  1054. break;
  1055. case IDC_SECOND:
  1056. if (!nValue)
  1057. {
  1058. pServParams->dwSecond = SECOND_MIN;
  1059. break;
  1060. }
  1061. if ((iVal < SECOND_MIN) || (iVal > SECOND_MAX))
  1062. bReturn = FALSE;
  1063. break;
  1064. }
  1065. return (bReturn);
  1066. }
  1067. //-------------------------------------------------------------------
  1068. // Function: CheckAMPM
  1069. //
  1070. // Summary:
  1071. //
  1072. // In:
  1073. // Out:
  1074. // Returns:
  1075. //
  1076. // Caveats:
  1077. //
  1078. // History:
  1079. // Feb-07-95 ChandanS Created
  1080. //-------------------------------------------------------------------
  1081. BOOL CheckAMPM(HWND hDlg, WORD nID)
  1082. {
  1083. WCHAR szName[TIMESUF_LEN + 1];
  1084. UINT nValue;
  1085. nValue = GetDlgItemText (hDlg, nID, szName, TIMESUF_LEN);
  1086. szName[nValue] = UNICODE_NULL;
  1087. switch (nID)
  1088. {
  1089. case IDC_AMPM:
  1090. if (!nValue)
  1091. {
  1092. pServParams->fPM = FALSE; // default
  1093. return TRUE;
  1094. }
  1095. if (_wcsnicmp(szName, IntlCurrent.sz1159, nValue) &&
  1096. _wcsnicmp(szName, IntlCurrent.sz2359, nValue))
  1097. {
  1098. return FALSE;
  1099. }
  1100. else
  1101. { // One of them may match fully
  1102. if (!_wcsicmp (szName, IntlCurrent.sz1159))
  1103. {
  1104. pServParams->fPM = FALSE;
  1105. }
  1106. else if (!_wcsicmp(szName, IntlCurrent.sz2359))
  1107. {
  1108. pServParams->fPM = TRUE;
  1109. }
  1110. }
  1111. break;
  1112. }
  1113. return TRUE;
  1114. }
  1115. //-------------------------------------------------------------------
  1116. // Function: dlgprocLICCPACONFIG
  1117. //
  1118. // Summary:
  1119. // The dialog procedure for the main Control Panel Applet Dialog
  1120. //
  1121. // In:
  1122. // hwndDlg - handle of Dialog window
  1123. // uMsg - message
  1124. // lParam1 - first message parameter
  1125. // lParam2 - second message parameter
  1126. // Out:
  1127. // Returns:
  1128. // message dependant
  1129. //
  1130. // Caveats:
  1131. //
  1132. // History:
  1133. // Feb-07-95 ChandanS Created
  1134. // Mar-14-95 MikeMi Added F1 PWM_HELP message
  1135. // Mar-30-95 MikeMi Added Replication Help Context
  1136. // Feb-28-96 JeffParh Added handling of UDN_DELTAPOS and EN_SETFOCUS,
  1137. // removed WM_VSCROLL (switched from private
  1138. // cpArrow class to Up-Down common ctrl)
  1139. //
  1140. //-------------------------------------------------------------------
  1141. INT_PTR CALLBACK dlgprocLICCPACONFIG( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  1142. {
  1143. LRESULT frt = FALSE;
  1144. short nID;
  1145. switch (uMsg)
  1146. {
  1147. case WM_INITDIALOG:
  1148. OnCpaConfigInitDialog( hwndDlg );
  1149. return( (LRESULT)TRUE ); // use default keyboard focus
  1150. break;
  1151. case WM_COMMAND:
  1152. switch (HIWORD( wParam ))
  1153. {
  1154. case EN_UPDATE:
  1155. switch (LOWORD( wParam ))
  1156. {
  1157. case IDC_AMPM:
  1158. if (!CheckAMPM (hwndDlg, LOWORD(wParam)))
  1159. SendMessage ((HWND) lParam, EM_UNDO, 0, 0L);
  1160. break;
  1161. case IDC_HOURS:
  1162. case IDC_HOUR:
  1163. case IDC_MINUTE:
  1164. case IDC_SECOND:
  1165. if (!CheckNum (hwndDlg, LOWORD(wParam)))
  1166. SendMessage ((HWND) lParam, EM_UNDO, 0, 0L);
  1167. break;
  1168. default:
  1169. break;
  1170. }
  1171. break;
  1172. case EN_SETFOCUS:
  1173. frt = (LRESULT)OnEnSetFocus( hwndDlg, LOWORD( wParam ) );
  1174. break;
  1175. case BN_CLICKED:
  1176. switch (LOWORD( wParam ))
  1177. {
  1178. case IDOK:
  1179. frt = (LRESULT)TRUE; // use as save flag
  1180. // intentional no break
  1181. case IDCANCEL:
  1182. OnCpaConfigClose( hwndDlg, !!frt , wParam);
  1183. frt = (LRESULT)FALSE;
  1184. break;
  1185. case IDC_REPL_INT:
  1186. case IDC_REPL_TIME:
  1187. OnSetReplicationTime( hwndDlg, LOWORD(wParam) );
  1188. break;
  1189. case IDC_BUTTONHELP:
  1190. PostMessage( hwndDlg, PWM_HELP, 0, 0 );
  1191. break;
  1192. default:
  1193. break;
  1194. }
  1195. break;
  1196. default:
  1197. break;
  1198. }
  1199. break;
  1200. case WM_NOTIFY:
  1201. nID = (short) wParam;
  1202. if ( IDC_TIMEARROW == nID )
  1203. {
  1204. frt = (LRESULT)OnDeltaPosSpinTime( hwndDlg, (NM_UPDOWN*) lParam );
  1205. }
  1206. else
  1207. {
  1208. frt = (LRESULT)FALSE;
  1209. }
  1210. break;
  1211. case WM_CTLCOLORSTATIC:
  1212. frt = (LRESULT) OnCtlColorStatic( hwndDlg, (HDC) wParam, (HWND) lParam );
  1213. break;
  1214. default:
  1215. if (PWM_HELP == uMsg)
  1216. HtmlHelp(hwndDlg, LICCPA_HTMLHELPFILE, HH_DISPLAY_TOPIC, (DWORD_PTR)LICCPA_REPLICATION_HELPFILE);
  1217. break;
  1218. }
  1219. return( frt );
  1220. }
  1221. //-------------------------------------------------------------------
  1222. // Function: OnEnSetFocus
  1223. //
  1224. // Summary:
  1225. //
  1226. // In:
  1227. // Out:
  1228. // Returns:
  1229. //
  1230. // Caveats:
  1231. //
  1232. // History:
  1233. // Feb-28-96 JeffParh Created
  1234. //-------------------------------------------------------------------
  1235. static BOOL OnEnSetFocus( HWND hwndDlg, short nID )
  1236. {
  1237. BOOL fSetNewRange = TRUE;
  1238. HWND hwndSpinCtrl;
  1239. int nMax = 0; //this init is not necessary but avoid W4
  1240. int nMin = 0;
  1241. switch ( nID )
  1242. {
  1243. case IDC_AMPM:
  1244. nMin = 0;
  1245. nMax = 1;
  1246. break;
  1247. case IDC_HOUR:
  1248. nMin = HOUR_MIN;
  1249. nMax = HOUR_MAX;
  1250. break;
  1251. case IDC_MINUTE:
  1252. nMin = MINUTE_MIN;
  1253. nMax = MINUTE_MAX;
  1254. break;
  1255. case IDC_SECOND:
  1256. nMin = SECOND_MIN;
  1257. nMax = SECOND_MAX;
  1258. break;
  1259. default:
  1260. fSetNewRange = FALSE;
  1261. break;
  1262. }
  1263. if ( fSetNewRange )
  1264. {
  1265. hwndSpinCtrl = GetDlgItem( hwndDlg, IDC_TIMEARROW );
  1266. SendMessage( hwndSpinCtrl, UDM_SETRANGE, 0, (LPARAM) MAKELONG( (short) nMax, (short) nMin ) );
  1267. }
  1268. return FALSE;
  1269. }
  1270. //-------------------------------------------------------------------
  1271. // Function: OnDeltaPosSpinTime
  1272. //
  1273. // Summary:
  1274. //
  1275. // In:
  1276. // Out:
  1277. // Returns:
  1278. //
  1279. // Caveats:
  1280. //
  1281. // History:
  1282. // Feb-28-96 JeffParh Created
  1283. //-------------------------------------------------------------------
  1284. static BOOL OnDeltaPosSpinTime( HWND hwndDlg, NM_UPDOWN * pnmud )
  1285. {
  1286. WCHAR szTemp[ 16 ] = TEXT( "" );
  1287. HWND hwndEdit;
  1288. short nID;
  1289. int nValue;
  1290. LRESULT lRange;
  1291. short nRangeHigh;
  1292. short nRangeLow;
  1293. BOOL frt;
  1294. hwndEdit = GetFocus();
  1295. nID = (short) GetWindowLong( hwndEdit, GWL_ID );
  1296. if ( ( IDC_HOUR == nID )
  1297. || ( IDC_MINUTE == nID )
  1298. || ( IDC_SECOND == nID )
  1299. || ( IDC_AMPM == nID ) )
  1300. {
  1301. if ( IDC_AMPM == nID )
  1302. {
  1303. // AM/PM
  1304. GetDlgItemText( hwndDlg, nID, szTemp, sizeof( szTemp ) / sizeof( *szTemp ) );
  1305. nValue = _wcsicmp( szTemp, IntlCurrent.sz2359 );
  1306. SetDlgItemText( hwndDlg, nID, nValue ? IntlCurrent.sz2359 : IntlCurrent.sz1159 );
  1307. }
  1308. else
  1309. {
  1310. lRange = SendMessage( pnmud->hdr.hwndFrom, UDM_GETRANGE, 0, 0 );
  1311. nRangeHigh = LOWORD( lRange );
  1312. nRangeLow = HIWORD( lRange );
  1313. nValue = GetDlgItemInt( hwndDlg, nID, NULL, FALSE );
  1314. nValue += pnmud->iDelta;
  1315. if ( nValue < nRangeLow )
  1316. {
  1317. nValue = nRangeLow;
  1318. }
  1319. else if ( nValue > nRangeHigh )
  1320. {
  1321. nValue = nRangeHigh;
  1322. }
  1323. if ( ( IDC_HOUR == nID ) && !IntlCurrent.iTLZero )
  1324. {
  1325. // set value w/o leading 0
  1326. SetDlgItemInt( hwndDlg, nID, nValue, FALSE );
  1327. }
  1328. else
  1329. {
  1330. // set value w/ leading 0
  1331. HRESULT hr = StringCbPrintf(szTemp, sizeof(szTemp), TEXT("%02u"), nValue );
  1332. if (SUCCEEDED(hr))
  1333. SetDlgItemText( hwndDlg, nID, szTemp );
  1334. }
  1335. }
  1336. SetFocus( hwndEdit );
  1337. SendMessage( hwndEdit, EM_SETSEL, 0, -1 );
  1338. // handled
  1339. frt = TRUE;
  1340. }
  1341. else
  1342. {
  1343. // not handled
  1344. frt = FALSE;
  1345. }
  1346. return frt;
  1347. }
  1348. //-------------------------------------------------------------------
  1349. // Function: OnCtlColorStatic
  1350. //
  1351. // Summary:
  1352. //
  1353. // In:
  1354. // Out:
  1355. // Returns:
  1356. //
  1357. // Caveats:
  1358. //
  1359. // History:
  1360. // Feb-28-96 JeffParh Created
  1361. //-------------------------------------------------------------------
  1362. static HBRUSH OnCtlColorStatic( HWND hwndDlg, HDC hDC, HWND hwndStatic )
  1363. {
  1364. LONG nID;
  1365. HBRUSH hBrush;
  1366. nID = GetWindowLong( hwndStatic, GWL_ID );
  1367. if ( pServParams->dwReplicationType
  1368. && ( ( IDC_TIMESEP1 == nID )
  1369. || ( IDC_TIMESEP2 == nID )
  1370. || ( IDC_TIMEEDIT_BORDER == nID ) ) )
  1371. {
  1372. hBrush = (HBRUSH) DefWindowProc( hwndDlg, WM_CTLCOLOREDIT, (WPARAM) hDC, (LPARAM) hwndStatic );
  1373. }
  1374. else
  1375. {
  1376. hBrush = (HBRUSH) DefWindowProc( hwndDlg, WM_CTLCOLORSTATIC, (WPARAM) hDC, (LPARAM) hwndStatic );
  1377. }
  1378. return hBrush;
  1379. }