他们就给4000,我感觉付出了很多,至少6000吧
最近又加了些功能, 1 可选择定时声音报警,作出报警坐标,
2 5分钟自动保存
等最终弄好了给大家来分享
1 可选择定时声音报警,作出报警坐标,
AfxBeginThread((AFX_THREADPROC)sound,NULL,THREAD_PRIORITY_NORMAL);// 调用这个函数就能实现发声音
UINT CSerialPortTest2View::sound(LPVOID pParam)
{
HINSTANCE h=AfxGetInstanceHandle();
HRSRC hr=FindResource(h,"IDR_WAVE","WAVE");
HGLOBAL hg=LoadResource(h,hr);
LPSTR lp=(LPSTR)LockResource(hg);
sndPlaySound(lp,SND_MEMORY|SND_SYNC);
FreeResource(hg);
return 0;
}
2 .5分钟自动保存
SetTimer(3,1000*60*5,NULL); //5分钟自动保存
void CSerialPortTest2View::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
switch(nIDEvent)
{
case 1:
{
//;
}break;
case 2: {
/////保存报警点坐标数据
XSound[Sound]= Xsave[Num];
YSound[Sound]= Ysave[Num];
Sound++;
//作出报警点,计算出坐标点
CString strX1,strX2,strY;
int X=200+Xsave[Num]/XX;
strX1.Format("%02d",Xsave[Num]%3600/60);//分
strX2.Format("%02d",Xsave[Num]%3600%60);//秒
int Y=600-Ysave[Num]*YY;
strY.Format("%d",Ysave[Num]);
pDC->SetTextColor (RGB (0,0,255));
pDC->TextOut(X,Y,"("+strX1+":"+strX2+","+strY+")");//显示接收到的数据
////坐标做点
CPen pen(PS_SOLID, 5, RGB(0, 0, 0)); //黑
pDC->SelectObject(pen); //
pDC->MoveTo(X,Y);
pDC->LineTo(X,Y);//鼠标所在坐标做点
AfxBeginThread((AFX_THREADPROC)sound,NULL,THREAD_PRIORITY_NORMAL);// 发声音
}
break; //定点报时
case 3:
AutoSave5();
pDC->SetTextColor (RGB (255,20,25)); //暗绿
pDC->TextOut(200,630,"系统消息: 已成功自动保存当前相图数据文件—〉SaveDat.hlf");//
SetTimer(4,8000,NULL); //定时器4用来稳定延时显示 “成功自动保存文件SaveDat.hlf”
break; //5分钟自动保存
case 4:
pDC->TextOut(200,630," ");//
KillTimer(4);
break; //定时器4用来稳定延时显示 “成功自动保存文件SaveDat.hlf”
default: break;
}
ReleaseDC(pDC);
CView::OnTimer(nIDEvent);
}
void CSerialPortTest2View::AutoSave5()
{
CFile file;
file.Open("SaveDat.hlf",CFile::modeCreate|CFile::modeWrite);
/////以(x,y)形式保存入txt文档
CString strX,strY;
int i;
for ( i=0;i<Num_S;i++) /////////////////////!!!!!!!!!!!!!!
{
strX.Format("%04d",Xsave[i]);
strY.Format("%03d",Ysave[i]);
int nL=strX.GetLength()+strY.GetLength()+2;
file.Write(strX+","+strY+" ",nL);
}
file.Close();
}
熟人的公司,又是第一次做,整体稳定性不够好,6000差不多了
我只会打印BMP位图:
建立一个单文档视:头文件中添加OnPrint(CDC* pDC, CPrintInfo* pInfo);
OnDraw(pDC);重绘就OK了,可以打印和打印设置,不能打印预览~!
我曾经成功把每个象素在打印预览显示出来,但打印就是没有反映,不知为何
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSerialPortTest2View)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate();
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);////打印//
//}}AFX_VIRTUAL
void CSerialPortTest2View::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
CRect rct;
GetClientRect(rct);
pDC->SetMapMode(MM_ANISOTROPIC);
CDC* pViewDC = GetDC();
int numx=pViewDC->GetDeviceCaps(LOGPIXELSX);
int numy=pViewDC->GetDeviceCaps(LOGPIXELSY);
int w=pInfo->m_rectDraw.Width();
int h=pInfo->m_rectDraw.Height();
//转换坐标映射方式
CSize size = CSize(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
pDC->SetWindowExt(size);
//确定窗口大小
//得到实际设备每逻辑英寸的像素数量
int xLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSX);
int yLogPixPerInch = pDC->GetDeviceCaps(LOGPIXELSY);
//得到设备坐标和逻辑坐标的比例
long xExt;
long yExt;
xExt=(long)(size.cx*xLogPixPerInch/numx) ;
yExt=(long)(size.cy*yLogPixPerInch/numy) ;
pDC->SetViewportExt((int)xExt, (int)yExt);
OnDraw(pDC);
}