資源簡介
簡單函數繪圖語言解釋器,用VC6實現,能根據曲線函數畫出曲線,并能進行平移,旋轉,放縮,變換

代碼片段和文件信息
#include?“semantics.h“
#include?
#define?MAX_CHARS?200
extern?void?Parser(char?*SrcFilePtr);
HDC?hDC;
char?SrcFilePath[MAX_CHARS];
static?char?Name[]?=?“Compiler“;
//-----------------初始化窗口函數聲明
static?bool?PrepareWindow(HINSTANCE?HINSTANCE?int);
//-----------------檢查源程序文件是否合法函數聲明
static?bool?CheckSrcFile(LPSTR);
//-----------------窗口消息處理函數聲明
static?LRESULT?CALLBACK?WndProc(HWND?UINT?WPARAM?LPARAM);
//-----------------Window?程序主函數
int?APIENTRY?WinMain(HINSTANCE?hInstance
?HINSTANCE?hPrevInstance
?LPSTR?lpCmdLine
?int?nCmdShow)
{
//保存源文件路徑
strcpy(SrcFilePath?lpCmdLine);
//初始化窗口
if(PrepareWindow(hInstance?hPrevInstance?nCmdShow)!=true)?{
MessageBox(NULL?“窗口初始化失敗?!“?“錯誤“?MB_OK);
return?1;
}
//檢查要分析的源程序文件
if(!CheckSrcFile(lpCmdLine)) return?1;
//----------------------------------------
//???調用繪圖語言解釋器
Parser(SrcFilePath);
//----------------------------------------
//進入窗口消息循環
MSG?Msg;
while(GetMessage(&Msg?NULL0?0))?{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return?Msg.wParam;
}
//--------------初始化窗口函數實現
bool?PrepareWindow(HINSTANCE?hInst
???HINSTANCE?hPrevInstance
???int?nCmdShow)?{
HWND?hWnd;
WNDCLASS?W;
memset(&W?0?sizeof(WNDCLASS));
W.style?=?CS_HREDRAW?|?CS_VREDRAW;
W.lpfnWndProc?=?WndProc;
W.hInstance?=?hInst;
W.hCursor?=?LoadCursor(NULL?IDC_ARROW);
W.hbrBackground?=?(HBRUSH)(COLOR_WINDOW?+?1);
W.lpszClassName?=?Name;
RegisterClass(&W);
hWnd?=?CreateWindow(Name?Name
WS_OVERLAPPEDWINDOW
225?225?740?490?NULL?NULLhInstNULL);
if(hWnd?==?NULL)?
return?false;
ShowWindow(hWnd?nCmdShow);
UpdateWindow(hWnd);
SetCursor(LoadCursor(hInst?IDC_ARROW));
hDC?=?GetDC(hWnd);
return?true;
}
//--------------------檢查源程序文件是否合法函數實現
bool?CheckSrcFile(LPSTR?lpszCmdParam)?{
FILE?*file?=?NULL;
if(strlen(lpszCmdParam)?==?0)?{
MessageBox(NULL“未指定源程序文件!“?“Error“?MB_OK);
return?false;
}
if((file=fopen(lpszCmdParam?“r“))==NULL)?{
MessageBox(NULL?“打開源程序文件出錯!“?“錯誤“?MB_OK);
MessageBox(NULL?lpszCmdParam?“文件名“?MB_OK);
return?false;
}
else?fclose(file);
return?true;
}
//-------------------窗口消息處理函數實現
LRESULT?CALLBACK?WndProc(HWND?hWnd?UINT?Message?WPARAM?wParam?LPARAM?lParam)?{
switch(Message)?{
case?WM_DESTROY?:
ReleaseDC(hWnd?hDC);
PostQuitMessage(0);
return?0;
case?WM_PAINT?:
PAINTSTRUCT?pt;
BeginPaint(hWnd?&pt);
Parser(SrcFilePath);
EndPaint(hWnd?&pt);
default:
return?DefWindowProc(hWndMessagewParam?lParam);
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4703??2009-04-24?23:47??FunctionPlot\FunctionPlot.dsp
?????文件????????549??2009-04-24?17:49??FunctionPlot\FunctionPlot.dsw
?????文件??????58368??2009-07-03?01:15??FunctionPlot\FunctionPlot.ncb
?????文件??????49664??2009-07-03?01:15??FunctionPlot\FunctionPlot.opt
?????文件????????258??2009-07-03?01:14??FunctionPlot\FunctionPlot.plg
?????文件???????2784??2009-04-25?00:39??FunctionPlot\main.cpp
?????文件???????9058??2009-04-25?00:02??FunctionPlot\parser.cpp
?????文件????????418??2009-04-24?15:38??FunctionPlot\parser.h
?????文件???????3430??2009-04-23?21:17??FunctionPlot\scanner.cpp
?????文件???????1432??2009-04-24?18:02??FunctionPlot\scanner.h
?????文件???????3330??2009-04-24?20:38??FunctionPlot\semantic.cpp
?????文件????????529??2009-04-24?19:41??FunctionPlot\semantics.h
?????文件????????208??2009-05-09?15:26??FunctionPlot\test.txt
?????目錄??????????0??2009-07-03?01:15??FunctionPlot
-----------?---------??----------?-----??----
???????????????134731????????????????????14
評論
共有 條評論