========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : test program frame
========================================================================
/////////////////////////////////////////////////////////////////////////////
//
//APPFACE:
//
//////////////////////////////////////////////////////////////////////////
1.copy the"appface.h"and "appface.dll" under the project.
2.copy the "GtClassic.urf" under the res.
3.add the "appface.h" to the header files,add the "GtClassic.urf" to frame files.
4.add "GtClassic.urf" to the resources ,named type"MYTYPE",named file"IDR_MY_URF".
5.add program"//line1,//line2,//line3" to the "test program frame.cpp"
///////////////////////////////////////////////////////////////////////////////////////
//
//colorlist ctrl:
//
/////////////////////////////////////////////////////////////////////////////////////////
1.copy the "ColorListCtrl.cpp" and "ColorListCtrl.h" under the project.
2.add the "ColorListCtrl.cpp" to the source file,add the "ColorListCtrl.h" to the header file.
3.instead of the "clistctrl" by "CColorListCtrl" in the "test program frameDlg.h" .
4.add "#include "ColorListCtrl.h"" and program "#define COLUMNS_m_ColListCtrl 7" in the "test program frameDlg.h" .
5.add ",m_ColListCtrl(COLUMNS_m_ColListCtrl)"under the ": CDialog(CTestprogramframeDlg::IDD, pParent)" in the "test program frameDlg.cpp".
6.add programs
"
CStringArray Head;
CByteArray Cols;
Head.Add("NO.");
Cols.Add(6); //6%
Head.Add("TEST ITEM");
Cols.Add(19); //25%
Head.Add("Unit");
Cols.Add(10); //35%
Head.Add("high limit");
Cols.Add(15); //50%
Head.Add("low limit");
Cols.Add(15); //65%
Head.Add("measure value");
Cols.Add(25); //90%
Head.Add("Result");
Cols.Add(10); //100%
m_ColListCtrl.InitCtrl(&Head, &Cols);
"
in the "OnInitDialog()"
//////////////////////////////////////////////////////////////////////////////////////////
//
//cfont:
//
/////////////////////////////////////////////////////////////////////////////////////////////
add program
"
CFont ft;
ft.CreateFont(18, 0, 0, 0, FW_BOLD,FALSE, FALSE, FALSE, 0,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN, "Times New Roman");
"
to the "OnInitDialog()"
when used just like up
"
GetDlgItem(IDC_BUTTON_CONNECTION_TEST)->SetFont(&ft,TRUE);
GetDlgItem(IDC_BUTTON_MAIN_TEST)->SetFont(&ft,TRUE);//set the button fonts
GetDlgItem(IDC_STATIC_USB_MSG)->SetFont(&ft,TRUE);//set the static fonts
m_ColListCtrl.SetFont(&ft,TRUE);//set the listctrl fonts
"
and you also could set the fonts in the MFC direct.
//////////////////////////////////////////////////////////////////////////////////////////////
//
//threads:
//
////////////////////////////////////////////////////////////////////////////////////////
1.add "UINT WorkForce2(LPVOID lpParameter);//线程函数声明" and"CWinThread *pTest;" in the "test program frameDlg.h".
2.add "pTest=AfxBeginThread( WorkForce2, this);//如果采用默认值" in the "OnButtonMainTest()".
3.add "
UINT WorkForce2(LPVOID lpParameter)//线程函数声明
{
CTestprogramframeDlg* cd= (CTestprogramframeDlg*)lpParameter;
cd->test();
Sleep(1);
return 0;
}
"
in the "test program frameDlg.cpp".
4.build a new function "void CTestprogramframeDlg::test()" ,and add the program in this function.
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//progress:
//
///////////////////////////////////////////////////////////////////////////////////////
add
"
m_prg.SetPos(10);
m_prg.SetPos(20);
m_prg.SetPos(30);
m_prg.SetPos(40);
m_prg.SetPos(50);
m_prg.SetPos(60);
m_prg.SetPos(70);
m_prg.SetPos(80);
m_prg.SetPos(90);
m_prg.SetPos(100);
"
in the function "test",if the progress need to divide into 10 parts.
//////////////////////////////////////////////////////////////////////////////////////////////////////
//
//LPT:
//
////////////////////////////////////////////////////////////////////////////////
1.copy the "winio.h","winio.dll","winio.lib","winio.sys" and "winio.vxd" under the project and the debug.
2.add the "winio.h" to the "header files",add the "winio.dll" to the "project->setting".
3. add program
"
if(!InitializeWinIo())
{
MessageBox("Initialize WinIO driver Failed!");
exit(1);
}
"
"#include "winio.h"" to the "test program frameDlg.cpp".
4.use method:
int LPT1=0X378;
int LPT2=0X278;//address
SetPortVal(LPT1,~0x00,1);//set the LPT1 is 00000000
DWORD buf;//set a buffer to record the LPT value
GetPortVal(LPT2,buf,1);//read the LPT2 value to the buf
//////////////////////////////////////////////////////////////////////////////////////
//
//GPIB:
//
//////////////////////////////////////////////////////////////////////////////////////////
1.copy "decl-32.h","gpib-32.obj" and "ni488.h" under the project
2.add the "ni488.h" to the header file,and add "gpib-32.obj" to "project->set".
3.add "#include "ni488.h"" to "test program frameDlg.cpp".
4.use method:
GPIBDevice1=ibdev(0, GPIBaddr1, 0, T300ms, 1, 0);//设置GPIB DEVICE
ibwrt(GPIBDevice1,"*IDN?\n",strlen("*IDN?\n"));
char temp[100]="";
ibrd(GPIBDevice1,temp,100);//读返回值,存入temp
float result=(float)atof(temp)*10e2;//if want to transform the str(in temp) to mA(save in result)
//////////////////////////////////////////////////////////////////////////////////////
//
//series:
//
/////////////////////////////////////////////////////////////////////////////////
BOOL CConnectTestDlg::OpenSeriesPort(int port, int rate)
{
DCB dcb;
COMMTIMEOUTS CommTimeOuts;
CString comName;
HANDLE hCom;
switch(port)
{
case 1:
hCom=hCom1;
break;
case 2:
hCom=hCom2;
break;
case 3:
hCom=hCom3;
break;
case 4:
hCom=hCom4;
break;
case 5:
hCom=hCom5;
break;
case 6:
hCom=hCom6;
break;
default:
hCom=hCom1;
break;
}
if (hCom != INVALID_HANDLE_VALUE)
CloseHandle(hCom);
comName.Format("COM%d", port);
hCom = CreateFile(comName, GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,//FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,
NULL);
if (hCom==INVALID_HANDLE_VALUE)
return false;
SetupComm(hCom,256,64);
GetCommState(hCom, &dcb);
dcb.BaudRate=rate;
dcb.ByteSize=8;
dcb.Parity=NOPARITY;
dcb.StopBits=ONESTOPBIT;
SetCommState(hCom, &dcb);
CommTimeOuts.ReadIntervalTimeout=25;
CommTimeOuts.ReadTotalTimeoutMultiplier = 20;
CommTimeOuts.ReadTotalTimeoutConstant=500;
CommTimeOuts.WriteTotalTimeoutMultiplier=0;
CommTimeOuts.WriteTotalTimeoutConstant=0;
SetCommTimeouts(hCom, &CommTimeOuts);
PurgeComm(hCom,PURGE_TXABORT|PURGE_RXABORT|
PURGE_TXCLEAR|PURGE_RXCLEAR);
switch(port)
{
case 1:
hCom1=hCom;
break;
case 2:
hCom2=hCom;
break;
case 3:
hCom3=hCom;
break;
case 4:
hCom4=hCom;
break;
case 5:
hCom=hCom5;
break;
case 6:
hCom=hCom6;
break;
default:
hCom1=hCom;
break;
}
return true;
}
/////////////////////////////read a char from series///////////
BOOL CConnectTestDlg::ReadSeriesChar(int port, unsigned char *data)
{
static unsigned long m_BytesRead;
switch(port)
{
case 1:
ReadFile(hCom1, data, 1, &m_BytesRead, NULL);
break;
case 2:
ReadFile(hCom2, data, 1, &m_BytesRead, NULL);
break;
case 3:
ReadFile(hCom3, data, 1, &m_BytesRead, NULL);
break;
case 4:
ReadFile(hCom4, data, 1, &m_BytesRead, NULL);
break;
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
test program frame_01.rar (40个子文件)
test program frame_01
test program frame.aps 110KB
IniFile.cpp 7KB
test program frame.dsp 5KB
StdAfx.cpp 218B
test program frame.clw 4KB
config.ini 1KB
resource.h 3KB
test program frame.opt 432KB
ColorListCtrl.cpp 18KB
AppFace.h 6KB
test program frame.h 2KB
IniFile.h 3KB
ni488.h 19KB
WinIo.lib 4KB
test program frame.ncb 241KB
test program frame.rc 14KB
msado15.tlh 88KB
test program frame.dsw 561B
Decl-32.h 357B
ConnectTestDlg.cpp 10KB
test program frame.plg 270B
WinIo.dll 48KB
test program frame.cpp 2KB
msado15.tli 75KB
ReadMe.txt 17KB
test program frameDlg.h 3KB
StdAfx.h 1KB
WinIo.h 1KB
test program frameDlg.cpp 24KB
WINIO.VXD 5KB
res
GtClassic.urf 59KB
test program frame.ico 1KB
Thumbs.db 6KB
test program frame.rc2 410B
bitmap2.bmp 8KB
ConnectTestDlg.h 2KB
AppFace.dll 235KB
WinIo.sys 5KB
gpib-32.obj 30KB
ColorListCtrl.h 8KB
共 40 条
- 1
heatonwan
- 粉丝: 0
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0