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.

1323 lines
41 KiB

  1. /*************************************************
  2. * convdlg.c *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. #include <string.h>
  8. #include "prop.h"
  9. #include "upimeres.h"
  10. #include <regstr.h>
  11. #include <htmlhelp.h>
  12. #ifdef UNICODE
  13. extern TCHAR Title[];
  14. extern TCHAR szVer[];
  15. #else
  16. extern BYTE Title[];
  17. extern BYTE szVer[];
  18. #endif
  19. /*****************************************************************************
  20. FUNCTION: ConvDialogProc(HWND, UINT, WPARAM, LPARAM)
  21. PURPOSE: Processes messages for "conv" property sheet.
  22. PARAMETERS:
  23. hdlg - window handle of the property sheet
  24. wMessage - type of message
  25. wparam - message-specific information
  26. lparam - message-specific information
  27. RETURN VALUE:
  28. TRUE - message handled
  29. FALSE - message not handled
  30. HISTORY:
  31. 04-18-95 Yehfew Tie Created.
  32. ****************************************************************************/
  33. INT_PTR CALLBACK ConvDialogProc(HWND hdlg,
  34. UINT uMessage,
  35. WPARAM wparam,
  36. LPARAM lparam)
  37. {
  38. LPNMHDR lpnmhdr;
  39. static DWORD dwDesOffset,dwDesLen;
  40. static DWORD dwRuleOffset,dwRuleLen;
  41. static TCHAR szMbName[MAX_PATH];
  42. static TCHAR szSrcName[MAX_PATH];
  43. static TCHAR _szStr[MAX_PATH];
  44. static BOOL bModify;
  45. LPRULE lpRule;
  46. int i;
  47. static DESCRIPTION Descript;
  48. switch (uMessage)
  49. {
  50. case WM_INITDIALOG:
  51. {
  52. //install conv sub class
  53. lpConvProc = (FARPROC)SetWindowLongPtr(GetDlgItem(hdlg,IDC_LIST),
  54. GWLP_WNDPROC,(LONG_PTR)ConvEditProc);
  55. SendDlgItemMessage(hdlg,IDC_IMENAME,EM_LIMITTEXT,24,0L);
  56. SendDlgItemMessage(hdlg,IDC_USEDCODE,EM_LIMITTEXT,MAXUSEDCODES,0L);
  57. SetConvDisable(hdlg);
  58. PropSheet_CancelToClose(GetParent(hdlg));
  59. break;
  60. }
  61. case WM_DESTROY:
  62. if(hRule)
  63. GlobalFree(hRule);
  64. if(hEncode)
  65. GlobalFree(hEncode);
  66. break;
  67. case WM_NOTIFY:
  68. lpnmhdr = (NMHDR FAR *)lparam;
  69. switch (lpnmhdr->code)
  70. {
  71. case PSN_SETACTIVE:
  72. hRule = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,
  73. sizeof(RULE)*MAXCODELEN);
  74. hEncode = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,
  75. NUMENCODEAREA*sizeof(ENCODEAREA));
  76. if(!hRule || !hEncode)
  77. ProcessError(ERR_OUTOFMEMORY,hdlg,ERR);
  78. if ( hEncode )
  79. ConvInitEncode(hEncode);
  80. break;
  81. case PSN_APPLY:
  82. if(bModify) {
  83. LoadString(NULL, IDS_FILEMODIFY, _szStr, sizeof(_szStr)/sizeof(TCHAR));
  84. #ifdef UNICODE
  85. {
  86. TCHAR UniTmp[] = {0x521B, 0x5EFA, 0x8F93, 0x5165, 0x6CD5, 0x9875, 0x9762, 0x4E2D, 0x005C, 0x006E, 0x005C, 0x0027, 0x0025, 0x0077, 0x0073, 0x005C, 0x0027, 0x005C, 0x006E, 0x0025, 0x0077, 0x0073, 0x0000};
  87. StringCchPrintf(szMbName,ARRAYSIZE(szMbName),UniTmp,szSrcName,_szStr);
  88. }
  89. #else
  90. StringCchPrintf(szMbName,ARRAYSIZE(szMbName),"�������뷨ҳ����\n\'%s\'\n%s",szSrcName,_szStr);
  91. #endif
  92. if(ErrMessage(hdlg,szMbName)) {
  93. SendMessage(hdlg,WM_COMMAND,IDC_SAVE,0L);
  94. }
  95. }
  96. break;
  97. case PSN_RESET:
  98. break;
  99. case PSN_QUERYCANCEL:
  100. break;
  101. case PSN_HELP:
  102. break;
  103. case PSN_KILLACTIVE:
  104. break;
  105. default:
  106. break;
  107. }
  108. break;
  109. case WM_COMMAND:
  110. switch (LOWORD(wparam))
  111. {
  112. case IDC_BROWSE:
  113. if(bModify) {
  114. TCHAR errString[MAX_PATH];
  115. LoadString(NULL, IDS_FILEMODIFY, _szStr, sizeof(_szStr)/sizeof(TCHAR));
  116. StringCchPrintf(errString,ARRAYSIZE(errString),TEXT("\'%s\'%s"),szSrcName,_szStr);
  117. if(ErrMessage(hdlg,errString))
  118. SendMessage(hdlg,WM_COMMAND,IDC_SAVE,0L);
  119. }
  120. SetDlgItemText(hdlg,IDC_MBNAME,szMbName);
  121. {
  122. #ifdef UNICODE
  123. static TCHAR szTitle[] = {0x6253, 0x5F00, 0x0000};
  124. #else
  125. TCHAR szTitle[MAX_PATH];
  126. strcpy(szTitle,"����");
  127. #endif
  128. if(!TxtFileOpenDlg(hdlg,_szStr,szTitle))
  129. break;
  130. }
  131. lstrcpy(szSrcName,_szStr);
  132. bModify = FALSE;
  133. memset(_szStr, 0, MAX_PATH);
  134. SetDlgItemText(hdlg,IDC_EDITBOX,_szStr);
  135. SendDlgItemMessage(hdlg,IDC_LIST,LB_RESETCONTENT,0,0L);
  136. {
  137. LPTSTR lpString;
  138. if((lpString = _tcsrchr(szSrcName,TEXT('\\')))!=NULL)
  139. SetDlgItemText(hdlg,IDC_SRCNAME, lpString+1);
  140. StringCchCopy(szMbName, ARRAYSIZE(szMbName), szSrcName);
  141. StringCchCopy(_szStr, ARRAYSIZE(_szStr),szSrcName);
  142. if((lpString = _tcsrchr(szMbName,TEXT('.')))!=NULL)
  143. *lpString = 0;
  144. StringCchCat(szMbName, ARRAYSIZE(szMbName), TEXT(MbExt));
  145. }
  146. SetDlgItemText(hdlg,IDC_MBNAME,szMbName);
  147. {
  148. int nRetValue;
  149. nRetValue = ConvGetDescript(hdlg, szSrcName,
  150. &dwDesOffset, &dwDesLen, &Descript, FALSE);
  151. if(nRetValue ==(-ERR_FILENOTOPEN)) {
  152. szSrcName[0]=0;
  153. lstrcpy(szMbName, szSrcName);
  154. SetDlgItemText(hdlg,IDC_SRCNAME,szSrcName);
  155. SetDlgItemText(hdlg,IDC_MBNAME,szMbName);
  156. MessageBeep((UINT)-1);
  157. break;
  158. }
  159. }
  160. if(!(lpRule = GlobalLock(hRule)) ) {
  161. ProcessError(ERR_GLOBALLOCK,hdlg,ERR);
  162. break;
  163. }
  164. if(ConvGetRule(hdlg, szSrcName, &dwRuleOffset, &dwRuleLen,
  165. lpRule, &Descript)==(-ERR_FILENOTOPEN))
  166. {
  167. szSrcName[0]=0;
  168. lstrcpy(szMbName,szSrcName);
  169. SetDlgItemText(hdlg,IDC_SRCNAME,szSrcName);
  170. SetDlgItemText(hdlg,IDC_MBNAME,szMbName);
  171. GlobalUnlock(hRule);
  172. MessageBeep((UINT)-1);
  173. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
  174. break;
  175. }
  176. SetDlgDescript(hdlg,&Descript);
  177. SetDlgRuleStr(hdlg,Descript.wNumRules,lpRule);
  178. SetDlgItemText(hdlg,IDC_MBNAME,szMbName);
  179. GlobalUnlock(hRule);
  180. SetConvEnable(hdlg);
  181. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
  182. SendMessage(GetDlgItem(hdlg,ID_FILEOPEN),BM_SETSTYLE,BS_PUSHBUTTON,0L);
  183. SendMessage(GetDlgItem(hdlg,IDC_CONV),BM_SETSTYLE,BS_DEFPUSHBUTTON,TRUE);
  184. SetFocus(GetDlgItem(hdlg,IDC_CONV));
  185. break;
  186. case IDC_MBNAME:
  187. GetDlgItemText(hdlg,IDC_MBNAME,szMbName,256);
  188. if(lstrlen(szMbName) == 0) {
  189. EnableWindow(GetDlgItem(hdlg,IDC_CONV),FALSE);
  190. break;
  191. }
  192. else {
  193. GetDlgItemText(hdlg,IDC_IMENAME,_szStr,32);
  194. if(lstrlen(_szStr) != 0 && Descript.wMaxCodes != 0)
  195. EnableWindow(GetDlgItem(hdlg,IDC_CONV),TRUE);
  196. else
  197. EnableWindow(GetDlgItem(hdlg,IDC_CONV),FALSE);
  198. }
  199. break;
  200. case IDC_IMENAME:
  201. GetDlgItemText(hdlg,IDC_IMENAME,_szStr,128);
  202. _szStr[128]=0;
  203. if(lstrlen(_szStr) == 0) {
  204. EnableWindow(GetDlgItem(hdlg,IDC_CONV),FALSE);
  205. break;
  206. }
  207. else {
  208. GetDlgItemText(hdlg,IDC_MBNAME,szMbName,256);
  209. if(lstrlen(szMbName) != 0 && Descript.wMaxCodes != 0)
  210. EnableWindow(GetDlgItem(hdlg,IDC_CONV),TRUE);
  211. else
  212. EnableWindow(GetDlgItem(hdlg,IDC_CONV),FALSE);
  213. }
  214. if(lstrcmpi(Descript.szName,_szStr)==0)
  215. break;
  216. bModify = TRUE;
  217. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  218. break;
  219. case IDC_MAXCODES:
  220. {
  221. int nMaxCodes;
  222. nMaxCodes = GetDlgItemInt (hdlg,IDC_MAXCODES,NULL,FALSE);
  223. if(nMaxCodes > MAXCODELEN) {
  224. MessageBeep((UINT)-1);
  225. SetDlgItemInt (hdlg,IDC_MAXCODES,MAXCODELEN,FALSE);
  226. Descript.wMaxCodes = MAXCODELEN;
  227. }
  228. if(Descript.wMaxCodes != nMaxCodes) {
  229. bModify = TRUE;
  230. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  231. }
  232. break;
  233. }
  234. case IDC_USEDCODE:
  235. GetDlgItemText(hdlg,IDC_USEDCODE,_szStr,sizeof(_szStr)/sizeof(TCHAR));
  236. if(lstrlen(_szStr) == 0)
  237. EnableWindow(GetDlgItem(hdlg,IDC_CONV),FALSE);
  238. if(lstrcmpi(Descript.szUsedCode,_szStr)==0)
  239. break;
  240. bModify = TRUE;
  241. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  242. break;
  243. case IDC_WILDCHAR:
  244. GetDlgItemText(hdlg,IDC_WILDCHAR,_szStr,sizeof(_szStr)/sizeof(TCHAR));
  245. if(lstrlen(_szStr)==0 ) {
  246. if( Descript.cWildChar!=0) {
  247. bModify = TRUE;
  248. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  249. }
  250. break;
  251. }
  252. if(lstrlen(_szStr)>1) {
  253. MessageBeep((UINT)-1);
  254. _szStr[0]=0;
  255. SetDlgItemText(hdlg,IDC_WILDCHAR,_szStr);
  256. break;
  257. }
  258. {
  259. TCHAR WildChar;
  260. WildChar=_szStr[0];
  261. if(WildChar != Descript.cWildChar) {
  262. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  263. bModify = TRUE;
  264. }
  265. GetDlgItemText(hdlg,IDC_USEDCODE,_szStr,sizeof(_szStr)/sizeof(TCHAR));
  266. if(_tcschr(_szStr,WildChar) != NULL) {
  267. _szStr[0]=0;
  268. SetDlgItemText(hdlg,IDC_WILDCHAR,_szStr);
  269. MessageBeep((UINT)-1);
  270. break;
  271. }
  272. }
  273. break;
  274. case IDC_SINGLEELEMENT:
  275. case IDC_MULTIELEMENT:
  276. if(Descript.byMaxElement == (BYTE)(IsDlgButtonChecked(hdlg,IDC_MULTIELEMENT)?2:1))
  277. break;
  278. Descript.byMaxElement = 1 + Descript.byMaxElement%2;
  279. bModify = TRUE;
  280. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  281. break;
  282. case IDC_ADD:
  283. {
  284. FARPROC lpProcInfo;
  285. szRuleStr[0] = 0;
  286. if(Descript.wNumRules >= MAXCODELEN) {
  287. ProcessError(ERR_RULENUM,hdlg,WARNING);
  288. break;
  289. }
  290. lpProcInfo = MakeProcInstance((FARPROC)AddRuleDlg, hInst);
  291. DialogBox(hInst,
  292. MAKEINTRESOURCE(IDD_ADDRULE),
  293. hdlg,
  294. AddRuleDlg);
  295. FreeProcInstance(lpProcInfo);
  296. bModify = TRUE;
  297. break;
  298. }
  299. case IDC_MODIFY:
  300. {
  301. FARPROC lpProcInfo;
  302. int nSelect;
  303. nSelect = (INT)SendDlgItemMessage(hdlg,
  304. IDC_LIST,
  305. LB_GETCURSEL,
  306. (WPARAM)0,
  307. (LPARAM)0);
  308. if(nSelect == LB_ERR) {
  309. MessageBeep((UINT)-1);
  310. break;
  311. }
  312. SendDlgItemMessage(hdlg,IDC_LIST,LB_GETTEXT,nSelect,(LPARAM)szRuleStr);
  313. lpProcInfo = MakeProcInstance((FARPROC)ModiRuleDlg, hInst);
  314. DialogBox(hInst,
  315. MAKEINTRESOURCE(IDD_EDITRULE),
  316. hdlg,
  317. ModiRuleDlg);
  318. FreeProcInstance(lpProcInfo);
  319. break;
  320. }
  321. case IDC_DEL:
  322. {
  323. int nSelect;
  324. nSelect = (INT)SendDlgItemMessage(hdlg,
  325. IDC_LIST,
  326. LB_GETCURSEL,
  327. (WPARAM)0,
  328. (LPARAM)0);
  329. if(nSelect != LB_ERR) {
  330. SendDlgItemMessage(hdlg,IDC_LIST,LB_DELETESTRING,
  331. nSelect,(LPARAM)0);
  332. if(!(lpRule = GlobalLock(hRule)) ) {
  333. ProcessError(ERR_GLOBALLOCK,hdlg,ERR);
  334. break;
  335. }
  336. DelSelRule(Descript.wNumRules,(WORD)nSelect,lpRule);
  337. Descript.wNumRules--;
  338. GlobalUnlock(hRule);
  339. bModify = TRUE;
  340. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  341. SetFocus(GetDlgItem(hdlg,IDC_LIST));
  342. SendDlgItemMessage(hdlg,IDC_LIST,LB_SETCURSEL,nSelect,0L);
  343. if((nSelect=(INT)SendDlgItemMessage(hdlg,IDC_LIST,
  344. LB_GETCURSEL,0,0L))==LB_ERR) {
  345. nSelect=(INT)SendDlgItemMessage(hdlg,
  346. IDC_LIST,
  347. LB_GETCOUNT,
  348. (WPARAM)0,
  349. (LPARAM)0);
  350. SendDlgItemMessage(hdlg,
  351. IDC_LIST,
  352. LB_SETCURSEL,
  353. (WPARAM)(nSelect-1),
  354. (LPARAM)0);
  355. }
  356. }
  357. else
  358. MessageBeep((UINT)-1);
  359. break;
  360. }
  361. case IDC_ADDRULE:
  362. if(!(lpRule = GlobalLock(hRule)) ) {
  363. ProcessError(ERR_GLOBALLOCK,hdlg,ERR);
  364. szRuleStr[0] = 0;
  365. break;
  366. }
  367. if(RuleParse(hdlg,szRuleStr,0,lpRule,Descript.wMaxCodes)) {
  368. int nCnt;
  369. nCnt =(WORD)SendDlgItemMessage(hdlg,IDC_LIST,LB_GETCOUNT,0,0L);
  370. if(nCnt != 0)
  371. {
  372. for(i=0; i<nCnt; i++) {
  373. SendDlgItemMessage(hdlg,IDC_LIST,LB_GETTEXT,i,(LPARAM)_szStr);
  374. #ifdef UNICODE
  375. if(wcsncmp(szRuleStr,_szStr,3) == 0)
  376. #else
  377. if(strncmp(szRuleStr,_szStr,3) == 0)
  378. #endif //UNICODE
  379. {
  380. GlobalUnlock(hRule);
  381. ProcessError(ERR_DUPRULE,hdlg,ERR);
  382. MessageBeep((UINT)-1);
  383. MessageBeep((UINT)-1);
  384. _szStr[0] = 0;
  385. lstrcpy((LPTSTR)lparam,(LPTSTR)_szStr);
  386. return FALSE;
  387. }
  388. }
  389. }
  390. SendDlgItemMessage(hdlg,IDC_LIST,LB_ADDSTRING,0,(LPARAM)szRuleStr);
  391. bModify = TRUE;
  392. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  393. Descript.wNumRules++;
  394. }
  395. else
  396. {
  397. MessageBeep((UINT)-1);
  398. _szStr[0] = 0;
  399. lstrcpy((LPTSTR)lparam,(LPTSTR)_szStr);
  400. }
  401. GlobalUnlock(hRule);
  402. break;
  403. case IDC_CHGDATA:
  404. if(!(lpRule = GlobalLock(hRule)) ) {
  405. ProcessError(ERR_GLOBALLOCK,hdlg,ERR);
  406. _szStr[0] = 0;
  407. lstrcpy((LPTSTR)lparam,(LPTSTR)_szStr);
  408. break;
  409. }
  410. {
  411. int nSelect;
  412. nSelect = (INT)SendDlgItemMessage(hdlg,IDC_LIST,LB_GETCURSEL,0,0L);
  413. if(RuleParse(hdlg,szRuleStr,nSelect,lpRule,Descript.wMaxCodes)) {
  414. // Descript.wNumRules++;
  415. int nCnt;
  416. nCnt =(WORD)SendDlgItemMessage(hdlg,IDC_LIST,LB_GETCOUNT,0,0L);
  417. if(nCnt != 0)
  418. {
  419. for(i=0; i<nCnt; i++) {
  420. if(i == nSelect)
  421. continue;
  422. SendDlgItemMessage(hdlg,IDC_LIST,LB_GETTEXT,i,(LPARAM)_szStr);
  423. #ifdef UNICODE
  424. if(wcsncmp(szRuleStr,_szStr,3) == 0)
  425. #else
  426. if(strncmp(szRuleStr,_szStr,3) == 0)
  427. #endif
  428. {
  429. GlobalUnlock(hRule);
  430. MessageBeep((UINT)-1);
  431. _szStr[0] = 0;
  432. lstrcpy((LPTSTR)lparam,_szStr);
  433. return FALSE;
  434. }
  435. }
  436. }
  437. SendDlgItemMessage(hdlg,IDC_LIST,LB_DELETESTRING,nSelect,0L);
  438. SendDlgItemMessage(hdlg,IDC_LIST,LB_ADDSTRING,0,(LPARAM)szRuleStr);
  439. bModify = TRUE;
  440. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
  441. }
  442. else
  443. {
  444. _szStr[0] = 0;
  445. lstrcpy((LPTSTR)lparam,_szStr);
  446. MessageBeep((UINT)-1);
  447. }
  448. GlobalUnlock(hRule);
  449. break;
  450. }
  451. case IDC_GETMBFILE:
  452. GetDlgItemText(hdlg,IDC_MBNAME,_szStr,sizeof(_szStr)/sizeof(TCHAR));
  453. lstrcpy((LPTSTR)lparam,_szStr);
  454. break;
  455. case IDC_GETSRCFILE:
  456. lstrcpy((LPTSTR)lparam,szSrcName);
  457. break;
  458. case IDC_CONV:
  459. {
  460. //FARPROC lpProcInfo;
  461. if(bModify)
  462. SendMessage(hdlg,WM_COMMAND,IDC_SAVE,0L);
  463. //lpProcInfo = MakeProcInstance((FARPROC)InfoDlg, hInst);
  464. pfnmsg=(PFNMSG)ConvProc;
  465. bEndProp=FALSE;
  466. //DialogBox(hInst,
  467. // MAKEINTRESOURCE(IDD_INFO),
  468. // hdlg,
  469. // (DLGPROC)lpProcInfo);
  470. //FreeProcInstance(lpProcInfo);
  471. DialogBox(hInst,
  472. MAKEINTRESOURCE(IDD_INFO),
  473. hdlg,
  474. InfoDlg);
  475. break;
  476. }
  477. case IDC_CRTIME:
  478. {
  479. //FARPROC lpProcInfo;
  480. int nRetValue;
  481. GetDlgItemText(hdlg, IDC_MBNAME, _szStr, sizeof(_szStr)/sizeof(TCHAR));
  482. nRetValue = ReadDescript(_szStr,&Descript,FILE_SHARE_READ);
  483. if(nRetValue == -1){
  484. TCHAR errString[MAX_PATH];
  485. LoadString(NULL, IDS_FILEOPEN, errString, sizeof(errString)/sizeof(TCHAR));
  486. lstrcat(_szStr, errString);
  487. FatalMessage(hdlg,_szStr);
  488. break;
  489. }
  490. else if(!nRetValue)
  491. {
  492. ProcessError(ERR_READMAININDEX,hdlg,WARNING);
  493. break;
  494. }
  495. //lpProcInfo = MakeProcInstance((FARPROC)CrtImeDlg, hInst);
  496. //DialogBox(hInst,
  497. // MAKEINTRESOURCE(IDD_CRTIME),
  498. // hdlg,
  499. // (DLGPROC)lpProcInfo);
  500. //FreeProcInstance(lpProcInfo);
  501. DialogBox(hInst,
  502. MAKEINTRESOURCE(IDD_CRTIME),
  503. hdlg,
  504. CrtImeDlg);
  505. break;
  506. }
  507. case IDC_SAVE:
  508. if(!(lpRule = GlobalLock(hRule)) ) {
  509. ProcessError(ERR_GLOBALLOCK,hdlg,ERR);
  510. _szStr[0] = 0;
  511. lstrcpy((LPTSTR)lparam,_szStr);
  512. break;
  513. }
  514. GetDlgDescript(hdlg,&Descript);
  515. if(!CheckCodeCollection(hdlg,Descript.szUsedCode))
  516. break;
  517. GetDlgRule(hdlg,lpRule,&(Descript.wNumRules),Descript.wMaxCodes);
  518. if(!ConvSaveDescript(szSrcName,&Descript, dwDesOffset,dwDesLen))
  519. break;
  520. //**** modify 95.10.11
  521. ConvGetDescript(hdlg,szSrcName,&dwDesOffset,&dwDesLen,&Descript,TRUE);
  522. //**** end modify
  523. if(!(lpRule = GlobalLock(hRule)) ) {
  524. ProcessError(ERR_GLOBALLOCK,hdlg,ERR);
  525. break;
  526. }
  527. if(!ConvSaveRule(hdlg,szSrcName, dwDesLen,dwRuleLen,
  528. lpRule, Descript.wNumRules))
  529. break;
  530. ConvGetRule(hdlg, szSrcName, &dwRuleOffset, &dwRuleLen,
  531. lpRule, &Descript);
  532. GlobalUnlock(hRule);
  533. bModify = FALSE;
  534. EnableWindow(GetDlgItem(hdlg,IDC_CONV),TRUE);
  535. EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
  536. SendMessage(GetDlgItem(hdlg,IDC_SAVE),BM_SETSTYLE,BS_PUSHBUTTON,0L);
  537. SendMessage(GetDlgItem(hdlg,IDC_CONV),BM_SETSTYLE,BS_DEFPUSHBUTTON,TRUE);
  538. SetFocus(GetDlgItem(hdlg,IDC_CONV));
  539. break;
  540. case IDC_HLP:
  541. {
  542. TCHAR szHlpName[MAX_PATH];
  543. szHlpName[0] = 0;
  544. if (GetWindowsDirectory((LPTSTR)szHlpName, MAX_PATH))
  545. {
  546. StringCchCat(szHlpName, ARRAYSIZE(szHlpName),TEXT("\\HELP\\IMEGEN.CHM"));
  547. HtmlHelp(hdlg,szHlpName,HH_DISPLAY_TOPIC,0L);
  548. }
  549. }
  550. break;
  551. default:
  552. break;
  553. }
  554. break;
  555. default:
  556. break;
  557. }
  558. return FALSE;
  559. }
  560. VOID ConvProc(LPVOID hWnd)
  561. {
  562. static TCHAR file1[MAX_PATH]=TEXT("");
  563. static TCHAR file2[MAX_PATH]=TEXT("");
  564. SendMessage(GetParent(hDlgless),WM_COMMAND,IDC_GETSRCFILE,(LPARAM)file1);
  565. SendMessage(GetParent(hDlgless),WM_COMMAND,IDC_GETMBFILE,(LPARAM)file2);
  566. if(ConvConv(hDlgless,file1,file2))
  567. bEndProp=TRUE;
  568. SendMessage(hDlgless,WM_CLOSE,0,0L);
  569. }
  570. void SetDlgDescript(HWND hDlg,LPDESCRIPTION lpDescript)
  571. {
  572. short nElement;
  573. TCHAR _szStr[20];
  574. nElement =(lpDescript->byMaxElement==1)?IDC_SINGLEELEMENT:IDC_MULTIELEMENT;
  575. SetDlgItemText(hDlg,IDC_IMENAME,lpDescript->szName);
  576. SetDlgItemText(hDlg,IDC_USEDCODE,lpDescript->szUsedCode);
  577. _szStr[0]=lpDescript->cWildChar;
  578. _szStr[1]=0;
  579. SetDlgItemText(hDlg,IDC_WILDCHAR,_szStr);
  580. SetDlgItemInt (hDlg,IDC_MAXCODES,lpDescript->wMaxCodes,FALSE);
  581. CheckRadioButton(hDlg,IDC_SINGLEELEMENT,IDC_MULTIELEMENT,nElement);
  582. }
  583. void GetDlgDescript(HWND hDlg,LPDESCRIPTION lpDescript)
  584. {
  585. BOOL bTrans;
  586. TCHAR _szStr[20];
  587. GetDlgItemText(hDlg,IDC_IMENAME,lpDescript->szName,NAMESIZE);
  588. GetDlgItemText(hDlg,IDC_USEDCODE,lpDescript->szUsedCode,MAXUSEDCODES);
  589. GetDlgItemText(hDlg,IDC_WILDCHAR,_szStr,sizeof(_szStr)/sizeof(TCHAR));
  590. DelSpace(_szStr);
  591. if(_szStr[0]==0) _szStr[0]=TEXT('?');
  592. lpDescript->cWildChar=_szStr[0];
  593. lpDescript->wMaxCodes=(WORD)GetDlgItemInt (hDlg,IDC_MAXCODES,&bTrans,FALSE);
  594. lpDescript->wNumCodes=(WORD)lstrlen(lpDescript->szUsedCode);
  595. lpDescript->byMaxElement=(BYTE)(IsDlgButtonChecked(hDlg,IDC_MULTIELEMENT)?2:1);
  596. lpDescript->wNumRules=(WORD)SendDlgItemMessage(hDlg,IDC_LIST,LB_GETCOUNT,0,0L);
  597. }
  598. void SetDlgRuleStr(HWND hDlg,WORD NumRules,LPRULE lpRule)
  599. {
  600. WORD i;
  601. TCHAR _szStr[MAX_PATH];
  602. SendDlgItemMessage(hDlg,IDC_LIST,LB_RESETCONTENT,0,0L);
  603. if(NumRules==0) return;
  604. for(i=0; i<NumRules; i++) {
  605. RuleToText(&lpRule[i], _szStr);
  606. _szStr[lstrlen(_szStr)-2]=0;
  607. SendDlgItemMessage(hDlg,IDC_LIST,LB_ADDSTRING,0,(LPARAM)_szStr);
  608. }
  609. }
  610. void GetDlgRule(HWND hdlg,LPRULE lpRule,LPWORD fwNumRules,WORD MaxCodes)
  611. {
  612. int i;
  613. TCHAR _szStr[128];
  614. WORD NumRules = 0;
  615. lpRule = GlobalLock(hRule);
  616. *fwNumRules =(WORD)SendDlgItemMessage(hdlg,IDC_LIST,LB_GETCOUNT,0,0L);
  617. if((*fwNumRules) == 0)
  618. {
  619. GlobalUnlock(hRule);
  620. return;
  621. }
  622. for(i=0;i<(int)*fwNumRules;i++) {
  623. SendDlgItemMessage(hdlg,IDC_LIST,LB_GETTEXT,i,(LPARAM)_szStr);
  624. if(RuleParse(hdlg,_szStr,i,lpRule,MaxCodes))
  625. NumRules++;
  626. }
  627. GlobalUnlock(hRule);
  628. *fwNumRules = NumRules;
  629. }
  630. void DelSelRule(WORD wNumRules,WORD wSelect,LPRULE lpRule)
  631. {
  632. int i;
  633. if(wSelect>=MAXCODELEN) return;
  634. for(i=wSelect;i<wNumRules;i++)
  635. lpRule[i]=lpRule[i+1];
  636. }
  637. void SetConvDisable(HWND hDlg)
  638. {
  639. WORD wID;
  640. for(wID = IDC_MBNAME ;wID <= IDC_CONV ;wID++)
  641. EnableWindow(GetDlgItem(hDlg,wID),FALSE);
  642. EnableWindow(GetDlgItem(hDlg,IDC_CRTIME),FALSE);
  643. for(wID = IDC_STATIC1 ;wID <= IDC_STATIC5 ;wID++)
  644. EnableWindow(GetDlgItem(hDlg,wID),FALSE);
  645. }
  646. void SetConvEnable(HWND hDlg)
  647. {
  648. WORD wID;
  649. for(wID = IDC_MBNAME ;wID <= IDC_CONV ;wID++)
  650. EnableWindow(GetDlgItem(hDlg,wID),TRUE);
  651. EnableWindow(GetDlgItem(hDlg,IDC_CRTIME),TRUE);
  652. for(wID = IDC_STATIC1 ;wID <= IDC_STATIC5 ;wID++)
  653. EnableWindow(GetDlgItem(hDlg,wID),TRUE);
  654. }
  655. INT_PTR CALLBACK ConvEditProc(HWND hWnd,
  656. UINT wMsgID,
  657. WPARAM wParam,
  658. LPARAM lParam)
  659. {
  660. switch(wMsgID) {
  661. case WM_LBUTTONDBLCLK:
  662. SendMessage(GetParent(hWnd),WM_COMMAND,IDC_MODIFY,0L);
  663. break;
  664. case WM_KEYDOWN:
  665. switch(wParam) {
  666. case VK_DELETE:
  667. SendMessage(GetParent(hWnd),WM_COMMAND,IDC_DEL,0L);
  668. break;
  669. }
  670. default:
  671. return CallWindowProc((WNDPROC)lpConvProc,hWnd,wMsgID,wParam,lParam);
  672. }
  673. return FALSE;
  674. }
  675. void InstallConvSubClass(HWND hWnd)
  676. {
  677. lpConvProc = (FARPROC)SetWindowLongPtr(hWnd,GWLP_WNDPROC,(LONG_PTR)ConvEditProc);
  678. }
  679. INT_PTR CALLBACK AddRuleDlg(
  680. HWND hDlg,
  681. UINT message,
  682. WPARAM wParam,
  683. LPARAM lParam)
  684. {
  685. LPRULE lpRule;
  686. switch (message) {
  687. case WM_INITDIALOG:
  688. lpRule=GlobalLock(hRule);
  689. szRuleStr[0] = 0;
  690. SetDlgItemText(hDlg,IDC_EDITRULE,szRuleStr);
  691. return (TRUE);
  692. case WM_COMMAND:
  693. switch(LOWORD(wParam)) {
  694. case IDOK:
  695. GetDlgItemText(hDlg,IDC_EDITRULE,szRuleStr,sizeof(szRuleStr)/sizeof(TCHAR));
  696. SendMessage(GetParent(hDlg),WM_COMMAND,IDC_ADDRULE,(LPARAM)szRuleStr);
  697. if(*szRuleStr == 0)
  698. {
  699. SetFocus(GetDlgItem(hDlg,IDC_EDITRULE));
  700. return (TRUE);
  701. }
  702. GlobalUnlock(hRule);
  703. EndDialog(hDlg, TRUE);
  704. return (TRUE);
  705. case IDCANCEL:
  706. case WM_CLOSE:
  707. GlobalUnlock(hRule);
  708. EndDialog(hDlg, TRUE);
  709. break;
  710. default:
  711. break;
  712. }
  713. break;
  714. }
  715. return (FALSE);
  716. UNREFERENCED_PARAMETER(lParam);
  717. }
  718. INT_PTR CALLBACK ModiRuleDlg(
  719. HWND hDlg,
  720. UINT message,
  721. WPARAM wParam,
  722. LPARAM lParam)
  723. {
  724. LPRULE lpRule;
  725. switch (message) {
  726. case WM_INITDIALOG:
  727. lpRule=GlobalLock(hRule);
  728. SetDlgItemText(hDlg,IDC_EDITRULE,szRuleStr);
  729. return (TRUE);
  730. case WM_COMMAND:
  731. switch(LOWORD(wParam)) {
  732. case IDOK:
  733. GetDlgItemText(hDlg,IDC_EDITRULE,szRuleStr,sizeof(szRuleStr)/sizeof(TCHAR));
  734. SendMessage(GetParent(hDlg),WM_COMMAND,IDC_CHGDATA,(LPARAM)szRuleStr);
  735. if(*szRuleStr == 0)
  736. {
  737. SetFocus(GetDlgItem(hDlg,IDC_EDITRULE));
  738. return (TRUE);
  739. }
  740. GlobalUnlock(hRule);
  741. EndDialog(hDlg, TRUE);
  742. return (TRUE);
  743. case IDCANCEL:
  744. case WM_CLOSE:
  745. GlobalUnlock(hRule);
  746. EndDialog(hDlg, TRUE);
  747. break;
  748. default:
  749. break;
  750. }
  751. break;
  752. }
  753. return (FALSE);
  754. UNREFERENCED_PARAMETER(lParam);
  755. }
  756. //**********************************************************
  757. //SetupIme(ImeFileName, ImeLayoutName);
  758. //**********************************************************
  759. /*
  760. BOOL SetupIme(
  761. LPTSTR ImeFileName, //ime file name with full path
  762. LPTSTR MBFileName,
  763. LPTSTR ImeLayoutName)//ime layout name(in chinese)
  764. {
  765. HKEY hKeyCurrVersion, hKey, hNewKey;
  766. long retCode,i;
  767. UCHAR Buf[256], lpszName[256],LayoutHandleName[10];
  768. DWORD dwDisposition;
  769. memset(Buf,0,256);
  770. memset(lpszName,0,256);
  771. memset(LayoutHandleName, 0, 10);
  772. //create registry in keyboard layout
  773. retCode = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  774. REGSTR_PATH_CURRENT_CONTROL_SET,
  775. (DWORD)0,
  776. KEY_ENUMERATE_SUB_KEYS |
  777. KEY_EXECUTE |
  778. KEY_QUERY_VALUE,
  779. &hKeyCurrVersion);
  780. if (retCode) {
  781. wsprintf (Buf, "����: RegOpenKeyEx = %d", retCode);
  782. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  783. return FALSE;
  784. }
  785. retCode = RegOpenKeyEx (hKeyCurrVersion,
  786. "Keyboard Layouts",
  787. 0,
  788. KEY_ENUMERATE_SUB_KEYS |
  789. KEY_EXECUTE |
  790. KEY_QUERY_VALUE,
  791. &hKey);
  792. if (retCode) {
  793. wsprintf (Buf, "����: RegOpenKeyEx = %d", retCode);
  794. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  795. return FALSE;
  796. }
  797. for(i=0;;i++){
  798. retCode = RegEnumKey(hKey, // handle of key to query
  799. i, // index of subkey to query
  800. lpszName, // address of buffer for subkey name
  801. 256); // size of subkey buffer
  802. if(retCode)
  803. break;
  804. else{
  805. if(strcmp(Buf, lpszName)<0)
  806. strcpy(Buf, lpszName);
  807. }
  808. }
  809. if(Buf[0]=='\0')
  810. return FALSE;
  811. if(Buf[3]=='f' || Buf[3]=='F'){
  812. Buf[3]== '0';
  813. Buf[2]++;
  814. }else if(Buf[3]=='9')
  815. Buf[3]='A';
  816. else
  817. Buf[3]++;
  818. strcpy(LayoutHandleName,Buf);
  819. retCode = RegCreateKeyEx (hKey,
  820. LayoutHandleName,
  821. 0,
  822. 0,
  823. REG_OPTION_NON_VOLATILE,
  824. KEY_ALL_ACCESS,
  825. NULL,
  826. &hNewKey,
  827. &dwDisposition);
  828. if (retCode) {
  829. wsprintf (Buf, "����: RegOpenKeyEx = %d", retCode);
  830. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  831. return FALSE;
  832. }
  833. GetFileTitle(ImeFileName, Buf, MAX_PATH);
  834. retCode = RegSetValueEx (hNewKey,
  835. "IME file",
  836. (DWORD)NULL,
  837. REG_SZ,
  838. (LPBYTE)Buf,
  839. strlen(Buf));
  840. if (retCode) {
  841. wsprintf (Buf, "����: RegSetValueEx = %d", retCode);
  842. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  843. return FALSE;
  844. }
  845. strcpy(Buf, "kbdus.kbd");
  846. retCode = RegSetValueEx (hNewKey,
  847. "layout file",
  848. (DWORD)NULL,
  849. REG_SZ,
  850. (LPBYTE)Buf,
  851. strlen(Buf));
  852. if (retCode) {
  853. wsprintf (Buf, "����: RegSetValueEx = %d", retCode);
  854. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  855. return FALSE;
  856. }
  857. strcpy(Buf, ImeLayoutName);
  858. retCode = RegSetValueEx (hNewKey,
  859. "layout text",
  860. (DWORD)NULL,
  861. REG_SZ,
  862. (LPBYTE)Buf,
  863. strlen(Buf));
  864. if (retCode) {
  865. wsprintf (Buf, "����: RegSetValueEx = %d", retCode);
  866. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  867. return FALSE;
  868. }
  869. RegCloseKey(hNewKey);
  870. RegCloseKey(hKey);
  871. RegCloseKey(hKeyCurrVersion);
  872. //create registry in preload
  873. retCode = RegOpenKeyEx (HKEY_CURRENT_USER,
  874. "Keyboard Layout\\Preload",
  875. 0,
  876. KEY_ENUMERATE_SUB_KEYS |
  877. KEY_EXECUTE |
  878. KEY_QUERY_VALUE,
  879. &hKeyCurrVersion);
  880. if (retCode) {
  881. wsprintf (Buf, "����: RegOpenKeyEx = %d", retCode);
  882. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  883. return FALSE;
  884. }
  885. memset(Buf,0,256);
  886. memset(lpszName,0,256);
  887. for(i=0;;i++){
  888. retCode = RegEnumKey(hKeyCurrVersion, // handle of key to query
  889. i, // index of subkey to query
  890. lpszName, // address of buffer for subkey name
  891. 256); // size of subkey buffer
  892. if(retCode)
  893. break;
  894. else{
  895. if(strcmp(Buf, lpszName)<0)
  896. strcpy(Buf, lpszName);
  897. }
  898. }
  899. if(Buf[0]=='\0')
  900. return FALSE;
  901. i=_ttoi(Buf);
  902. i++;
  903. _itoa(i,Buf,10);
  904. retCode = RegCreateKeyEx (hKeyCurrVersion,
  905. Buf,
  906. 0,
  907. 0,
  908. REG_OPTION_NON_VOLATILE,
  909. KEY_ALL_ACCESS,
  910. NULL,
  911. &hNewKey,
  912. &dwDisposition);
  913. if (retCode) {
  914. wsprintf (Buf, "����: RegOpenKeyEx = %d", retCode);
  915. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  916. return FALSE;
  917. }
  918. retCode = RegSetValueEx (hNewKey,
  919. NULL,
  920. (DWORD)NULL,
  921. REG_SZ,
  922. (LPBYTE)LayoutHandleName,
  923. strlen(LayoutHandleName));
  924. if (retCode) {
  925. wsprintf (Buf, "����: RegSetValueEx = %d", retCode);
  926. MessageBox (NULL, Buf, "����", MB_OK | MB_ICONINFORMATION);
  927. return FALSE;
  928. }
  929. RegCloseKey(hNewKey);
  930. RegCloseKey(hKey);
  931. RegCloseKey(hKeyCurrVersion);
  932. //copy files
  933. {
  934. UCHAR DesFilePath[MAX_PATH];
  935. GetSystemDirectory(DesFilePath,MAX_PATH);
  936. strcat(DesFilePath,"\\");
  937. GetFileTitle(ImeFileName, Buf, MAX_PATH);
  938. strcat(DesFilePath,Buf);
  939. CopyFile(ImeFileName, DesFilePath, FALSE);
  940. GetSystemDirectory(DesFilePath,MAX_PATH);
  941. strcat(DesFilePath,"\\");
  942. GetFileTitle(MBFileName, Buf, MAX_PATH);
  943. strcat(DesFilePath,Buf);
  944. CopyFile(MBFileName, DesFilePath, FALSE);
  945. }
  946. return TRUE;
  947. }
  948. */
  949. //Hack for #62554 10/29/96
  950. HWND HwndCrtImeDlg = NULL;
  951. INT_PTR CALLBACK CrtImeDlg(
  952. HWND hDlg,
  953. UINT message,
  954. WPARAM wParam,
  955. LPARAM lParam)
  956. {
  957. static TCHAR _szStr[MAX_PATH];
  958. static TCHAR ImeTplName[MAX_PATH];
  959. static TCHAR mbName[MAX_PATH];
  960. static IMERES ImeRes;
  961. LPTSTR lpString;
  962. HwndCrtImeDlg = hDlg;
  963. switch (message) {
  964. case WM_INITDIALOG:
  965. SendMessage(GetParent(hDlg),WM_COMMAND,IDC_GETMBFILE,(LPARAM)mbName);
  966. SendDlgItemMessage(hDlg,IDC_VERSION,EM_LIMITTEXT,8,0L);
  967. SendDlgItemMessage(hDlg,IDC_GROUP,EM_LIMITTEXT,32,0L);
  968. SetDlgItemText(hDlg, IDC_VERSION,TEXT(DefVer));
  969. SetDlgItemText(hDlg, IDC_GROUP, TEXT(DefOrgName));
  970. ImeRes.Value = 0x00af;
  971. SetValue(hDlg,ImeRes.Value);
  972. SendMessage(hDlg,WM_COMMAND, IDC_DEF, 0L);
  973. CheckRadioButton(hDlg,IDC_DEF,IDC_USERDEF,IDC_DEF);
  974. break;
  975. case WM_COMMAND:
  976. switch(LOWORD(wParam)) {
  977. case IDOK:
  978. {
  979. DESCRIPTION Descript;
  980. TCHAR tmpBuf[MAX_PATH];
  981. if(!GetImeRes(hDlg,&ImeRes))
  982. return TRUE;
  983. ReadDescript(mbName,&Descript,FILE_SHARE_READ);
  984. StringCchCopy(_szStr, ARRAYSIZE(_szStr),Descript.szName);
  985. StringCchCat(_szStr, ARRAYSIZE(_szStr), szVer);
  986. StringCchCat(_szStr, ARRAYSIZE(_szStr), ImeRes.Version);
  987. lstrcpy(ImeRes.Version, _szStr);
  988. GetSystemDirectory(ImeTplName,sizeof(ImeTplName)/sizeof(TCHAR));
  989. StringCchCopy(_szStr, ARRAYSIZE(_szStr), ImeTplName);
  990. StringCchCat(ImeTplName, ARRAYSIZE(ImeTplName), TEXT(TplName));
  991. StringCchCat(_szStr, ARRAYSIZE(_szStr), TEXT("\\"));
  992. GetFileTitle(mbName, tmpBuf, MAX_PATH);
  993. StringCchCat(_szStr, ARRAYSIZE(_szStr), tmpBuf);
  994. if((lpString=_tcsrchr(_szStr,TEXT('.')))!=NULL)
  995. *lpString=0;
  996. StringCchCat(_szStr, ARRAYSIZE(_szStr),TEXT(ImeExt));
  997. DispInfo(GetWindow(hDlg, GW_OWNER),IDS_UPRES);
  998. CopyFile(ImeTplName, _szStr, FALSE);
  999. if(ImeUpdateRes(_szStr, ImeRes.BmpName, ImeRes.IcoName,ImeRes.Version,
  1000. ImeRes.Depart, ImeRes.Value)==TRUE){
  1001. TCHAR szDBCS[256];
  1002. LoadString(NULL,IDS_SETUPIME,szDBCS, sizeof(szDBCS)/sizeof(TCHAR));
  1003. if(ErrMessage(hDlg, szDBCS))
  1004. {
  1005. HKL hKL;
  1006. TCHAR DesFilePath[MAX_PATH],Buf[MAX_PATH];
  1007. hKL = ImmInstallIME(_szStr,Descript.szName);
  1008. //copy .MB & .HLP to system directory.
  1009. if(hKL){
  1010. GetSystemDirectory(DesFilePath,MAX_PATH);
  1011. StringCchCat(DesFilePath, ARRAYSIZE(DesFilePath), TEXT("\\"));
  1012. GetFileTitle(mbName, Buf, MAX_PATH);
  1013. StringCchCat(DesFilePath, ARRAYSIZE(DesFilePath),Buf);
  1014. CopyFile(mbName, DesFilePath, FALSE);
  1015. if(ImeRes.HlpFile[0]){
  1016. StringCchCopy(_szStr, ARRAYSIZE(_szStr), DesFilePath);
  1017. if((lpString=_tcsrchr(_szStr,TEXT('.')))!=NULL)
  1018. *lpString=0;
  1019. StringCchCat(_szStr,ARRAYSIZE(_szStr), TEXT(HlpExt));
  1020. CopyFile( ImeRes.HlpFile, _szStr, FALSE);
  1021. if((lpString=_tcsrchr(ImeRes.HlpFile,TEXT('.')))!=NULL)
  1022. *lpString=0;
  1023. StringCchCat(ImeRes.HlpFile,ARRAYSIZE(ImeRes.HlpFile),TEXT(".CNT"));
  1024. StringCchCopy(_szStr, ARRAYSIZE(_szStr), DesFilePath);
  1025. if((lpString=_tcsrchr(_szStr,TEXT('\\')))!=NULL)
  1026. *(lpString+1)=0;
  1027. GetFileTitle(ImeRes.HlpFile, Buf, MAX_PATH);
  1028. StringCchCat(_szStr,ARRAYSIZE(_szStr),Buf);
  1029. CopyFile( ImeRes.HlpFile, _szStr, FALSE);
  1030. if((lpString=_tcsrchr(ImeRes.HlpFile,TEXT('.')))!=NULL)
  1031. *(lpString+1)=0;
  1032. StringCchCat(ImeRes.HlpFile,ARRAYSIZE(ImeRes.HlpFile), TEXT(".GID"));
  1033. StringCchCopy(_szStr,ARRAYSIZE(_szStr), DesFilePath);
  1034. if((lpString=_tcsrchr(_szStr,TEXT('\\')))!=NULL)
  1035. *lpString=0;
  1036. GetFileTitle(ImeRes.HlpFile, Buf, MAX_PATH);
  1037. StringCchCat(_szStr,ARRAYSIZE(_szStr), Buf);
  1038. CopyFile( ImeRes.HlpFile, _szStr, FALSE);
  1039. }
  1040. }else{
  1041. LoadString(NULL,IDS_ERR_INSTALLIME,_szStr, sizeof(_szStr)/sizeof(TCHAR));
  1042. WarnMessage(hDlg,_szStr);
  1043. }
  1044. }
  1045. }
  1046. EndDialog(hDlg, TRUE);
  1047. return (TRUE);
  1048. }
  1049. case IDC_BROWSE:
  1050. if(!RcFileOpenDlg(hDlg, _szStr,Title))
  1051. break;
  1052. if(_tcsstr(_tcsupr(_szStr),TEXT(BmpExt)) != NULL)
  1053. SetDlgItemText(hDlg, IDC_BMP, _szStr);
  1054. #ifdef UNICODE
  1055. else if(_tcsstr(_wcsupr(_szStr),TEXT(IconExt)) != NULL)
  1056. #else
  1057. else if(_tcsstr(_strupr(_szStr),TEXT(IconExt)) != NULL)
  1058. #endif
  1059. SetDlgItemText(hDlg, IDC_ICO, _szStr);
  1060. #ifdef UNICODE
  1061. else if(_tcsstr(_wcsupr(_szStr),TEXT(HlpExt)) != NULL)
  1062. #else
  1063. else if(_tcsstr(_strupr(_szStr),TEXT(HlpExt)) != NULL)
  1064. #endif
  1065. SetDlgItemText(hDlg, IDC_HLPFILE, _szStr);
  1066. break;
  1067. case IDC_DEF:
  1068. EnableWindow(GetDlgItem(hDlg,IDC_BMP), FALSE);
  1069. EnableWindow(GetDlgItem(hDlg,IDC_ICO), FALSE);
  1070. EnableWindow(GetDlgItem(hDlg,IDC_HLPFILE), FALSE);
  1071. EnableWindow(GetDlgItem(hDlg,IDC_BROWSE), FALSE);
  1072. GetDlgItemText(hDlg, IDC_ICO, ImeRes.IcoName,sizeof(ImeRes.IcoName)/sizeof(TCHAR));
  1073. GetDlgItemText(hDlg, IDC_BMP, ImeRes.BmpName,sizeof(ImeRes.BmpName)/sizeof(TCHAR) );
  1074. GetDlgItemText(hDlg, IDC_BMP, ImeRes.HlpFile,sizeof(ImeRes.HlpFile)/sizeof(TCHAR));
  1075. _szStr[0] = 0;
  1076. SetDlgItemText(hDlg, IDC_ICO, _szStr);
  1077. SetDlgItemText(hDlg, IDC_BMP, _szStr);
  1078. SetDlgItemText(hDlg, IDC_HLPFILE, _szStr);
  1079. break;
  1080. case IDC_USERDEF:
  1081. EnableWindow(GetDlgItem(hDlg,IDC_BMP), TRUE);
  1082. EnableWindow(GetDlgItem(hDlg,IDC_ICO), TRUE);
  1083. EnableWindow(GetDlgItem(hDlg,IDC_HLPFILE), TRUE);
  1084. EnableWindow(GetDlgItem(hDlg,IDC_BROWSE), TRUE);
  1085. SetDlgItemText(hDlg, IDC_ICO, ImeRes.IcoName);
  1086. SetDlgItemText(hDlg, IDC_BMP, ImeRes.BmpName);
  1087. SetDlgItemText(hDlg, IDC_HLPFILE, ImeRes.HlpFile);
  1088. break;
  1089. case IDC_ZJTS:
  1090. if(IsDlgButtonChecked(hDlg,IDC_ZJTS))
  1091. EnableWindow(GetDlgItem(hDlg,IDC_WMTS),TRUE);
  1092. else {
  1093. CheckDlgButton(hDlg,IDC_WMTS,0);
  1094. EnableWindow(GetDlgItem(hDlg,IDC_WMTS),FALSE);
  1095. }
  1096. break;
  1097. case IDCANCEL:
  1098. case WM_CLOSE:
  1099. EndDialog(hDlg, TRUE);
  1100. return (TRUE);
  1101. default:
  1102. break;
  1103. }
  1104. break;
  1105. }
  1106. return (FALSE);
  1107. UNREFERENCED_PARAMETER(lParam);
  1108. }
  1109. void SetValue(HWND hDlg, WORD Value)
  1110. {
  1111. CheckDlgButton(hDlg,IDC_CYLX,Value&0x0001);
  1112. CheckDlgButton(hDlg,IDC_CYSR,Value&0x0002);
  1113. CheckDlgButton(hDlg,IDC_ZJTS,Value&0x0004);
  1114. if((Value&0x0004)==0) {
  1115. EnableWindow(GetDlgItem(hDlg,IDC_WMTS),FALSE);
  1116. Value &= ~ 0x0008;
  1117. }
  1118. CheckDlgButton(hDlg,IDC_WMTS,Value&0x0008);
  1119. CheckDlgButton(hDlg,IDC_GBGS,Value&0x0020);
  1120. CheckDlgButton(hDlg,IDC_SPACE,Value&0x0040);
  1121. CheckDlgButton(hDlg,IDC_ENTER,Value&0x0080);
  1122. }
  1123. void GetValue(HWND hDlg,LPWORD Value)
  1124. {
  1125. *Value = 0;
  1126. *Value |= IsDlgButtonChecked(hDlg,IDC_CYLX);
  1127. *Value |= IsDlgButtonChecked(hDlg,IDC_CYSR) << 1;
  1128. *Value |= IsDlgButtonChecked(hDlg,IDC_ZJTS) << 2;
  1129. *Value |= IsDlgButtonChecked(hDlg,IDC_WMTS) << 3;
  1130. *Value |= IsDlgButtonChecked(hDlg,IDC_GBGS) << 5;
  1131. *Value |= IsDlgButtonChecked(hDlg,IDC_SPACE) << 6;
  1132. *Value |= IsDlgButtonChecked(hDlg,IDC_ENTER) << 7;
  1133. }
  1134. int GetImeRes(HWND hDlg,LPIMERES lpImeRes)
  1135. {
  1136. GetDlgItemText(hDlg, IDC_VERSION, lpImeRes->Version, sizeof(lpImeRes->Version)/sizeof(TCHAR));
  1137. if(lstrlen(lpImeRes->Version) == 0)
  1138. {
  1139. ProcessError(ERR_VERSION, hDlg, WARNING);
  1140. return FALSE;
  1141. }
  1142. GetDlgItemText(hDlg, IDC_GROUP, lpImeRes->Depart, sizeof(lpImeRes->Depart)/sizeof(TCHAR));
  1143. if(lstrlen(lpImeRes->Depart) == 0)
  1144. {
  1145. ProcessError(ERR_GROUP, hDlg, WARNING);
  1146. return FALSE;
  1147. }
  1148. GetDlgItemText(hDlg, IDC_BMP, lpImeRes->BmpName, sizeof(lpImeRes->BmpName)/sizeof(TCHAR));
  1149. GetDlgItemText(hDlg, IDC_ICO, lpImeRes->IcoName, sizeof(lpImeRes->IcoName)/sizeof(TCHAR));
  1150. GetValue(hDlg, &(lpImeRes->Value));
  1151. return TRUE;
  1152. }