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.

1229 lines
36 KiB

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