{
T=T+Text[N];
N++;
}
}
}
OpenWnd -> UpdateWindow();
File.Close();
}
}
void CMyFrameWin::OnSave()
{
CString string="Результати обчислень програми: ";
CFileDialog DlgSave(FALSE,"txt","",OFN_HIDEREADONLY,
"Text file (*.txt)|*.txt|All Files(*.*)|*.*|",this);
string+=s;
if(DlgSave.DoModal()==IDOK)
{
CStdioFile File(DlgSave.GetPathName(),
CFile::modeCreate | CFile::modeWrite);
File.WriteString(LPCSTR(string));
}
}
void CMyFrameWin::OnExit()
{
SendMessage(WM_CLOSE);
}
void CMyFrameWin::OnInput()
{
CMyDialog dialog(this);
dialog.DoModal();
}
void CMyFrameWin::OnRun()
{
float res;
float x=atof(T);
HINSTANCE hDll;
hDll=::LoadLibrary("MandroDLL");
typedef float(*FUN)(float);
FUN func;
func=(FUN)::GetProcAddress(hDll,"Calc");
res=(*func)(x);
sprintf(s,"%f",res);
FreeLibrary(hDll);
CTextWnd * TextWnd=new CTextWnd(this);
TextWnd->ShowWindow(SW_SHOWNORMAL);
TextWnd->UpdateWindow();
CClientDC myDC(TextWnd);
myDC.SetTextColor(RGB(13,66,6));
myDC.TextOut(125,125,s,strlen(s));
}
void CMyFrameWin::OnResult()
{
CGraphWnd * GraphWnd=new CGraphWnd(this);
GraphWnd->ShowWindow(SW_SHOWNORMAL);
GraphWnd->UpdateWindow();
CClientDC DCS(GraphWnd);
float z=atof(T);
CPen pen;
CPoint arr[6];
arr[0].x=100;
arr[0].y=220;
arr[1].x=180;
arr[1].y=100;
arr[2].x=260;
arr[2].y=100;
arr[3].x=180;
arr[3].y=220;
arr[4].x=260;
arr[4].y=340;
arr[5].x=180;
arr[5].y=340;
CBrush brush,brush2,brush3;
pen.CreatePen( PS_SOLID, 5, RGB( 0, 0, 0));
brush.CreateHatchBrush(HS_DIAGCROSS, RGB( 0, 0, 255));
brush2.CreateSolidBrush(RGB( 255, 0, 0));
brush3.CreateSolidBrush(RGB( 0, 255, 0));
float m=atof(s);
DCS.SelectObject(&brush);
DCS.Rectangle(200-m,500-m,700+m,700);
DCS.SelectObject(&pen);
DCS.SelectObject( &brush3);
if(z<4)
{
DCS.Polygon(arr,6);
};
if(z>4)
{
arr[0].x=260;
arr[3].x=340;
DCS.Polygon(arr,6);
};
for (int i=20;i>0;i--)
{
CPoint arr2[10];
arr2[0].x=420+i;
arr2[0].y=260+i;
arr2[1].x=540+i;
arr2[1].y=20+i;
arr2[2].x=620+i;
arr2[2].y=20+i;
arr2[3].x=540+i;
arr2[3].y=180+i;
arr2[4].x=700+i;
arr2[4].y=140+i;
arr2[5].x=760+i;
arr2[5].y=60+i;
arr2[6].x=860+i;
arr2[6].y=60+i;
arr2[7].x=640+i;
arr2[7].y=380+i;
arr2[8].x=560+i;
arr2[8].y=380+i;
arr2[9].x=660+i;
arr2[9].y=200+i;
DCS.SelectObject(&brush2);
DCS.Polygon(arr2,10);
}
CString str1="Результати обрахувань програми: ";
DCS.SetTextColor(RGB(155,100,55));
DCS.TextOut(350,550,str1);
DCS.SetTextColor(RGB(100,155,255));
DCS.TextOut(450,600,s);
pen.DeleteObject();
brush.DeleteObject();
brush2.DeleteObject();
brush3.DeleteObject();
}
void CMyFrameWin::OnAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
void CMyFrameWin::OnHelp()
{
MessageBox(NULL,"Only God can help U","Help",MB_OK|
MB_ICONINFORMATION);
}
void CMyFrameWin::OnRButtonDown(UINT nFlags, CPoint point)
{
CPoint t;
GetCursorPos(&t);
PopupMenu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,t.x, t.y, this);
}
class CMyApp:public CWinApp
{public:
virtual BOOL InitInstance();
};
BOOL CMyApp::InitInstance()
{
CMyFrameWin *pMainWnd=new CMyFrameWin;
m_pMainWnd=pMainWnd;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
};
CMyApp app;
ДОДАТОК Б
// MandroDLL.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
float Calc(float X)
{
float A(5);
float B(2);
float C(6);
float D(0);
float E(0);
float F(4);
float Y(0);
_asm
{
FINIT;
FLD F;//st(1)=4
FLD X;//st(0)=X
FCOM ST(1)
FSTSW ax
AND EAX ,00004500h
CMP EAX ,00000000h
je M_Bigger;
CMP EAX ,00000100h
je M_Lower;
CMP EAX ,00004000h
je M_Equal;
M_Equal:
Finit
Fld E;//ST(6)
Fld D;//ST(5)
Fld A;//ST(4)
Fld B;//ST(3)
Fld C;//ST(2)
Fld X;//ST(1)
Fld Y;//ST(0)
Fadd ST(0),ST(1);//y=x
Fmul ST(0),ST(4);//y=x*a
Fxch ST(5);//d=a*x
Fadd ST(0),ST(1);//y=x
Fmul ST(0),ST(3);//y=x*b
Fxch ST(6);//e=x*b
Fadd ST(0),ST(3);//y=b
Fmul ST(0),ST(4);//y=a*b
Fadd ST(0),ST(5);//y=a*x+a*b
Fsub ST(0),ST(6);//y=a*x+a*b-b*x
Fst Y;
jmp M_END
M_Lower:
Finit
Fld D;//ST(5)
Fld A;//ST(4)
Fld B;//ST(3)
Fld C;//ST(2)
Fld X;//ST(1)
Fld Y;//ST(0)
Fadd ST(0),ST(1);//y=x
Fmul ST(0),ST(4);//y=x*a
Fxch ST(5);//d=a*x
Fadd ST(0),ST(1);//y=x
Fmul ST(0),ST(3);//y=x*b
Fadd ST(0),ST(5);//y=a*x+b*x
Fsub ST(0),ST(2);//y=a*x+b*x-c
Fst Y;
jmp M_END
M_Bigger:
Finit
Fld D;//ST(5)
Fld A;//ST(4)
Fld B;//ST(3)
Fld C;//ST(2)
Fld X;//ST(1)
Fld Y;//ST(0)
Fadd ST(0),ST(4);//y=a
Fmul ST(0),ST(3);//y=a*b
Fxch ST(5);//d=a*b
Fadd ST(0),ST(1);//y=x
Fmul ST(0),ST(1);//y=x*x
Fmul ST(0),ST(4);//y=x*x*a
Fsub ST(0),ST(5);//y=a*x*x-a*b
Fst Y;
M_END:
}
return Y;
}