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.

278 lines
9.9 KiB

  1. //
  2. // ���C ���Ѹ��T ���X�D�{��
  3. //
  4. // ���Ż� 1998/03/15
  5. //
  6. #include <windows.h>
  7. #include <commdlg.h>
  8. #include <string.h>
  9. #include <stdlib.h>
  10. #include <direct.h>
  11. #include "resource.h"
  12. #include "function.h"
  13. char szAppName[] = "���C���Ѹ��T���X�{��" ;
  14. char *szFilterI = "���r�� (*.TXT;*.NT)\0*.txt;*.nt\0All Files (*.*)\0*.*\0";
  15. char *szFilterO = "������ (*.TAB)\0*.tab\0All Files (*.*)\0*.*\0";
  16. char *szFilterH = "���w�� (*.TBL)\0*.tbl\0All Files (*.*)\0*.*\0";
  17. HANDLE hInst;
  18. //HWND msghwnd;
  19. char szInWordFileName[256];
  20. char szOutWordFileName[256];
  21. char szInHighFileName[256];
  22. char szOutHighFileName[256];
  23. char szInPhrFileName[256];
  24. char szOutPhrFileName[256];
  25. char szIdxFileName[256];
  26. char hlpfile[256];
  27. DWORD line;
  28. long FAR PASCAL CALLBACK WndProc (HWND, UINT, UINT, LONG) ;
  29. int cvtword (char *,char *,DWORD *);
  30. int cvthigh (char *,char *,DWORD *);
  31. int cvtphrase (char *,char *,char *,DWORD *);
  32. void error(HWND hwnd,int ErrCode,int item)
  33. {
  34. char Buffer[255];
  35. char szMsg[255];
  36. if(LoadString(hInst, ErrCode, (LPSTR)Buffer, sizeof(Buffer)))
  37. switch(ErrCode)
  38. {
  39. case IDS_ERROPENFILE:
  40. case IDS_ERRUNICODE:
  41. case IDS_ERRFORMATROOT:
  42. case IDS_ERRFORMATROOTS:
  43. case IDS_ERRFORMATPHRASE:
  44. case IDS_ERRFORMATCODE:
  45. switch(item)
  46. {
  47. case IDM_WORD:
  48. wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInWordFileName,line);
  49. break;
  50. case IDM_HIGH:
  51. wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInHighFileName,line);
  52. break;
  53. case IDM_PHRASE:
  54. wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInPhrFileName,line);
  55. break;
  56. }
  57. break;
  58. case IDS_ERRCREATEFILE:
  59. switch(item)
  60. {
  61. case IDM_WORD:
  62. wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutWordFileName,line);
  63. break;
  64. case IDM_HIGH:
  65. wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutHighFileName,line);
  66. break;
  67. case IDM_PHRASE:
  68. wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutPhrFileName,line);
  69. break;
  70. }
  71. break;
  72. case IDS_ERRCREATEIDX:
  73. wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szIdxFileName);
  74. break;
  75. default:
  76. strcpy(szMsg,"�o�ͤ������~!");
  77. break;
  78. }
  79. else
  80. strcpy(szMsg,"�o�ͤ������~!");
  81. MessageBox(hwnd,(LPSTR)szMsg,szAppName,MB_OK | MB_ICONHAND |MB_APPLMODAL);
  82. }
  83. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
  84. LPSTR lpszCmdParam, int nCmdShow)
  85. {
  86. HWND hwnd ;
  87. MSG msg ;
  88. WNDCLASS wndclass ;
  89. if (!hPrevInstance)
  90. {
  91. wndclass.style = CS_HREDRAW | CS_VREDRAW ;
  92. wndclass.lpfnWndProc = WndProc ;
  93. wndclass.cbClsExtra = 0 ;
  94. wndclass.cbWndExtra = 0 ;
  95. wndclass.hInstance = hInstance ;
  96. wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;//LoadIcon (hInstance, "ICON") ;
  97. wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
  98. wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ;
  99. wndclass.lpszMenuName = "MENU" ;
  100. wndclass.lpszClassName = szAppName ;
  101. RegisterClass (&wndclass) ;
  102. }
  103. hInst=hInstance;
  104. _getcwd( hlpfile, sizeof(hlpfile));
  105. if(hlpfile[strlen(hlpfile)-1]=='\\')
  106. hlpfile[strlen(hlpfile)-1]=0;
  107. strcat(hlpfile,"\\ARCVT.TXT");
  108. hwnd = CreateWindow (szAppName, // window class name
  109. szAppName, // window caption
  110. WS_OVERLAPPEDWINDOW, // window style
  111. CW_USEDEFAULT, // initial x position
  112. CW_USEDEFAULT, // initial y position
  113. CW_USEDEFAULT, // initial x size
  114. CW_USEDEFAULT, // initial y size
  115. NULL, // parent window handle
  116. NULL, // window menu handle
  117. hInstance, // program instance handle
  118. NULL) ; // creation parameters
  119. ShowWindow (hwnd, nCmdShow) ;
  120. UpdateWindow (hwnd) ;
  121. while (GetMessage (&msg, NULL, 0, 0))
  122. {
  123. TranslateMessage (&msg) ;
  124. DispatchMessage (&msg) ;
  125. }
  126. return msg.wParam ;
  127. }
  128. long FAR PASCAL CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam,
  129. LONG lParam)
  130. {
  131. static FARPROC dlgprc;
  132. static HWND msghwnd;
  133. HCURSOR hcurSave;
  134. int ErrCode;
  135. static HFILE hlp;
  136. NPSTR npmem;
  137. WORD Len;
  138. switch (message)
  139. {
  140. case WM_CREATE:
  141. strcpy(szInWordFileName,"arntall.nt");
  142. strcpy(szOutWordFileName,"array30.tab");
  143. strcpy(szInHighFileName,"arhw-nt.nt");
  144. strcpy(szOutHighFileName,"arrayhw.tab");
  145. strcpy(szInPhrFileName,"ar25000.nt");
  146. strcpy(szOutPhrFileName,"arphr.tbl");
  147. strcpy(szIdxFileName,"arptr.tbl");
  148. msghwnd = CreateWindow ("edit", NULL,
  149. WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
  150. WS_BORDER | ES_LEFT | ES_MULTILINE |
  151. ES_AUTOHSCROLL,
  152. //ES_AUTOVSCROLL, //ES_AUTOHSCROLL |
  153. 0, 0, 0,0,
  154. hwnd, (HANDLE)1,
  155. hInst, NULL) ;
  156. SendMessage(msghwnd,EM_SETREADONLY,TRUE,0L);
  157. if((hlp=_lopen((LPSTR)hlpfile, OF_READ))>0)
  158. {
  159. Len = (WORD) FileLen(hlp);
  160. npmem = (NPSTR)LocalAlloc(LMEM_FIXED,Len+1);
  161. _lread(hlp,(LPSTR)npmem,Len);
  162. _lclose(hlp);
  163. *(npmem+Len)=0;
  164. SendMessage(msghwnd,WM_SETTEXT,0,(LPARAM)(LPSTR)npmem);
  165. }
  166. PopFileInit ();
  167. return 0;
  168. case WM_SIZE:
  169. MoveWindow(msghwnd,0, 0, LOWORD(lParam),HIWORD(lParam),TRUE);
  170. return 0;
  171. case WM_COMMAND:
  172. switch(wParam)
  173. {
  174. case IDM_WORD: //���r
  175. if(!PopFileOpenDlg(hwnd,szInWordFileName,"�п��ܸ��ƨӷ�",szFilterI))
  176. break;
  177. if((ErrCode=IsUniCode (szInWordFileName))!=0)
  178. {
  179. error(hwnd,ErrCode,wParam);
  180. break;
  181. }
  182. if(!PopFileSaveDlg(hwnd,szOutWordFileName,"�Ы��w���X�ɦW",szFilterO))
  183. break;
  184. hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT));
  185. ErrCode=cvtword(szInWordFileName,szOutWordFileName,&line);
  186. SetCursor(hcurSave);
  187. if(!ErrCode)
  188. MessageBox(hwnd,"���r�����Ѹ��T�ഫ�����I",szAppName,0);
  189. else
  190. error(hwnd,ErrCode,wParam);
  191. break;
  192. case IDM_PHRASE: //���y
  193. if(!PopFileOpenDlg(hwnd,szInPhrFileName,"�п��ܸ��ƨӷ�",szFilterI))
  194. break;
  195. if((ErrCode=IsUniCode (szInPhrFileName))!=0)
  196. {
  197. error(hwnd,ErrCode,wParam);
  198. break;
  199. }
  200. if(!PopFileSaveDlg(hwnd,szOutPhrFileName,"�Ы��w���X���y�ɦW",szFilterH))
  201. break;
  202. if(!PopFileSaveDlg(hwnd,szIdxFileName,"�Ы��w���X�����ɦW",szFilterH))
  203. break;
  204. hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT));
  205. ErrCode=cvtphrase(szInPhrFileName,szOutPhrFileName,szIdxFileName,&line);
  206. SetCursor(hcurSave);
  207. if(!ErrCode)
  208. MessageBox(hwnd,"���y�����Ѹ��T�ഫ�����I",szAppName,0);
  209. else
  210. error(hwnd,ErrCode,wParam);
  211. break;
  212. case IDM_HIGH: //²�X
  213. if(!PopFileOpenDlg(hwnd,szInHighFileName,"�п��ܸ��ƨӷ�",szFilterI))
  214. break;
  215. if((ErrCode=IsUniCode (szInHighFileName))!=0)
  216. {
  217. error(hwnd,ErrCode,wParam);
  218. break;
  219. }
  220. if(!PopFileSaveDlg(hwnd,szOutHighFileName,"�Ы��w���X�ɦW",szFilterO))
  221. break;
  222. hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT));
  223. ErrCode=cvthigh(szInHighFileName,szOutHighFileName,&line);
  224. SetCursor(hcurSave);
  225. if(!ErrCode)
  226. MessageBox(hwnd,"²�X�����Ѹ��T�ഫ�����I",szAppName,0);
  227. else
  228. error(hwnd,ErrCode,wParam);
  229. break;
  230. }
  231. return 0;
  232. case WM_DESTROY:
  233. DestroyWindow(msghwnd);
  234. PostQuitMessage (0) ;
  235. return 0 ;
  236. }
  237. return DefWindowProc (hwnd, message, wParam, lParam) ;
  238. }