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.

244 lines
7.0 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. DialogBox(hInst,
  145. MAKEINTRESOURCE(IDD_INFO),
  146. hdlg,
  147. InfoDlg);
  148. break;
  149. default:
  150. break;
  151. }
  152. break;
  153. default:
  154. break;
  155. }
  156. return FALSE;
  157. }
  158. VOID ReConvProc(LPVOID hWnd)
  159. {
  160. static TCHAR file1[MAX_PATH]=TEXT("");
  161. static TCHAR file2[MAX_PATH]=TEXT("");
  162. SendMessage(GetParent(hDlgless),WM_COMMAND,IDC_GETSRCFILE,(LPARAM)file1);
  163. SendMessage(GetParent(hDlgless),WM_COMMAND,IDC_GETMBFILE,(LPARAM)file2);
  164. if(ConvReConv(hDlgless,file1,file2))
  165. bEndProp=TRUE;
  166. SendMessage(hDlgless,WM_CLOSE,0,0L);
  167. }
  168. void SetReConvDisable(HWND hDlg)
  169. {
  170. WORD wID;
  171. EnableWindow(GetDlgItem(hDlg,IDC_RECONV),FALSE);
  172. EnableWindow(GetDlgItem(hDlg,IDC_SRCNAME),FALSE);
  173. EnableWindow(GetDlgItem(hDlg,IDC_MBNAME),FALSE);
  174. for(wID = IDC_STATIC1 ;wID <= IDC_STATIC8 ;wID++)
  175. EnableWindow(GetDlgItem(hDlg,wID),FALSE);
  176. }
  177. void SetReConvEnable(HWND hDlg)
  178. {
  179. WORD wID;
  180. EnableWindow(GetDlgItem(hDlg,IDC_RECONV),TRUE);
  181. EnableWindow(GetDlgItem(hDlg,IDC_SRCNAME),TRUE);
  182. EnableWindow(GetDlgItem(hDlg,IDC_MBNAME),TRUE);
  183. for(wID = IDC_STATIC1 ;wID <= IDC_STATIC8 ;wID++)
  184. EnableWindow(GetDlgItem(hDlg,wID),TRUE);
  185. }
  186. void SetReconvDlgDes(HWND hDlg,LPDESCRIPTION lpDescript)
  187. {
  188. TCHAR szStr[48];
  189. SetDlgItemText(hDlg,IDC_IMENAME,lpDescript->szName);
  190. lstrcpy(szStr,lpDescript->szUsedCode);
  191. szStr[30]=0;
  192. SetDlgItemText(hDlg,IDC_USEDCODE1,szStr);
  193. if(lstrlen(lpDescript->szUsedCode) > 30)
  194. SetDlgItemText(hDlg,IDC_USEDCODE2,&(lpDescript->szUsedCode[30]));
  195. else
  196. SetDlgItemText(hDlg,IDC_USEDCODE2,NULL);
  197. szStr[0]=lpDescript->cWildChar;
  198. szStr[1]=0;
  199. SetDlgItemText(hDlg,IDC_WILDCHAR,szStr);
  200. SetDlgItemInt (hDlg,IDC_MAXCODES,lpDescript->wMaxCodes,FALSE);
  201. SetDlgItemInt (hDlg,IDC_MAXELEMENT,lpDescript->byMaxElement,FALSE);
  202. SetDlgItemInt (hDlg,IDC_RULENUM,lpDescript->wNumRules,FALSE);
  203. }