|
|
//
// ���C ���Ѹ��T ���X�D�{��
//
// ���Ż� 1998/03/15
//
#include <windows.h>
#include <commdlg.h>
#include <string.h>
#include <stdlib.h>
#include <direct.h>
#include "resource.h"
#include "function.h"
char szAppName[] = "���C���Ѹ��T���X�{��" ; char *szFilterI = "���r�� (*.TXT;*.NT)\0*.txt;*.nt\0All Files (*.*)\0*.*\0"; char *szFilterO = "������ (*.TAB)\0*.tab\0All Files (*.*)\0*.*\0"; char *szFilterH = "���w�� (*.TBL)\0*.tbl\0All Files (*.*)\0*.*\0";
HANDLE hInst; //HWND msghwnd;
char szInWordFileName[256]; char szOutWordFileName[256]; char szInHighFileName[256]; char szOutHighFileName[256]; char szInPhrFileName[256]; char szOutPhrFileName[256]; char szIdxFileName[256]; char hlpfile[256]; DWORD line;
long FAR PASCAL CALLBACK WndProc (HWND, UINT, UINT, LONG) ; int cvtword (char *,char *,DWORD *); int cvthigh (char *,char *,DWORD *); int cvtphrase (char *,char *,char *,DWORD *);
void error(HWND hwnd,int ErrCode,int item) { char Buffer[255]; char szMsg[255]; if(LoadString(hInst, ErrCode, (LPSTR)Buffer, sizeof(Buffer))) switch(ErrCode) { case IDS_ERROPENFILE: case IDS_ERRUNICODE: case IDS_ERRFORMATROOT: case IDS_ERRFORMATROOTS: case IDS_ERRFORMATPHRASE: case IDS_ERRFORMATCODE: switch(item) { case IDM_WORD: wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInWordFileName,line); break; case IDM_HIGH: wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInHighFileName,line); break; case IDM_PHRASE: wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szInPhrFileName,line); break; } break; case IDS_ERRCREATEFILE: switch(item) { case IDM_WORD: wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutWordFileName,line); break; case IDM_HIGH: wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutHighFileName,line); break; case IDM_PHRASE: wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szOutPhrFileName,line); break; } break; case IDS_ERRCREATEIDX: wsprintf((LPSTR)szMsg,(LPSTR)Buffer,(LPSTR)szIdxFileName); break; default: strcpy(szMsg,"�o�ͤ������~!"); break; } else strcpy(szMsg,"�o�ͤ������~!"); MessageBox(hwnd,(LPSTR)szMsg,szAppName,MB_OK | MB_ICONHAND |MB_APPLMODAL); }
int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow) { HWND hwnd ; MSG msg ; WNDCLASS wndclass ;
if (!hPrevInstance) { wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;//LoadIcon (hInstance, "ICON") ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuName = "MENU" ; wndclass.lpszClassName = szAppName ;
RegisterClass (&wndclass) ; } hInst=hInstance; _getcwd( hlpfile, sizeof(hlpfile)); if(hlpfile[strlen(hlpfile)-1]=='\\') hlpfile[strlen(hlpfile)-1]=0; strcat(hlpfile,"\\ARCVT.TXT"); hwnd = CreateWindow (szAppName, // window class name
szAppName, // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters
ShowWindow (hwnd, nCmdShow) ; UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; }
long FAR PASCAL CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam) { static FARPROC dlgprc; static HWND msghwnd; HCURSOR hcurSave; int ErrCode; static HFILE hlp; NPSTR npmem; WORD Len; switch (message) { case WM_CREATE: strcpy(szInWordFileName,"arntall.nt"); strcpy(szOutWordFileName,"array30.tab"); strcpy(szInHighFileName,"arhw-nt.nt"); strcpy(szOutHighFileName,"arrayhw.tab"); strcpy(szInPhrFileName,"ar25000.nt"); strcpy(szOutPhrFileName,"arphr.tbl"); strcpy(szIdxFileName,"arptr.tbl");
msghwnd = CreateWindow ("edit", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL, //ES_AUTOVSCROLL, //ES_AUTOHSCROLL |
0, 0, 0,0, hwnd, (HANDLE)1, hInst, NULL) ;
SendMessage(msghwnd,EM_SETREADONLY,TRUE,0L);
if((hlp=_lopen((LPSTR)hlpfile, OF_READ))>0) { Len = (WORD) FileLen(hlp); npmem = (NPSTR)LocalAlloc(LMEM_FIXED,Len+1); _lread(hlp,(LPSTR)npmem,Len); _lclose(hlp); *(npmem+Len)=0; SendMessage(msghwnd,WM_SETTEXT,0,(LPARAM)(LPSTR)npmem); }
PopFileInit (); return 0;
case WM_SIZE: MoveWindow(msghwnd,0, 0, LOWORD(lParam),HIWORD(lParam),TRUE); return 0; case WM_COMMAND: switch(wParam) { case IDM_WORD: //���r
if(!PopFileOpenDlg(hwnd,szInWordFileName,"�п��ܸ��ƨӷ�",szFilterI)) break; if((ErrCode=IsUniCode (szInWordFileName))!=0) { error(hwnd,ErrCode,wParam); break; } if(!PopFileSaveDlg(hwnd,szOutWordFileName,"�Ы��w���X�ɦW",szFilterO)) break; hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT)); ErrCode=cvtword(szInWordFileName,szOutWordFileName,&line); SetCursor(hcurSave); if(!ErrCode) MessageBox(hwnd,"���r�����Ѹ��T�ഫ�����I",szAppName,0); else error(hwnd,ErrCode,wParam); break; case IDM_PHRASE: //���y
if(!PopFileOpenDlg(hwnd,szInPhrFileName,"�п��ܸ��ƨӷ�",szFilterI)) break; if((ErrCode=IsUniCode (szInPhrFileName))!=0) { error(hwnd,ErrCode,wParam); break; } if(!PopFileSaveDlg(hwnd,szOutPhrFileName,"�Ы��w���X���y�ɦW",szFilterH)) break; if(!PopFileSaveDlg(hwnd,szIdxFileName,"�Ы��w���X�����ɦW",szFilterH)) break; hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT)); ErrCode=cvtphrase(szInPhrFileName,szOutPhrFileName,szIdxFileName,&line); SetCursor(hcurSave); if(!ErrCode) MessageBox(hwnd,"���y�����Ѹ��T�ഫ�����I",szAppName,0); else error(hwnd,ErrCode,wParam);
break; case IDM_HIGH: //²�X
if(!PopFileOpenDlg(hwnd,szInHighFileName,"�п��ܸ��ƨӷ�",szFilterI)) break; if((ErrCode=IsUniCode (szInHighFileName))!=0) { error(hwnd,ErrCode,wParam); break; } if(!PopFileSaveDlg(hwnd,szOutHighFileName,"�Ы��w���X�ɦW",szFilterO)) break; hcurSave = SetCursor(LoadCursor(NULL, IDC_WAIT)); ErrCode=cvthigh(szInHighFileName,szOutHighFileName,&line); SetCursor(hcurSave); if(!ErrCode) MessageBox(hwnd,"²�X�����Ѹ��T�ഫ�����I",szAppName,0); else error(hwnd,ErrCode,wParam); break;
} return 0; case WM_DESTROY: DestroyWindow(msghwnd); PostQuitMessage (0) ; return 0 ; }
return DefWindowProc (hwnd, message, wParam, lParam) ; }
|