Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

684 lines
17 KiB

  1. // File: dlginfo.cpp
  2. #include "precomp.h"
  3. #include <windowsx.h>
  4. #include "resource.h"
  5. #include "help_ids.h"
  6. #include "nmhelp.h"
  7. #include "mrulist2.h"
  8. #include "dlginfo.h"
  9. #include "nmsysinfo.h"
  10. extern HINSTANCE g_hInst;
  11. const int MRU_MAX_ENTRIES = 15; // This MUST be the same as the constant in ui\conf\mrulist.h
  12. const int CCHMAXSZ = 256; // Maximum generic string length
  13. const int CCHMAXSZ_EMAIL = 128; // Maximum length of an email name
  14. const int CCHMAXSZ_FIRSTNAME = 128; // Maximum length of a first name
  15. const int CCHMAXSZ_LASTNAME = 128; // Maximum length of a last name
  16. const int CCHMAXSZ_NAME = 256; // Maximum user name, displayed (combined first+last name)
  17. const int CCHMAXSZ_LOCATION = 128; // Maximum length of a Location
  18. const int CCHMAXSZ_SERVER = 128; // Maximum length of an address
  19. ///////////////////////////////////////////////////////////////////////////
  20. // Local Data
  21. static const DWSTR _rgMruServer[] = {
  22. {1, DIR_MRU_KEY},
  23. {MRUTYPE_SZ, TEXT("Name")},
  24. };
  25. static const DWORD _mpIdHelpDlgInfo[] = {
  26. IDG_UI_MYINFO, IDH_MYINFO_MYINFO,
  27. IDE_UI_FIRSTNAME, IDH_MYINFO_FIRSTNAME,
  28. IDE_UI_LASTNAME, IDH_MYINFO_LASTNAME,
  29. IDE_UI_EMAIL, IDH_MYINFO_EMAIL,
  30. IDE_UI_LOCATION, IDH_MYINFO_LOCATION,
  31. IDG_UI_DIRECTORY, IDH_MYINFO_ULS_SERVER,
  32. IDE_UI_DIRECTORY, IDH_MYINFO_ULS_SERVER,
  33. 0, 0 // terminator
  34. };
  35. // Local functions
  36. VOID FillServerComboBox(HWND hwndCombo);
  37. BOOL FLegalEmailName(HWND hdlg, UINT id);
  38. BOOL FLegalEmailSz(PTSTR pszName);
  39. BOOL FLoadString(UINT id, LPTSTR lpsz, UINT cch);
  40. BOOL FGetDefaultServer(LPTSTR pszServer, UINT cchMax);
  41. UINT GetDlgItemTextTrimmed(HWND hdlg, int id, PTCHAR psz, int cchMax);
  42. BOOL FEmptyDlgItem(HWND hdlg, UINT id);
  43. VOID CombineNames(LPTSTR pszResult, int cchResult, LPCTSTR pcszFirst, LPCTSTR pcszLast);
  44. BOOL FGetPropertySz(NM_SYSPROP nmProp, LPTSTR psz, int cchMax);
  45. BOOL FSetPropertySz(NM_SYSPROP nmProp, LPCTSTR pcsz);
  46. CMRUList2 * GetMruListServer(void);
  47. /* C D L G I N F O */
  48. /*-------------------------------------------------------------------------
  49. %%Function: CDlgInfo
  50. -------------------------------------------------------------------------*/
  51. CDlgInfo::CDlgInfo():
  52. m_hwnd(NULL)
  53. {
  54. }
  55. CDlgInfo::~CDlgInfo(void)
  56. {
  57. }
  58. /* D O M O D A L */
  59. /*-------------------------------------------------------------------------
  60. %%Function: DoModal
  61. -------------------------------------------------------------------------*/
  62. INT_PTR CDlgInfo::DoModal(HWND hwndParent)
  63. {
  64. return DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_USERINFO),
  65. hwndParent, CDlgInfo::DlgProc, (LPARAM) this);
  66. }
  67. /* I N I T C T R L */
  68. /*-------------------------------------------------------------------------
  69. %%Function: InitCtrl
  70. -------------------------------------------------------------------------*/
  71. VOID CDlgInfo::InitCtrl(NM_SYSPROP nmProp, HWND hwnd, int cchMax)
  72. {
  73. ::SendMessage(hwnd, WM_SETFONT, (WPARAM)(HFONT)::GetStockObject(DEFAULT_GUI_FONT), 0);
  74. Edit_LimitText(hwnd, cchMax);
  75. TCHAR sz[MAX_PATH];
  76. if (!FGetPropertySz(nmProp, sz, CCHMAX(sz)))
  77. return;
  78. ::SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) sz);
  79. }
  80. /* F S E T P R O P E R T Y */
  81. /*-------------------------------------------------------------------------
  82. %%Function: FSetProperty
  83. -------------------------------------------------------------------------*/
  84. BOOL CDlgInfo::FSetProperty(NM_SYSPROP nmProp, int id)
  85. {
  86. TCHAR sz[MAX_PATH];
  87. if (0 == GetDlgItemTextTrimmed(m_hwnd, id, sz, CCHMAX(sz)))
  88. return FALSE;
  89. return FSetPropertySz(nmProp, sz);
  90. }
  91. /* O N I N I T D I A L O G */
  92. /*-------------------------------------------------------------------------
  93. %%Function: OnInitDialog
  94. -------------------------------------------------------------------------*/
  95. VOID CDlgInfo::OnInitDialog(void)
  96. {
  97. InitCtrl(NM_SYSPROP_FIRST_NAME, GetDlgItem(m_hwnd, IDE_UI_FIRSTNAME), CCHMAXSZ_FIRSTNAME-1);
  98. InitCtrl(NM_SYSPROP_LAST_NAME, GetDlgItem(m_hwnd, IDE_UI_LASTNAME), CCHMAXSZ_LASTNAME-1);
  99. InitCtrl(NM_SYSPROP_EMAIL_NAME, GetDlgItem(m_hwnd, IDE_UI_EMAIL), CCHMAXSZ_EMAIL-1);
  100. InitCtrl(NM_SYSPROP_USER_CITY, GetDlgItem(m_hwnd, IDE_UI_LOCATION), CCHMAXSZ_LOCATION-1);
  101. m_hwndCombo = GetDlgItem(m_hwnd, IDE_UI_DIRECTORY);
  102. InitCtrl(NM_SYSPROP_SERVER_NAME, m_hwndCombo, CCHMAXSZ_SERVER-1);
  103. FillServerComboBox(m_hwndCombo);
  104. ValidateData();
  105. }
  106. /* D L G P R O C */
  107. /*-------------------------------------------------------------------------
  108. %%Function: DlgProc
  109. -------------------------------------------------------------------------*/
  110. INT_PTR CALLBACK CDlgInfo::DlgProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  111. {
  112. switch (uMsg)
  113. {
  114. case WM_INITDIALOG:
  115. {
  116. ASSERT(NULL != lParam);
  117. ::SetWindowLongPtr(hdlg, DWLP_USER, lParam);
  118. CDlgInfo * pDlg = (CDlgInfo*) lParam;
  119. pDlg->m_hwnd = hdlg;
  120. pDlg->OnInitDialog();
  121. return TRUE; // default focus is ok
  122. }
  123. case WM_COMMAND:
  124. {
  125. CDlgInfo * pDlg = (CDlgInfo*) GetWindowLongPtr(hdlg, DWLP_USER);
  126. if (NULL != pDlg)
  127. {
  128. pDlg->OnCommand(wParam, lParam);
  129. }
  130. break;
  131. }
  132. case WM_HELP:
  133. DoHelp(lParam, _mpIdHelpDlgInfo);
  134. break;
  135. case WM_CONTEXTMENU:
  136. DoHelpWhatsThis(wParam, _mpIdHelpDlgInfo);
  137. break;
  138. default:
  139. break;
  140. }
  141. return FALSE;
  142. }
  143. /* O N C O M M A N D */
  144. /*-------------------------------------------------------------------------
  145. %%Function: OnCommand
  146. -------------------------------------------------------------------------*/
  147. BOOL CDlgInfo::OnCommand(WPARAM wParam, LPARAM lParam)
  148. {
  149. ASSERT(NULL != m_hwnd);
  150. WORD wCmd = GET_WM_COMMAND_ID(wParam, lParam);
  151. switch (wCmd)
  152. {
  153. case IDE_UI_FIRSTNAME:
  154. case IDE_UI_LASTNAME:
  155. case IDE_UI_EMAIL:
  156. {
  157. if (GET_WM_COMMAND_CMD(wParam,lParam) == EN_CHANGE)
  158. {
  159. ValidateData();
  160. }
  161. break;
  162. }
  163. case IDE_UI_DIRECTORY:
  164. {
  165. switch (GET_WM_COMMAND_CMD(wParam,lParam))
  166. {
  167. case CBN_SELCHANGE:
  168. // The data isn't available yet
  169. PostMessage(m_hwnd, WM_COMMAND, MAKELONG(IDE_UI_DIRECTORY, CBN_EDITCHANGE), lParam);
  170. break;
  171. case CBN_EDITCHANGE:
  172. ValidateData();
  173. default:
  174. break;
  175. }
  176. break;
  177. }
  178. case IDOK:
  179. {
  180. if (FSaveData())
  181. {
  182. ::EndDialog(m_hwnd, wCmd);
  183. }
  184. return TRUE;
  185. }
  186. case IDCANCEL:
  187. {
  188. ::EndDialog(m_hwnd, wCmd);
  189. return TRUE;
  190. }
  191. default:
  192. break;
  193. }
  194. return FALSE;
  195. }
  196. VOID CDlgInfo::ValidateData(void)
  197. {
  198. BOOL fOk = !FEmptyDlgItem(m_hwnd, IDE_UI_FIRSTNAME) &&
  199. !FEmptyDlgItem(m_hwnd, IDE_UI_LASTNAME) &&
  200. !FEmptyDlgItem(m_hwnd, IDE_UI_EMAIL);
  201. if (fOk)
  202. {
  203. TCHAR sz[CCHMAXSZ_EMAIL];
  204. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_EMAIL, sz, CCHMAX(sz));
  205. fOk = FLegalEmailSz(sz);
  206. }
  207. if (fOk)
  208. {
  209. TCHAR sz[CCHMAXSZ_SERVER];
  210. fOk = (0 != ComboBox_GetText(m_hwndCombo, sz, CCHMAX(sz)));
  211. if (fOk)
  212. {
  213. fOk = 0 != TrimSz(sz);
  214. }
  215. }
  216. Button_Enable(GetDlgItem(m_hwnd, IDOK), fOk);
  217. }
  218. /* F S A V E D A T A */
  219. /*-------------------------------------------------------------------------
  220. %%Function: FSaveData
  221. -------------------------------------------------------------------------*/
  222. BOOL CDlgInfo::FSaveData(void)
  223. {
  224. if (!FSetProperty(NM_SYSPROP_FIRST_NAME, IDE_UI_FIRSTNAME) ||
  225. !FSetProperty(NM_SYSPROP_LAST_NAME, IDE_UI_LASTNAME) ||
  226. !FSetProperty(NM_SYSPROP_EMAIL_NAME, IDE_UI_EMAIL) ||
  227. !FSetProperty(NM_SYSPROP_SERVER_NAME, IDE_UI_DIRECTORY)
  228. )
  229. {
  230. return FALSE;
  231. }
  232. // The city name (can be blank)
  233. TCHAR sz[CCHMAXSZ];
  234. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_LOCATION, sz, CCHMAX(sz));
  235. FSetPropertySz(NM_SYSPROP_USER_CITY, sz);
  236. // Full Name = First + Last
  237. TCHAR szFirst[CCHMAXSZ_FIRSTNAME];
  238. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_FIRSTNAME, szFirst, CCHMAX(szFirst));
  239. TCHAR szLast[CCHMAXSZ_LASTNAME];
  240. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_LASTNAME, szLast, CCHMAX(szLast));
  241. CombineNames(sz, CCHMAX(sz), szFirst, szLast);
  242. if (!FSetPropertySz(NM_SYSPROP_USER_NAME, sz))
  243. return FALSE;
  244. // Resolve Name = server / email
  245. UINT cch = GetDlgItemTextTrimmed(m_hwnd, IDE_UI_DIRECTORY, sz, CCHMAX(sz));
  246. GetDlgItemTextTrimmed(m_hwnd, IDE_UI_EMAIL, &sz[cch], CCHMAX(sz)-cch);
  247. return FSetPropertySz(NM_SYSPROP_RESOLVE_NAME, sz);
  248. }
  249. ///////////////////////////////////////////////////////////////////////////
  250. /* C O M B I N E N A M E S */
  251. /*-------------------------------------------------------------------------
  252. %%Function: CombineNames
  253. Combine the two names into one string.
  254. The result is a "First Last" (or Intl'd "Last First") string
  255. -------------------------------------------------------------------------*/
  256. VOID CombineNames(LPTSTR pszResult, int cchResult, LPCTSTR pcszFirst, LPCTSTR pcszLast)
  257. {
  258. ASSERT(pszResult);
  259. TCHAR szFmt[32]; // A small value: String is "%1 %2" or "%2 %1"
  260. TCHAR sz[CCHMAXSZ_NAME];
  261. LPCTSTR argw[2];
  262. argw[0] = pcszFirst;
  263. argw[1] = pcszLast;
  264. *pszResult = _T('\0');
  265. if (!FLoadString(IDS_NAME_ORDER, szFmt, CCHMAX(szFmt)))
  266. return;
  267. if (0 == FormatMessage(FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_FROM_STRING,
  268. szFmt, 0, 0, sz, CCHMAX(sz), (va_list *)argw ))
  269. return;
  270. // REVIEW: Use STRCPYN or make this a utility function
  271. lstrcpyn(pszResult, sz, cchResult);
  272. #ifndef _UNICODE
  273. // lstrcpyn() can clip a DBCS character in half at the end of the string
  274. // we need to walk the string with ::CharNext() and replace the last byte
  275. // with a NULL if the last byte is half of a DBCS char.
  276. PTSTR pszSource = sz;
  277. while (*pszSource && (pszSource - sz < cchResult))
  278. {
  279. PTSTR pszPrev = pszSource;
  280. pszSource = ::CharNext(pszPrev);
  281. // If we've reached the first character that didn't get copied into
  282. // the destination buffer, and the previous character was a double
  283. // byte character...
  284. if (((pszSource - sz) == cchResult) && ::IsDBCSLeadByte(*pszPrev))
  285. {
  286. // Replace the destination buffer's last character with '\0'
  287. // NOTE: pszResult[cchResult - 1] is '\0' thanks to lstrcpyn()
  288. pszResult[cchResult - 2] = _T('\0');
  289. break;
  290. }
  291. }
  292. #endif // ! _UNICODE
  293. }
  294. /* F L E G A L E M A I L S Z */
  295. /*-------------------------------------------------------------------------
  296. %%Function: FLegalEmailSz
  297. A legal email name contains only ANSI characters.
  298. "a-z, A-Z, numbers 0-9 and some common symbols"
  299. It cannot include extended characters or < > ( ) /
  300. -------------------------------------------------------------------------*/
  301. BOOL FLegalEmailSz(PTSTR pszName)
  302. {
  303. if (IS_EMPTY_STRING(pszName))
  304. return FALSE;
  305. for ( ; ; )
  306. {
  307. UINT ch = (UINT) ((*pszName++) & 0x00FF);
  308. if (0 == ch)
  309. break;
  310. switch (ch)
  311. {
  312. default:
  313. if ((ch > (UINT) _T(' ')) && (ch <= (UINT) _T('~')) )
  314. break;
  315. // else fall thru to error code
  316. case '(': case ')':
  317. case '<': case '>':
  318. case '[': case ']':
  319. case '/': case '\\':
  320. case ':': case ';':
  321. case '+':
  322. case '=':
  323. case ',':
  324. case '\"':
  325. WARNING_OUT(("FLegalEmailSz: Invalid character '%s' (0x%02X)", &ch, ch));
  326. return FALSE;
  327. }
  328. }
  329. return TRUE;
  330. }
  331. /* F L E G A L E M A I L N A M E */
  332. /*-------------------------------------------------------------------------
  333. %%Function: FLegalEmailName
  334. -------------------------------------------------------------------------*/
  335. BOOL FLegalEmailName(HWND hdlg, UINT id)
  336. {
  337. TCHAR sz[MAX_PATH];
  338. GetDlgItemTextTrimmed(hdlg, id, sz, CCHMAX(sz));
  339. return FLegalEmailSz(sz);
  340. }
  341. /* F I L L S E R V E R C O M B O B O X */
  342. /*-------------------------------------------------------------------------
  343. %%Function: FillServerComboBox
  344. -------------------------------------------------------------------------*/
  345. VOID FillServerComboBox(HWND hwnd)
  346. {
  347. CMRUList2 * pMru = GetMruListServer();
  348. if (NULL == pMru)
  349. return;
  350. int cServers = pMru->GetNumEntries();
  351. for (int i = 0; i < cServers; i++)
  352. {
  353. int iPos = ComboBox_AddString(hwnd, pMru->PszEntry(i));
  354. if (iPos < 0)
  355. break;
  356. }
  357. delete pMru;
  358. }
  359. inline VOID DwToSz(DWORD dw, LPTSTR psz)
  360. {
  361. wsprintf(psz, TEXT("%d"), dw);
  362. }
  363. BOOL FGetPropertySz(NM_SYSPROP nmProp, LPTSTR psz, int cchMax)
  364. {
  365. HKEY hkey;
  366. LPTSTR pszSubKey;
  367. LPTSTR pszValue;
  368. bool fString;
  369. LONG lVal;
  370. if (!CNmSysInfoObj::GetKeyDataForProp(nmProp, &hkey, &pszSubKey, &pszValue, &fString))
  371. {
  372. return FALSE;
  373. }
  374. RegEntry re(pszSubKey, hkey);
  375. if (fString)
  376. {
  377. lstrcpyn(psz, re.GetString(pszValue), cchMax);
  378. }
  379. else
  380. {
  381. lVal = re.GetNumber(pszValue, 0);
  382. DwToSz(lVal, psz);
  383. ASSERT(lstrlen(psz) < cchMax);
  384. }
  385. return TRUE;
  386. }
  387. BOOL FSetPropertySz(NM_SYSPROP nmProp, LPCTSTR pcsz)
  388. {
  389. HKEY hkey;
  390. LPTSTR pszSubKey;
  391. LPTSTR pszValue;
  392. bool fString;
  393. if (!CNmSysInfoObj::GetKeyDataForProp(nmProp, &hkey, &pszSubKey, &pszValue, &fString))
  394. {
  395. return FALSE;
  396. }
  397. RegEntry re(pszSubKey, hkey);
  398. if (fString)
  399. {
  400. return (0 == re.SetValue(pszValue, pcsz));
  401. }
  402. DWORD dw = DecimalStringToUINT(pcsz);
  403. return (0 == re.SetValue(pszValue, dw));
  404. }
  405. CMRUList2 * GetMruListServer(void)
  406. {
  407. CMRUList2 * pMruList = new CMRUList2(&_rgMruServer[0], MRU_MAX_ENTRIES, TRUE /* fReverse */);
  408. if (NULL != pMruList)
  409. {
  410. TCHAR sz[MAX_PATH];
  411. if (FGetDefaultServer(sz, CCHMAX(sz)))
  412. {
  413. pMruList->AddEntry(sz);
  414. TCHAR ldapDirectory[ MAX_PATH ];
  415. if( FLoadString( IDS_MS_INTERNET_DIRECTORY, ldapDirectory, CCHMAX( ldapDirectory ) ) )
  416. {
  417. pMruList->DeleteEntry( ldapDirectory );
  418. }
  419. RegEntry re( CONFERENCING_KEY, HKEY_CURRENT_USER );
  420. TCHAR * webViewServer = re.GetString( REGVAL_WEBDIR_DISPLAY_NAME );
  421. if( lstrlen( webViewServer ) > 0 )
  422. {
  423. pMruList->DeleteEntry( webViewServer );
  424. }
  425. pMruList->SetDirty(FALSE);
  426. }
  427. }
  428. return pMruList;
  429. }
  430. ///////////////////////////////////////////////////////////////////////////
  431. /* F V A L I D U S E R I N F O */
  432. /*-------------------------------------------------------------------------
  433. %%Function: FValidUserInfo
  434. Return TRUE if all of the necessary user information is available.
  435. -------------------------------------------------------------------------*/
  436. BOOL FValidUserInfo(void)
  437. {
  438. { // Fail if not a valid installation directory
  439. TCHAR sz[MAX_PATH];
  440. if (!GetInstallDirectory(sz) || !FDirExists(sz))
  441. return FALSE;
  442. }
  443. { // Validate ULS entries
  444. RegEntry reUls(ISAPI_KEY "\\" REGKEY_USERDETAILS, HKEY_CURRENT_USER);
  445. if (FEmptySz(reUls.GetString(REGVAL_ULS_EMAIL_NAME)))
  446. return FALSE;
  447. if (FEmptySz(reUls.GetString(REGVAL_SERVERNAME)))
  448. return FALSE;
  449. if (FEmptySz(reUls.GetString(REGVAL_ULS_RES_NAME)))
  450. return FALSE;
  451. }
  452. #if 0
  453. { // Check Wizard key
  454. RegEntry reConf(CONFERENCING_KEY, HKEY_CURRENT_USER);
  455. // check to see if the wizard has been run in UI mode
  456. DWORD dwVersion = reConf.GetNumber(REGVAL_WIZARD_VERSION_UI, 0);
  457. BOOL fForceWizard = (VER_PRODUCTVERSION_DW != dwVersion);
  458. if (fForceWizard)
  459. {
  460. // the wizard has not been run in UI mode, check to see if its been run in NOUI mode
  461. dwVersion = reConf.GetNumber(REGVAL_WIZARD_VERSION_NOUI, 0);
  462. fForceWizard = (VER_PRODUCTVERSION_DW != dwVersion);
  463. }
  464. if (fForceWizard)
  465. return FALSE; // Wizard has never been run
  466. }
  467. #endif /* 0 */
  468. // Everything is properly installed and the Wizard will not run
  469. return TRUE;
  470. }
  471. ///////////////////////////////////////////////////////////////////////////
  472. /* F L O A D S T R I N G */
  473. /*----------------------------------------------------------------------------
  474. %%Function: FLoadString
  475. Load a resource string.
  476. Assumes the buffer is valid and can hold the resource.
  477. ----------------------------------------------------------------------------*/
  478. BOOL FLoadString(UINT id, LPTSTR lpsz, UINT cch)
  479. {
  480. ASSERT(NULL != _Module.GetModuleInstance());
  481. ASSERT(NULL != lpsz);
  482. if (0 == ::LoadString(g_hInst, id, lpsz, cch))
  483. {
  484. ERROR_OUT(("*** Resource %d does not exist", id));
  485. *lpsz = _T('\0');
  486. return FALSE;
  487. }
  488. return TRUE;
  489. }
  490. /* F G E T D E F A U L T S E R V E R */
  491. /*-------------------------------------------------------------------------
  492. %%Function: FGetDefaultServer
  493. -------------------------------------------------------------------------*/
  494. BOOL FGetDefaultServer(LPTSTR pszServer, UINT cchMax)
  495. {
  496. RegEntry ulsKey(ISAPI_CLIENT_KEY, HKEY_CURRENT_USER);
  497. LPTSTR psz = ulsKey.GetString(REGVAL_SERVERNAME);
  498. if (FEmptySz(psz))
  499. return FALSE;
  500. lstrcpyn(pszServer, psz, cchMax);
  501. return TRUE;
  502. }
  503. /* G E T D L G I T E M T E X T T R I M M E D */
  504. /*-------------------------------------------------------------------------
  505. %%Function: GetDlgItemTextTrimmed
  506. -------------------------------------------------------------------------*/
  507. UINT GetDlgItemTextTrimmed(HWND hdlg, int id, PTCHAR psz, int cchMax)
  508. {
  509. UINT cch = GetDlgItemText(hdlg, id, psz, cchMax);
  510. if (0 != cch)
  511. {
  512. cch = TrimSz(psz);
  513. }
  514. return cch;
  515. }
  516. /* F E M P T Y D L G I T E M */
  517. /*-------------------------------------------------------------------------
  518. %%Function: FEmptyDlgItem
  519. Return TRUE if the dialog control is empty
  520. -------------------------------------------------------------------------*/
  521. BOOL FEmptyDlgItem(HWND hdlg, UINT id)
  522. {
  523. TCHAR sz[MAX_PATH];
  524. return (0 == GetDlgItemTextTrimmed(hdlg, id, sz, CCHMAX(sz)) );
  525. }
  526. /* V E R I F Y U S E R I N F O */
  527. /*-------------------------------------------------------------------------
  528. %%Function: VerifyUserInfo
  529. Return S_OK if the data is valid or S_FALSE if it is not.
  530. -------------------------------------------------------------------------*/
  531. HRESULT WINAPI VerifyUserInfo(HWND hwnd, NM_VUI options)
  532. {
  533. BOOL fOk = FALSE;
  534. BOOL fShow = (options & NM_VUI_SHOW) || !FValidUserInfo();
  535. if (fShow)
  536. {
  537. CDlgInfo * pDlg = new CDlgInfo();
  538. if (NULL == pDlg)
  539. return E_OUTOFMEMORY;
  540. fOk = (IDOK == pDlg->DoModal(hwnd));
  541. delete pDlg;
  542. }
  543. if (!FValidUserInfo())
  544. {
  545. // The app should not continue with this.
  546. return S_FALSE;
  547. }
  548. return S_OK;
  549. }
  550.