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.

887 lines
21 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ConstraintsPage.cpp
  5. Abstract:
  6. Functions for "Constraints" page of the wizard.
  7. Author:
  8. Sergey Kuzin (a-skuzin@microsoft.com) 09-August-1999
  9. Environment:
  10. Revision History:
  11. --*/
  12. #include "tsverui.h"
  13. #include "resource.h"
  14. void AddSelectedItemsToControl(HWND hwndDlg,int iCtrl);
  15. void AddOneSelectedItemToControl(HWND hwndDlg,int iCtrl);
  16. void AddSelectedRangeToControl(HWND hwndDlg);
  17. void AssembleContraints(HWND hwndDlg,LPSHAREDWIZDATA pdata);
  18. void InitConstraintsPage(HWND hwndDlg);
  19. void AddToControl(HWND hwndDlg, int iCtrl,int &i, TCHAR *szConstraints);
  20. void AddOneToControl(HWND hwndDlg, int iCtrl,int &i, TCHAR *szConstraints);
  21. void AddRangeToControl(HWND hwndDlg, int &i, TCHAR *szConstraints);
  22. BOOL CheckSyntax(HWND hwndDlg, WORD wCtrlId);
  23. BOOL CheckRangeSyntax(HWND hwndDlg);
  24. /*++
  25. Routine Description :
  26. dialog box procedure for the "Constraints" page.
  27. Arguments :
  28. IN HWND hwndDlg - handle to dialog box.
  29. IN UINT uMsg - message to be acted upon.
  30. IN WPARAM wParam - value specific to wMsg.
  31. IN LPARAM lParam - value specific to wMsg.
  32. Return Value :
  33. TRUE if it processed the message
  34. FALSE if it did not.
  35. --*/
  36. INT_PTR CALLBACK
  37. ConstraintsPageProc (
  38. HWND hwndDlg,
  39. UINT uMsg,
  40. WPARAM wParam,
  41. LPARAM lParam)
  42. {
  43. //Retrieve the shared user data from GWL_USERDATA
  44. LPSHAREDWIZDATA pdata = (LPSHAREDWIZDATA) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  45. switch (uMsg)
  46. {
  47. case WM_INITDIALOG :
  48. {
  49. //Get the shared data from PROPSHEETPAGE lParam value
  50. //and load it into GWL_USERDATA
  51. pdata = (LPSHAREDWIZDATA) ((LPPROPSHEETPAGE) lParam) -> lParam;
  52. SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (DWORD_PTR) pdata);
  53. InitConstraintsPage(hwndDlg);
  54. break;
  55. }
  56. case WM_NOTIFY :
  57. {
  58. LPNMHDR lpnm = (LPNMHDR) lParam;
  59. switch (lpnm->code)
  60. {
  61. case PSN_SETACTIVE : //Enable the Back and Next buttons
  62. PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
  63. if(pdata->pszConstraints){
  64. delete pdata->pszConstraints;
  65. pdata->pszConstraints=NULL;
  66. }
  67. break;
  68. case PSN_WIZNEXT :
  69. //Handle a Next button click here
  70. if(!CheckSyntax(hwndDlg,IDC_ALLOW)||
  71. !CheckSyntax(hwndDlg,IDC_DISALLOW)||
  72. !CheckSyntax(hwndDlg,IDC_HIGHER)||
  73. !CheckSyntax(hwndDlg,IDC_LOWER)||
  74. !CheckRangeSyntax(hwndDlg)){
  75. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, -1);
  76. return TRUE;
  77. }
  78. AssembleContraints(hwndDlg,pdata);
  79. break;
  80. case PSN_RESET :
  81. //Handle a Cancel button click, if necessary
  82. break;
  83. default :
  84. break;
  85. }
  86. }
  87. break;
  88. case WM_COMMAND:
  89. switch ( LOWORD(wParam) ) {
  90. case ID_ALLOW:
  91. AddSelectedItemsToControl(hwndDlg,IDC_ALLOW);
  92. break;
  93. case ID_DISALLOW:
  94. AddSelectedItemsToControl(hwndDlg,IDC_DISALLOW);
  95. break;
  96. case ID_HIGHER:
  97. AddOneSelectedItemToControl(hwndDlg,IDC_HIGHER);
  98. break;
  99. case ID_LOWER:
  100. AddOneSelectedItemToControl(hwndDlg,IDC_LOWER);
  101. break;
  102. case ID_RANGE:
  103. AddSelectedRangeToControl(hwndDlg);
  104. break;
  105. default:
  106. break;
  107. }
  108. break;
  109. default:
  110. break;
  111. }
  112. return FALSE;
  113. }
  114. /*++
  115. Routine Description :
  116. Checks validity of entered values
  117. Arguments :
  118. IN HWND hwndDlg - Page handle.
  119. IN int wCtrlId - edit box ID.
  120. Return Value :
  121. FALSE if some invalid values found.
  122. --*/
  123. BOOL
  124. CheckSyntax(
  125. HWND hwndDlg,
  126. WORD wCtrlId
  127. )
  128. {
  129. HWND hwndCtrl=GetDlgItem(hwndDlg,wCtrlId);
  130. TCHAR szBuf[MAX_LEN+1];
  131. TCHAR szTemplate[MAX_LEN-100+1];
  132. TCHAR szCtrlName[100+1];
  133. TCHAR szMsg[MAX_LEN+1];
  134. int size=GetDlgItemText(hwndDlg,wCtrlId,szBuf,MAX_LEN);
  135. if(!size){
  136. return TRUE;
  137. }
  138. do{
  139. size--;
  140. if(!_istdigit(szBuf[size])&&szBuf[size]!=' '){
  141. switch(wCtrlId){
  142. case IDC_HIGHER:
  143. case IDC_LOWER:
  144. LoadString(g_hInst,IDS_INVALID_VALUE,szTemplate,MAX_LEN-100);
  145. LoadString(g_hInst,wCtrlId,szCtrlName,100);
  146. wsprintf(szMsg,szTemplate,szCtrlName);
  147. MessageBox(hwndDlg,szMsg,NULL,MB_OK);
  148. return FALSE;
  149. case IDC_ALLOW:
  150. case IDC_DISALLOW:
  151. if(szBuf[size]!=','){
  152. LoadString(g_hInst,IDS_INVALID_VALUE,szTemplate,MAX_LEN-100);
  153. LoadString(g_hInst,wCtrlId,szCtrlName,100);
  154. wsprintf(szMsg,szTemplate,szCtrlName);
  155. MessageBox(hwndDlg,szMsg,NULL,MB_OK);
  156. return FALSE;
  157. }else{
  158. break;
  159. }
  160. default:
  161. break;
  162. }
  163. }
  164. }while(size);
  165. return TRUE;
  166. }
  167. /*++
  168. Routine Description :
  169. Checks validity of entered values
  170. for IDC_RANGE edit box
  171. Arguments :
  172. IN HWND hwndDlg - Page handle.
  173. Return Value :
  174. FALSE if some invalid values found.
  175. --*/
  176. BOOL
  177. CheckRangeSyntax(
  178. HWND hwndDlg)
  179. {
  180. HWND hwndCtrl=GetDlgItem(hwndDlg,IDC_RANGE);
  181. TCHAR szBuf[MAX_LEN+1];
  182. TCHAR szTemplate[MAX_LEN-100+1];
  183. TCHAR szCtrlName[100+1];
  184. TCHAR szMsg[MAX_LEN+1];
  185. int size=GetDlgItemText(hwndDlg,IDC_RANGE,szBuf,MAX_LEN);
  186. if(!size){
  187. return TRUE;
  188. }
  189. BOOL bBracket=FALSE;
  190. BOOL bColon=FALSE;
  191. BOOL bDigit=FALSE;
  192. do{
  193. size--;
  194. if(!bBracket)//outside of brackets
  195. {
  196. if(szBuf[size]!=';' && szBuf[size]!=')' && szBuf[size]!=' '){ //illegal symbol
  197. LoadString(g_hInst,IDS_INVALID_VALUE,szTemplate,MAX_LEN-100);
  198. LoadString(g_hInst,IDC_RANGE,szCtrlName,100);
  199. wsprintf(szMsg,szTemplate,szCtrlName);
  200. MessageBox(hwndDlg,szMsg,NULL,MB_OK);
  201. return FALSE;
  202. }
  203. } else {//inside of brackets
  204. if((!_istdigit(szBuf[size]) && szBuf[size]!=':' && szBuf[size]!='(' && szBuf[size]!=' ')|| //illegal symbol
  205. (szBuf[size]==':' && bColon)|| // two conons inside brackets
  206. (szBuf[size]=='(' && !bColon)|| // no colons inside brackets
  207. (szBuf[size]==':' && !bDigit)|| // no number after colon '(123:)'
  208. (szBuf[size]=='(' && !bDigit)){ // no number after bracket '(:123)'
  209. LoadString(g_hInst,IDS_INVALID_VALUE,szTemplate,MAX_LEN-100);
  210. LoadString(g_hInst,IDC_RANGE,szCtrlName,100);
  211. wsprintf(szMsg,szTemplate,szCtrlName);
  212. MessageBox(hwndDlg,szMsg,NULL,MB_OK);
  213. return FALSE;
  214. }
  215. }
  216. if(szBuf[size]==')'){
  217. bBracket=TRUE;
  218. bColon=FALSE;
  219. bDigit=FALSE;
  220. continue;
  221. }
  222. if(szBuf[size]=='('){
  223. bBracket=FALSE;
  224. bColon=FALSE;
  225. bDigit=FALSE;
  226. continue;
  227. }
  228. if(szBuf[size]==':'){
  229. bColon=TRUE;
  230. bDigit=FALSE;
  231. continue;
  232. }
  233. if(_istdigit(szBuf[size])){
  234. bDigit=TRUE;
  235. continue;
  236. }
  237. }while(size);
  238. return TRUE;
  239. }
  240. /*++
  241. Routine Description :
  242. Get IDs of selected listbox items
  243. Arguments :
  244. IN HWND hwndList - handle to list box.
  245. OUT int **ppItems - pointer to pointer to array of
  246. IDs of selected items
  247. Return Value :
  248. number of selected items.
  249. --*/
  250. //
  251. int
  252. GetSelectedItems(
  253. HWND hwndList,
  254. int **ppItems)
  255. {
  256. *ppItems=NULL;
  257. int nItems=(int)SendMessage(hwndList,LB_GETSELCOUNT,(WPARAM)0,(LPARAM)0);
  258. if(nItems){
  259. *ppItems=new int[nItems];
  260. if(*ppItems) {
  261. SendMessage(hwndList,LB_GETSELITEMS,(WPARAM)nItems,(LPARAM)*ppItems);
  262. } else {
  263. return 0;
  264. }
  265. }
  266. return nItems;
  267. }
  268. /*++
  269. Routine Description :
  270. Adds selected items from list to
  271. IDC_ALLOW or IDC_DISALLOW edit box
  272. Arguments :
  273. IN HWND hwndDlg - Page handle.
  274. IN int iCtrl - edit box ID.
  275. Return Value :
  276. none
  277. --*/
  278. void
  279. AddSelectedItemsToControl(
  280. HWND hwndDlg,
  281. int iCtrl)
  282. {
  283. static HWND hwndList=NULL;
  284. if(!hwndList){
  285. hwndList=GetDlgItem(hwndDlg,IDC_VERSION_LIST);
  286. }
  287. int *pItemIDs;
  288. int nItems=GetSelectedItems(hwndList,&pItemIDs);
  289. if(nItems){
  290. _TCHAR szNumber[11];//assume that list contains only numbers
  291. _TCHAR szCtrlText[MAX_LEN+1];
  292. for(int i=0;i<nItems;i++){
  293. SendMessage(hwndList,LB_GETTEXT,(WPARAM)pItemIDs[i],(LPARAM)szNumber);
  294. GetDlgItemText(hwndDlg,iCtrl,szCtrlText,MAX_LEN);
  295. if(_tcslen(szCtrlText)<=(MAX_LEN-11)){//10 digits+','
  296. if(_tcslen(szCtrlText)){
  297. _tcscat(szCtrlText,TEXT(","));
  298. }
  299. _tcscat(szCtrlText,szNumber);
  300. SetDlgItemText(hwndDlg,iCtrl,szCtrlText);
  301. }
  302. }
  303. delete pItemIDs;
  304. //deselect all items
  305. SendMessage(hwndList,LB_SETSEL,(WPARAM)0,(LPARAM)-1);
  306. }
  307. }
  308. /*++
  309. Routine Description :
  310. Adds selected items from list to
  311. IDC_HIGHER or IDC_LOWER edit box
  312. Arguments :
  313. IN HWND hwndDlg - Page handle.
  314. IN int iCtrl - edit box ID.
  315. Return Value :
  316. none
  317. --*/
  318. void
  319. AddOneSelectedItemToControl(
  320. HWND hwndDlg,
  321. int iCtrl)
  322. {
  323. static HWND hwndList=NULL;
  324. if(!hwndList){
  325. hwndList=GetDlgItem(hwndDlg,IDC_VERSION_LIST);
  326. }
  327. int *pItemIDs;
  328. int nItems=GetSelectedItems(hwndList,&pItemIDs);
  329. if(nItems){
  330. if(nItems==1){
  331. TCHAR szNumber[11];//assume that list contains only numbers
  332. SendMessage(hwndList,LB_GETTEXT,(WPARAM)pItemIDs[0],(LPARAM)szNumber);
  333. SetDlgItemText(hwndDlg,iCtrl,szNumber);
  334. }else{
  335. TCHAR szMsg[256];
  336. LoadString(g_hInst,IDS_SELECT_ONE,szMsg,255);
  337. MessageBox(hwndDlg,szMsg,NULL,MB_OK);
  338. }
  339. delete pItemIDs;
  340. //deselect all items
  341. SendMessage(hwndList,LB_SETSEL,(WPARAM)0,(LPARAM)-1);
  342. }
  343. }
  344. /*++
  345. Routine Description :
  346. Adds selected items from list to
  347. IDC_RANGE edit box
  348. Arguments :
  349. IN HWND hwndDlg - Page handle.
  350. Return Value :
  351. none
  352. --*/
  353. void
  354. AddSelectedRangeToControl(
  355. HWND hwndDlg)
  356. {
  357. static HWND hwndList=NULL;
  358. if(!hwndList){
  359. hwndList=GetDlgItem(hwndDlg,IDC_VERSION_LIST);
  360. }
  361. int *pItemIDs;
  362. int nItems=GetSelectedItems(hwndList,&pItemIDs);
  363. if(nItems){
  364. if(nItems==2){
  365. TCHAR szNumber1[11];//assume that list contains only numbers
  366. TCHAR szNumber2[11];
  367. SendMessage(hwndList,LB_GETTEXT,(WPARAM)pItemIDs[0],(LPARAM)szNumber1);
  368. SendMessage(hwndList,LB_GETTEXT,(WPARAM)pItemIDs[1],(LPARAM)szNumber2);
  369. TCHAR szRange[24];
  370. //versions in list are sorted, so Number1<=Number2
  371. _tcscpy(szRange,TEXT("("));
  372. _tcscat(szRange,szNumber1);
  373. _tcscat(szRange,TEXT(":"));
  374. _tcscat(szRange,szNumber2);
  375. _tcscat(szRange,TEXT(")"));
  376. TCHAR szCtrlText[MAX_LEN+1];
  377. GetDlgItemText(hwndDlg,IDC_RANGE,szCtrlText,MAX_LEN);
  378. if(_tcslen(szCtrlText)<(MAX_LEN-24)){//23+',' do not count '\0'
  379. if(_tcslen(szCtrlText)){
  380. _tcscat(szCtrlText,TEXT(";"));
  381. }
  382. _tcscat(szCtrlText,szRange);
  383. SetDlgItemText(hwndDlg,IDC_RANGE,szCtrlText);
  384. }
  385. }else{
  386. TCHAR szMsg[256];
  387. LoadString(g_hInst,IDS_SELECT_TWO,szMsg,255);
  388. MessageBox(hwndDlg,szMsg,NULL,MB_OK);
  389. }
  390. delete pItemIDs;
  391. //deselect all items
  392. SendMessage(hwndList,LB_SETSEL,(WPARAM)0,(LPARAM)-1);
  393. }
  394. }
  395. /*++
  396. Routine Description :
  397. Initializes controls with values from registry.
  398. Arguments :
  399. IN HWND hwndDlg - Page handle.
  400. Return Value :
  401. none
  402. --*/
  403. void
  404. InitConstraintsPage(
  405. HWND hwndDlg)
  406. {
  407. //Set string size limits
  408. HWND hwndAllow=GetDlgItem(hwndDlg,IDC_ALLOW);
  409. HWND hwndDisallow=GetDlgItem(hwndDlg,IDC_DISALLOW);
  410. HWND hwndHigher=GetDlgItem(hwndDlg,IDC_HIGHER);
  411. HWND hwndLower=GetDlgItem(hwndDlg,IDC_LOWER);
  412. HWND hwndRange=GetDlgItem(hwndDlg,IDC_RANGE);
  413. SendMessage(hwndAllow,EM_LIMITTEXT,(WPARAM)MAX_LEN,(LPARAM)0);
  414. SendMessage(hwndDisallow,EM_LIMITTEXT,(WPARAM)MAX_LEN,(LPARAM)0);
  415. SendMessage(hwndHigher,EM_LIMITTEXT,(WPARAM)10,(LPARAM)0);//max number length
  416. SendMessage(hwndLower,EM_LIMITTEXT,(WPARAM)10,(LPARAM)0);//max number length
  417. SendMessage(hwndRange,EM_LIMITTEXT,(WPARAM)MAX_LEN,(LPARAM)0);
  418. //Fill List of client versions
  419. //get list from registry
  420. TCHAR *pBuffer=NULL;
  421. HWND hwndList=GetDlgItem(hwndDlg,IDC_VERSION_LIST);
  422. GetRegMultiString(HKEY_USERS, szConstraintsKeyPath, KeyName[VERSIONS], &pBuffer);
  423. if(pBuffer){
  424. for(int i=0;pBuffer[i]!=0;i++){
  425. SendMessage(hwndList,LB_ADDSTRING,(WPARAM)0,(LPARAM)&pBuffer[i]);
  426. i+=_tcslen(pBuffer+i);
  427. }
  428. delete pBuffer;
  429. pBuffer=NULL;
  430. }
  431. //#ifdef TEST
  432. else{
  433. //Load version numbers from string table.
  434. TCHAR szTmp[MAX_LEN+1];
  435. ZeroMemory(szTmp,MAX_LEN+1);
  436. TCHAR *pszTmp=szTmp;
  437. LoadString(g_hInst,IDS_CLIENT_VERSIONS,szTmp,MAX_LEN);
  438. for(int i=0;szTmp[i]!=0;i++)
  439. {
  440. if(szTmp[i]==','){
  441. szTmp[i]=0;
  442. }
  443. }
  444. for(i=0;szTmp[i]!=0;i++){
  445. SendMessage(hwndList,LB_ADDSTRING,(WPARAM)0,(LPARAM)&szTmp[i]);
  446. i+=_tcslen(szTmp+i);
  447. }
  448. /*
  449. TCHAR *pTmp[9]={TEXT("2031"),TEXT("2072"),TEXT("2087"),TEXT("2092"),TEXT("2099"),
  450. TEXT("1877"),TEXT("9109"),TEXT("9165"),TEXT("9213")};
  451. for(int i=0;i<9;i++){
  452. SendMessage(hwndList,LB_ADDSTRING,(WPARAM)0,(LPARAM)pTmp[i]);
  453. }*/
  454. }
  455. //#endif TEST
  456. //--------------------------------------------------------------------------
  457. //Parse constraint string
  458. pBuffer=GetRegString(HKEY_USERS, szConstraintsKeyPath, KeyName[CONSTRAINTS]);
  459. if(pBuffer){
  460. for (int i = 0; i < (int)_tcslen(pBuffer); i++){
  461. switch (pBuffer[i])
  462. {
  463. case '=':
  464. // skip the case where the = sign follows a !
  465. if (pBuffer[i-1] != '!'){
  466. AddToControl(hwndDlg, IDC_ALLOW,i, pBuffer);
  467. }
  468. break;
  469. case '<':
  470. AddOneToControl(hwndDlg, IDC_LOWER,i, pBuffer);
  471. break;
  472. case '>':
  473. AddOneToControl(hwndDlg, IDC_HIGHER,i, pBuffer);
  474. break;
  475. case '!':
  476. i++; // increment past the = sign
  477. AddToControl(hwndDlg, IDC_DISALLOW,i, pBuffer);
  478. break;
  479. case '(':
  480. AddRangeToControl(hwndDlg, i, pBuffer);
  481. break;
  482. default:
  483. break;
  484. }
  485. }
  486. delete pBuffer;
  487. pBuffer=NULL;
  488. }
  489. //--------------------------------------------------------------------------
  490. //END "Parse constraint string"
  491. }
  492. /*++
  493. Routine Description :
  494. Adds values from constraint string to
  495. IDC_ALLOW or IDC_DISALLOW edit box
  496. Arguments :
  497. IN HWND hwndDlg - Page handle.
  498. IN int iCtrl - edit box ID.
  499. IN,OUT int &i - reference to current position in string
  500. IN TCHAR *szConstraints - constraint string
  501. Return Value :
  502. none
  503. --*/
  504. void
  505. AddToControl(
  506. HWND hwndDlg,
  507. int iCtrl,
  508. int &i,
  509. TCHAR *szConstraints)
  510. {
  511. int index;
  512. TCHAR szNumber[11];//max 10 digits + '\0'
  513. TCHAR szItemText[MAX_LEN+1];
  514. // parse a number out of the registry string
  515. index = 0;
  516. i++; //pass '=' or '>' or '<' or ',' symbol
  517. while ( ( _istdigit(szConstraints[i]) || szConstraints[i] == ' ' ) &&
  518. index < 10 )
  519. {
  520. if(szConstraints[i] != ' '){
  521. szNumber[index] = szConstraints[i];
  522. index++;
  523. }
  524. i++;
  525. }
  526. szNumber[index] = '\0';
  527. GetDlgItemText(hwndDlg,iCtrl,szItemText,MAX_LEN);
  528. if(_tcslen(szItemText)<=(MAX_LEN-11)){//10 digits+','
  529. if(_tcslen(szItemText)){
  530. _tcscat(szItemText,TEXT(","));
  531. }
  532. _tcscat(szItemText,szNumber);
  533. SetDlgItemText(hwndDlg,iCtrl,szItemText);
  534. }
  535. if(szConstraints[i]==','){
  536. AddToControl(hwndDlg, iCtrl, i, szConstraints);
  537. }
  538. }
  539. /*++
  540. Routine Description :
  541. Adds values from constraint string to
  542. IDC_HIGHER or IDC_LOWER edit box
  543. Arguments :
  544. IN HWND hwndDlg - Page handle.
  545. IN int iCtrl - edit box ID.
  546. IN,OUT int &i - reference to current position in string
  547. IN TCHAR *szConstraints - constraint string
  548. Return Value :
  549. none
  550. --*/
  551. void
  552. AddOneToControl(
  553. HWND hwndDlg,
  554. int iCtrl,
  555. int &i,
  556. TCHAR *szConstraints)
  557. {
  558. int index;
  559. TCHAR szNumber[11];//max 10 digits + '\0'
  560. // parse a number out of the registry string
  561. index = 0;
  562. i++; //pass '=' or '>' or '<' or ',' symbol
  563. while ( ( _istdigit(szConstraints[i]) || szConstraints[i] == ' ' ) &&
  564. index < 10 )
  565. {
  566. if(szConstraints[i] != ' '){
  567. szNumber[index] = szConstraints[i];
  568. index++;
  569. }
  570. i++;
  571. }
  572. szNumber[index] = '\0';
  573. SetDlgItemText(hwndDlg,iCtrl,szNumber);
  574. }
  575. /*++
  576. Routine Description :
  577. Adds values from constraint string to
  578. IDC_RANGE edit box
  579. Arguments :
  580. IN HWND hwndDlg - Page handle.
  581. IN,OUT int &i - reference to current position in string
  582. IN TCHAR *szConstraints - constraint string
  583. Return Value :
  584. none
  585. --*/
  586. void
  587. AddRangeToControl(
  588. HWND hwndDlg,
  589. int &i,
  590. TCHAR *szConstraints)
  591. {
  592. int index;
  593. TCHAR szRange[24];//10+10+'('+':'+')'+'\0'
  594. index = 0;
  595. while (szConstraints[i] != ')' && index < 22 ){
  596. if(szConstraints[i]!=' '){//delete all spaces
  597. szRange[index] = szConstraints[i];
  598. index++;
  599. }
  600. i++;
  601. }
  602. szRange[index]=')';//index max - 22
  603. index++;
  604. szRange[index] = '\0';//index max - 23
  605. TCHAR szItemText[MAX_LEN+1];
  606. GetDlgItemText(hwndDlg,IDC_RANGE,szItemText,MAX_LEN);
  607. if(_tcslen(szItemText)<(MAX_LEN-24)){//23+',' do not count '\0'
  608. if(_tcslen(szItemText)){
  609. _tcscat(szItemText,TEXT(";"));
  610. }
  611. _tcscat(szItemText,szRange);
  612. SetDlgItemText(hwndDlg,IDC_RANGE,szItemText);
  613. }
  614. }
  615. /*++
  616. Routine Description :
  617. Assembles constraint string from values in edit boxes
  618. and writes it in data structure.
  619. Arguments :
  620. IN HWND hwndDlg - Page handle.
  621. LPSHAREDWIZDATA pdata - pointer to data structure
  622. Return Value :
  623. none
  624. --*/
  625. void AssembleContraints(HWND hwndDlg,LPSHAREDWIZDATA pdata)
  626. {
  627. TCHAR szAllow[MAX_LEN+1];
  628. TCHAR szDisallow[MAX_LEN+1];
  629. TCHAR szHigher[MAX_LEN+1];
  630. TCHAR szLower[MAX_LEN+1];
  631. TCHAR szRange[MAX_LEN+1];
  632. GetDlgItemText(hwndDlg,IDC_ALLOW,szAllow,MAX_LEN);
  633. GetDlgItemText(hwndDlg,IDC_DISALLOW,szDisallow,MAX_LEN);
  634. GetDlgItemText(hwndDlg,IDC_HIGHER,szHigher,MAX_LEN);
  635. GetDlgItemText(hwndDlg,IDC_LOWER,szLower,MAX_LEN);
  636. GetDlgItemText(hwndDlg,IDC_RANGE,szRange,MAX_LEN);
  637. int Size=_tcslen(szAllow)+_tcslen(szDisallow)+_tcslen(szHigher)+
  638. _tcslen(szLower)+_tcslen(szRange)+10;//'='+'!='+'<'+'>'+4*';'+'\0'=10
  639. pdata->pszConstraints=new TCHAR[Size];
  640. if(pdata->pszConstraints != NULL) {
  641. pdata->pszConstraints[0]=0;
  642. }
  643. else {
  644. return;
  645. }
  646. if(_tcslen(szAllow)){
  647. _tcscpy(pdata->pszConstraints,TEXT("="));
  648. _tcscat(pdata->pszConstraints,szAllow);
  649. }
  650. if(_tcslen(szDisallow)){
  651. if(_tcslen(pdata->pszConstraints)){
  652. _tcscat(pdata->pszConstraints,TEXT(";!="));
  653. }else{
  654. _tcscat(pdata->pszConstraints,TEXT("!="));
  655. }
  656. _tcscat(pdata->pszConstraints,szDisallow);
  657. }
  658. if(_tcslen(szHigher)){
  659. if(_tcslen(pdata->pszConstraints)){
  660. _tcscat(pdata->pszConstraints,TEXT(";>"));
  661. }else{
  662. _tcscat(pdata->pszConstraints,TEXT(">"));
  663. }
  664. _tcscat(pdata->pszConstraints,szHigher);
  665. }
  666. if(_tcslen(szLower)){
  667. if(_tcslen(pdata->pszConstraints)){
  668. _tcscat(pdata->pszConstraints,TEXT(";<"));
  669. }else{
  670. _tcscat(pdata->pszConstraints,TEXT("<"));
  671. }
  672. _tcscat(pdata->pszConstraints,szLower);
  673. }
  674. if(_tcslen(szRange)){
  675. if(_tcslen(pdata->pszConstraints)){
  676. _tcscat(pdata->pszConstraints,TEXT(";"));
  677. }
  678. _tcscat(pdata->pszConstraints,szRange);
  679. }
  680. }