OPOS en C++

Fermé
skymax406 Messages postés 215 Date d'inscription samedi 19 juillet 2008 Statut Membre Dernière intervention 22 avril 2015 - 12 déc. 2013 à 10:19
Bonjour,

Alors voila je voudrais coder une imprimante à ticket epson qui utilise la librairie OPOS.

A savoir que le c++ j'ai des notions du BTS mais moi je suis développeur WEB donc c'est plutot flou :D

Donc en fouillant dans OPOS j'ai pu trouver un logiciel (avec les sources) qui dialogue avec l'imprimante. ( Logiciel de démo plus qu'autre chose mais largement suffisant )

Donc mon but est de recréer un logiciel pour l'instant basique quand je clique sur un bouton il me connecte à l'imprimante et me dit si ça a réussis ou pas, rien de bien compliqué ( à priori )

Mon probléme est que je n'arrive pas a extraire le bout de code qu'il me faut j'ai jamais les bonnes dépendances.

Voici le dit-code :


#include "stdafx.h"
#include "Printer.h"
#include "PrinterDlg.h"
#include "XMLView.h"
#include "OPOSPtr.h"
#include "EPSNPtr.h"

typedef struct tITEMDATA {
long Price;
CString Name;
} ITEMDATA;

long cmbItem[] = { 0x0a, 0x0b, 0x14, 0x15, 0x3c, 0x46 };


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CPrinterDlg dialog

CPrinterDlg::CPrinterDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPrinterDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPrinterDlg)
m_Counter = -1;
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CPrinterDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPrinterDlg)
DDX_Control(pDX, IDC_EDIT_RETRIEVST, m_edtRetrieveSt);
DDX_CBIndex(pDX, IDC_CMB_COUNTER, m_Counter);
DDX_Control(pDX, IDC_POSPRINTER1, m_Ptr1);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPrinterDlg, CDialog)
//{{AFX_MSG_MAP(CPrinterDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_BTN_REC1, OnBtnRec1)
ON_BN_CLICKED(IDC_BTN_REC2, OnBtnRec2)
ON_BN_CLICKED(IDC_BTN_REC3, OnBtnRec3)
ON_BN_CLICKED(IDC_BTN_SLP1, OnBtnSlp1)
ON_BN_CLICKED(IDC_BTN_DIO1, OnBtnDio1)
ON_BN_CLICKED(IDC_BTN_DIO2, OnBtnDio2)
ON_BN_CLICKED(IDC_BTN_MC_RESET, OnBtnMcReset)
ON_BN_CLICKED(IDC_BTN_MC_GET, OnBtnMcGet)
ON_BN_CLICKED(IDC_BTN_MC_CUMULATIVE, OnBtnMcCumulative)
ON_BN_CLICKED(IDC_BTN_RETRIEVST, OnBtnRetrievSt)
ON_BN_CLICKED(IDC_BTN_REC4, OnBtnRec4)
ON_BN_CLICKED(IDC_BTN_REC5, OnBtnRec5)
ON_BN_CLICKED(IDC_BTN_REC6, OnBtnRec6)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPrinterDlg message handlers

BOOL CPrinterDlg::OnInitDialog()
{
CDialog::OnInitDialog();

SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
BOOL bError = FALSE;
long lRetryCount = 0;
long pData;
long pData2;
CString cString;
BSTR pString;

while( 1 ) {
//Open the device
//Use a Logical Device Name which has been set on the SetupPOS.
m_Ptr1.Open("TM-H6000IIP");
//Check whether the device is succeed to open, or not
if( m_Ptr1.GetResultCode() != OPOS_SUCCESS ) {
MessageBox("This device has not been registered, or cannot use.");
bError = TRUE;
break;
}

//Get the exclusive control right for the opened device.
//Then the device is disable from other application.
//(Notice:When using an old CO, use the Claim.)
m_Ptr1.ClaimDevice( 1000 );
if( m_Ptr1.GetResultCode() != OPOS_SUCCESS ) {
MessageBox("Fails to get the exclusive right for the device.");
bError = TRUE;
break;
}

//Enable the device.
//Je vous épargne la suite du code :D
}





Moi ce qui m'interesse pour l'instant c'est ça :



//Open the device
//Use a Logical Device Name which has been set on the SetupPOS.
m_Ptr1.Open("TM-H6000IIP");
//Check whether the device is succeed to open, or not
if( m_Ptr1.GetResultCode() != OPOS_SUCCESS ) {
MessageBox("This device has not been registered, or cannot use.");
bError = TRUE;
break;
}

//Get the exclusive control right for the opened device.
//Then the device is disable from other application.
//(Notice:When using an old CO, use the Claim.)
m_Ptr1.ClaimDevice( 1000 );
if( m_Ptr1.GetResultCode() != OPOS_SUCCESS ) {
MessageBox("Fails to get the exclusive right for the device.");
bError = TRUE;
break;
}




J'en suis là et bien sure ça fonctionne pas :D

#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
DDX_Control(pDX, IDC_EDIT_RETRIEVST, m_edtRetrieveSt);
DDX_CBIndex(pDX, IDC_CMB_COUNTER, m_Counter);
DDX_Control(pDX, IDC_POSPRINTER1, m_Ptr1);
}
};
}


Par ou je dois (re)commencer ?


Merci de votre aide INTERNAUTES :p

PS : Je travaille sur Visual Studio 2010.