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.

240 lines
6.6 KiB

  1. /*************************************************
  2. * recnvdlg.c *
  3. * *
  4. * Copyright (C) 1995-1999 Microsoft Inc. *
  5. * *
  6. *************************************************/
  7. #include "prop.h"
  8. /*****************************************************************************
  9. FUNCTION: ReConvDialogProc(HWND, UINT, WPARAM, LPARAM)
  10. PURPOSE: Processes messages for "reconv" property sheet.
  11. PARAMETERS:
  12. hdlg - window handle of the property sheet
  13. wMessage - type of message
  14. wparam - message-specific information
  15. lparam - message-specific information
  16. RETURN VALUE:
  17. TRUE - message handled
  18. FALSE - message not handled
  19. HISTORY:
  20. 04-18-95 Yehfew Tie Created.
  21. ****************************************************************************/
  22. INT_PTR CALLBACK ReConvDialogProc(HWND hdlg,
  23. UINT uMessage,
  24. WPARAM wparam,
  25. LPARAM lparam)
  26. {
  27. LPNMHDR lpnmhdr;
  28. static TCHAR szMBFile[MAX_PATH];
  29. static TCHAR szSrcFile[MAX_PATH];
  30. static HANDLE hRule0;
  31. LPTSTR lpString;
  32. TCHAR szStr[MAX_PATH];
  33. MAININDEX MainIndex[NUMTABLES];
  34. HANDLE hFile;
  35. FARPROC lpProcInfo;
  36. switch (uMessage)
  37. {
  38. case WM_INITDIALOG:
  39. SetReConvDisable(hdlg);
  40. break;
  41. case WM_NOTIFY:
  42. lpnmhdr = (NMHDR FAR *)lparam;
  43. switch (lpnmhdr->code)
  44. {
  45. case PSN_SETACTIVE:
  46. hEncode = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,
  47. NUMENCODEAREA*sizeof(ENCODEAREA));
  48. if(!hRule )
  49. ProcessError(ERR_OUTOFMEMORY,hdlg,ERR);
  50. if ( hEncode )
  51. ConvInitEncode(hEncode);
  52. break;
  53. case PSN_KILLACTIVE:
  54. if(hEncode)
  55. GlobalFree(hEncode);
  56. break;
  57. break;
  58. case PSN_APPLY:
  59. break;
  60. case PSN_RESET:
  61. break;
  62. case PSN_QUERYCANCEL:
  63. break;
  64. case PSN_HELP:
  65. break;
  66. default:
  67. break;
  68. }
  69. break;
  70. case WM_COMMAND:
  71. switch (LOWORD(wparam))
  72. {
  73. case ID_FILEOPEN:
  74. {
  75. #ifdef UNICODE
  76. static TCHAR szTitle[] = {0x6253, 0x5F00, 0x0000};
  77. #else
  78. TCHAR szTitle[MAX_PATH];
  79. strcpy(szTitle,"����");
  80. #endif
  81. if(!MBFileOpenDlg(hdlg,szStr,szTitle))
  82. break;
  83. }
  84. lstrcpy(szMBFile, szStr);
  85. lstrcpy(szSrcFile,szMBFile);
  86. SetReConvDisable(hdlg);
  87. hFile = Create_File(hdlg,szMBFile,GENERIC_READ,OPEN_EXISTING);
  88. if (hFile == (HANDLE)-1) {
  89. szMBFile[0]=0;
  90. lstrcpy(szSrcFile,szMBFile);
  91. SetDlgItemText(hdlg,IDC_MBNAME,szMBFile);
  92. SetDlgItemText(hdlg,IDC_SRCNAME,szSrcFile);
  93. break;
  94. }
  95. if(!ConvGetMainIndex(hdlg,hFile,MainIndex)) {
  96. szMBFile[0] = 0;
  97. lstrcpy(szSrcFile,szMBFile);
  98. CloseHandle(hFile);
  99. SetDlgItemText(hdlg,IDC_SRCNAME,szSrcFile);
  100. SetDlgItemText(hdlg,IDC_MBNAME,szMBFile);
  101. break;
  102. }
  103. {
  104. DESCRIPTION Descript; //add 95.10.26
  105. ConvReadDescript(hFile,&Descript, MainIndex);
  106. SetReconvDlgDes(hdlg,&Descript);
  107. }
  108. fnsplit(szMBFile, szStr);
  109. SetDlgItemText(hdlg,IDC_MBNAME,szStr);
  110. if((lpString = _tcsrchr(szSrcFile,TEXT('.')))!=NULL)
  111. *lpString = 0;
  112. lstrcat(szSrcFile, TEXT(TxtFileExt));
  113. SetDlgItemText(hdlg,IDC_SRCNAME,szSrcFile);
  114. CloseHandle(hFile);
  115. SetReConvEnable(hdlg);
  116. SendMessage(GetDlgItem(hdlg,ID_FILEOPEN),BM_SETSTYLE,BS_PUSHBUTTON,0L);
  117. SendMessage(GetDlgItem(hdlg,IDC_RECONV),BM_SETSTYLE,BS_DEFPUSHBUTTON,TRUE);
  118. SetFocus(GetDlgItem(hdlg,IDC_RECONV));
  119. break;
  120. case IDC_SRCNAME:
  121. GetDlgItemText(hdlg,IDC_SRCNAME,szSrcFile,MAX_PATH);
  122. if(lstrlen(szSrcFile) == 0)
  123. EnableWindow(GetDlgItem(hdlg,IDC_RECONV),FALSE);
  124. else
  125. EnableWindow(GetDlgItem(hdlg,IDC_RECONV),TRUE);
  126. break;
  127. case IDC_GETMBFILE:
  128. lstrcpy((LPTSTR)lparam,szMBFile);
  129. break;
  130. case IDC_GETSRCFILE:
  131. lstrcpy((LPTSTR)lparam,szSrcFile);
  132. break;
  133. case IDC_RECONV:
  134. lpProcInfo = MakeProcInstance((FARPROC)InfoDlg, hInst);
  135. pfnmsg = (PFNMSG)ReConvProc;
  136. bEndProp = FALSE;
  137. DialogBox(hInst,
  138. MAKEINTRESOURCE(IDD_INFO),
  139. hdlg,
  140. (DLGPROC)lpProcInfo);
  141. /*if(bEndProp)
  142. PropSheet_PressButton(GetParent(hdlg),PSBTN_OK);*/
  143. FreeProcInstance(lpProcInfo);
  144. break;
  145. default:
  146. break;
  147. }
  148. break;
  149. default:
  150. break;
  151. }
  152. return FALSE;
  153. }
  154. VOID ReConvProc(LPVOID hWnd)
  155. {
  156. static TCHAR file1[MAX_PATH]=TEXT("");
  157. static TCHAR file2[MAX_PATH]=TEXT("");
  158. SendMessage(GetParent(hDlgless),WM_COMMAND,IDC_GETSRCFILE,(LPARAM)file1);
  159. SendMessage(GetParent(hDlgless),WM_COMMAND,IDC_GETMBFILE,(LPARAM)file2);
  160. if(ConvReConv(hDlgless,file1,file2))
  161. bEndProp=TRUE;
  162. SendMessage(hDlgless,WM_CLOSE,0,0L);
  163. }
  164. void SetReConvDisable(HWND hDlg)
  165. {
  166. WORD wID;
  167. EnableWindow(GetDlgItem(hDlg,IDC_RECONV),FALSE);
  168. EnableWindow(GetDlgItem(hDlg,IDC_SRCNAME),FALSE);
  169. EnableWindow(GetDlgItem(hDlg,IDC_MBNAME),FALSE);
  170. for(wID = IDC_STATIC1 ;wID <= IDC_STATIC8 ;wID++)
  171. EnableWindow(GetDlgItem(hDlg,wID),FALSE);
  172. }
  173. void SetReConvEnable(HWND hDlg)
  174. {
  175. WORD wID;
  176. EnableWindow(GetDlgItem(hDlg,IDC_RECONV),TRUE);
  177. EnableWindow(GetDlgItem(hDlg,IDC_SRCNAME),TRUE);
  178. EnableWindow(GetDlgItem(hDlg,IDC_MBNAME),TRUE);
  179. for(wID = IDC_STATIC1 ;wID <= IDC_STATIC8 ;wID++)
  180. EnableWindow(GetDlgItem(hDlg,wID),TRUE);
  181. }
  182. void SetReconvDlgDes(HWND hDlg,LPDESCRIPTION lpDescript)
  183. {
  184. TCHAR szStr[48];
  185. SetDlgItemText(hDlg,IDC_IMENAME,lpDescript->szName);
  186. lstrcpy(szStr,lpDescript->szUsedCode);
  187. szStr[30]=0;
  188. SetDlgItemText(hDlg,IDC_USEDCODE1,szStr);
  189. if(lstrlen(lpDescript->szUsedCode) > 30)
  190. SetDlgItemText(hDlg,IDC_USEDCODE2,&(lpDescript->szUsedCode[30]));
  191. else
  192. SetDlgItemText(hDlg,IDC_USEDCODE2,NULL);
  193. szStr[0]=lpDescript->cWildChar;
  194. szStr[1]=0;
  195. SetDlgItemText(hDlg,IDC_WILDCHAR,szStr);
  196. SetDlgItemInt (hDlg,IDC_MAXCODES,lpDescript->wMaxCodes,FALSE);
  197. SetDlgItemInt (hDlg,IDC_MAXELEMENT,lpDescript->byMaxElement,FALSE);
  198. SetDlgItemInt (hDlg,IDC_RULENUM,lpDescript->wNumRules,FALSE);
  199. }