// PosdllDemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "PosdllDemo.h"
#include "PosdllDemoDlg.h"
#include "LoadDll.h"
#include "PrintSamples.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
HANDLE g_hComm = INVALID_HANDLE_VALUE;//端口句柄
bool IsPrinter = false;//判断是否是用驱动程序打印
int m_iMode = 0;//页模式或标准模式
bool bSaveToTxt = false;//是否选择数据保存到文件Test.txt,不向端口下发
extern HMODULE g_hPosdll;//动态库句柄
extern POS_Open VC_POS_Open;//打开端口
extern POS_Close VC_POS_Close;//关闭端口
extern POS_RTQueryStatus VC_POS_RTQueryStatus;//实时状态查询
extern POS_NETQueryStatus VC_POS_NETQueryStatus;//网络接口的状态查询
extern POS_StartDoc VC_POS_StartDoc;//启动一个文档
extern POS_EndDoc VC_POS_EndDoc;//结束一个文档
extern POS_BeginSaveFile VC_POS_BeginSaveFile;//启动保存数据到文件
extern POS_EndSaveFile VC_POS_EndSaveFile;//结束保存数据到文件
extern POS_GetVersionInfo VC_POS_GetVersionInfo;//获取当前动态库版本
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPosdllDemoDlg dialog
CPosdllDemoDlg::CPosdllDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPosdllDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPosdllDemoDlg)
m_PortType = 0;
m_ModeSelect = 0;
m_strMsg = _T("");
m_strDrvName = _T("");
m_iTphWidth = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPosdllDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPosdllDemoDlg)
DDX_Control(pDX, IDC_PAGE_WIDTH, m_ctrlPageWidth);
DDX_Control(pDX, IDC_DRV_NAME, m_ctrlDrvName);
DDX_Control(pDX, IDC_IPADDRESS, m_ctrlIPAddr);
DDX_Control(pDX, IDC_CLOSE_PORT, m_ctrlClosePort);
DDX_Control(pDX, IDC_PRINT, m_ctrlPrint);
DDX_Control(pDX, IDC_QUERY_STATUS, m_ctrlQueryStatus);
DDX_Control(pDX, IDC_LPT_NAME, m_ctrlLPTName);
DDX_Control(pDX, IDC_PARITY, m_ctrlParity);
DDX_Control(pDX, IDC_FLOW_CONTROL, m_ctrlFlowControl);
DDX_Control(pDX, IDC_STOPBITS, m_ctrlStopBits);
DDX_Control(pDX, IDC_BAUDRATE, m_ctrlBaudrate);
DDX_Control(pDX, IDC_DATABITS, m_ctrlDataBits);
DDX_Control(pDX, IDC_COM_NAME, m_ctrlComName);
DDX_Radio(pDX, IDC_PORT_COM, m_PortType);
DDX_Radio(pDX, IDC_MODE_STANDARD, m_ModeSelect);
DDX_Text(pDX, IDC_EDIT_STATUS, m_strMsg);
DDX_Text(pDX, IDC_DRV_NAME, m_strDrvName);
DDX_CBIndex(pDX, IDC_PAGE_WIDTH, m_iTphWidth);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPosdllDemoDlg, CDialog)
//{{AFX_MSG_MAP(CPosdllDemoDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_OPEN_PORT, OnOpenPort)
ON_BN_CLICKED(IDC_PORT_COM, OnPortCom)
ON_BN_CLICKED(IDC_PORT_LPT, OnPortLpt)
ON_BN_CLICKED(IDC_PORT_USB, OnPortUsb)
ON_BN_CLICKED(IDC_PORT_NET, OnPortNet)
ON_BN_CLICKED(IDC_PORT_DRV, OnPortDrv)
ON_BN_CLICKED(IDC_QUERY_STATUS, OnQueryStatus)
ON_BN_CLICKED(IDC_PRINT, OnPrint)
ON_BN_CLICKED(IDC_CLOSE_PORT, OnClosePort)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_MODE_STANDARD, OnModeStandard)
ON_BN_CLICKED(IDC_MODE_PAGE, OnModePage)
ON_BN_CLICKED(IDC_SAVE_TO_TXT, OnSaveToTxt)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPosdllDemoDlg message handlers
BOOL CPosdllDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
if ( false == LoadPosdll() )
{
// 如果动态库加载失败, 则退出
AfxMessageBox("加载动态库失败!");
CDialog::OnCancel();
return false;
}
/*初始化界面显示*/
m_ctrlIPAddr.SetAddress(192,168,10,251);
m_ctrlIPAddr.EnableWindow(false);
m_ctrlComName.SetCurSel(0);
m_ctrlDataBits.SetCurSel(1);
m_ctrlBaudrate.SetCurSel(2);
m_ctrlStopBits.SetCurSel(0);
m_ctrlParity.SetCurSel(2);
m_ctrlFlowControl.SetCurSel(1);
m_ctrlLPTName.SetCurSel(0);
m_ctrlPageWidth.SetCurSel(1);
SetDlgItemText(IDC_DRV_NAME,"BTP-2002CP(S)");
int iMajor,iMinor;
CString str,tmp;
VC_POS_GetVersionInfo(&iMajor,&iMinor);
str = "一切正常,版本号V";
tmp.Format("%d.%d",iMajor,iMinor);
str += tmp;
SetDlgItemText(IDC_EDIT_STATUS,str);
return TRUE; // return TRUE unless you set the focus to a control
}
void CPosdllDemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
CDialog::OnSysCommand(nID, lParam);
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPosdllDemoDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPosdllDemoDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPosdllDemoDlg::OnPortCom() //端口选择为串口
{
// TODO: Add your control notification handler code here
m_ctrlComName.EnableWindow(true);
m_ctrlDataBits.EnableWindow(true);
m_ctrlBaudrate.EnableWindow(true);
m_ctrlStopBits.EnableWindow(true);
m_ctrlParity.EnableWindow(true);
m_ctrlFlowControl.EnableWindow(true);
m_ctrlLPTName.EnableWindow(false);
m_ctrlIPAddr.EnableWindow(false);
m_ctrlDrvName.EnableWindow(false);
SetDlgItemText(IDC_EDIT_STATUS,"端口选择为串口");
VC_POS_Close();
m_ctrlQueryStatus.EnableWindow(false);
m_ctrlPrint.EnableWindow(false);
m_ctrlClosePort.EnableWindow(false);
GetDlgItem(IDC_OPEN_PORT)->EnableWindow(true);
}
void CPosdllDemoDlg::OnPortLpt() //端口选择为并口
{
// TODO: Add your control notification handler code here
m_ctrlLPTName.EnableWindow(true);
m_ctrlComName.EnableWindow(false);
m_ctrlDataBits.EnableWindow(false);
m_ctrlBaudrate.EnableWindow(false);
m_ctrlStopBits.EnableWindow(false);
m_ctrlParity.EnableWindow(false);
m_ctrlFlowControl.EnableWindow(false);
m_ctrlIPAddr.EnableWindow(false);
m_ctrlDrvName.EnableWindow(false);
SetDlgItemText(IDC_EDIT_STATUS,"端口选择为并口");
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
2009080731149501.rar (63个子文件)
2009080731149501
POSDLL V1.40
POSDLL_API.chm 65KB
POSdllDemo_Delphi.exe 451KB
Kitty.bmp 798B
POSDLL演示例程
POSDLLDemo_VC
Resource.h 2KB
PosdllDemo.rc.bak 10KB
POSDLL_API.chm 65KB
PosdllDemo.aps 38KB
res
PosdllDemo.rc2 402B
PosdllDemo.ico 1KB
Thumbs.db 3KB
Kitty.bmp 798B
PosdllDemo.dsw 545B
PosdllDemo.plg 256B
PosdllDemo.exe 208KB
PosdllDemoDlg.cpp 18KB
PrintSamples.cpp 15KB
PosdllDemo.cpp 2KB
LoadDll.h 7KB
PosdllDemo.opt 190KB
PosdllDemo.ncb 161KB
LoadDll.cpp 8KB
PosdllDemoDlg.h 2KB
StdAfx.cpp 212B
PosdllDemo.dsp 4KB
PosdllDemo.rc 9KB
PosdllDemo.clw 2KB
StdAfx.h 1KB
PosdllDemo.h 1KB
Look.bmp 798B
PrintSamples.h 446B
POSDLL.dll 80KB
POSDLLDemo_VB
MainForm.frm 43KB
MainForm.frx 341B
Kitty.bmp 798B
PosdllDemo.exe 60KB
PosdllFuncs.bas 20KB
PosdllDemo.vbp 1KB
MSSCCPRJ.SCC 343B
PosdllDemo.vbw 84B
Look.bmp 798B
POSDLL.dll 80KB
POSDLLDemo_Delphi
POSdllDemoProj.identcache 216B
PosDllDemo.pas 30KB
POSdllDemoProj.res 5KB
PosdllFuncs.pas 8KB
Kitty.bmp 798B
PosdllFuncs.dcu 7KB
POSdllDemoProj.cfg 488B
POSdllDemoProj.dpr 213B
PortIO.pas 33KB
POSdllDemoProj.exe 451KB
POSdllDemoProj.bdsproj.local 690B
PosDllDemo.dfm 9KB
POSdllDemoProj.dproj.local 690B
POSdllDemoProj.bdsproj 9KB
Look.bmp 798B
PosDllDemo.dcu 25KB
POSdllDemoProj.dproj 5KB
POSDLL.dll 80KB
PosdllDemo_VC.exe 208KB
PosdllDemo_VB.exe 60KB
Look.bmp 798B
POSDLL.dll 80KB
共 63 条
- 1
xiezs
- 粉丝: 1
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页