Page 1 of 1
c++
Posted: Fri Feb 09, 2007 11:06 am
by pymsoft
Sigo con las funciones en C++, ahora tengo que lograr hacer que funcione el lector de codigos de barras.
Code: Select all
#pragma BEGINDUMP
#include "c:\lavwin\teve\mobitron\inc\Barcode.h"
static CBarcode * bar = NULL;
// BARCODE //
HB_FUNC( BAR_POWERON ) // param: hWnd
{
if( bar == NULL )
{
bar = new CBarcode;
}
return bar->Bar_PowerOn( hb_parnl(1) )
}
HB_FUNC( BAR_POWEROFF ) // param: hWnd
{
if( bar == NULL )
{
bar = new CBarcode;
}
return bar->Bar_PowerOff( hb_parnl(1) )
}
#pragma ENDDUMP
Luego de esto, me da error al compilar:
teve.c
c:\lavwin\teve\mobitron\inc\barcode.h(12) : fatal error C1189: #error : include
'stdafx.h' before including this file for PCH
Entiendo que tengo que poner ese include que me falta.
Lo busco en los ejemplos de C++ que me proporcionaron y lo agrego.
luego de eso me da este error:
c:\lavwin\teve\mobitron\inc\stdafx.h(17) : fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory
Muy bien, lo busco por todo el disco y lo encuentro:
en esta carpeta: C:\Programmi\Windows CE Tools\wce400\STANDARDSDK\Mfc\Include
lo agrego y me da este error:
c:\lavwin\teve\mobitron\inc\stdafx.h(17) : fatal error C1083: Cannot open includ
e file: 'afxwin.h': Invalid argument
Alguna idea al respecto?
Gracias
Posted: Fri Feb 09, 2007 11:58 am
by Antonio Linares
Prueba a añadir este flag al compilar con clarm.exe
-IC:\Programmi\Windows CE Tools\wce400\STANDARDSDK\Mfc\Include
Posted: Fri Feb 09, 2007 1:20 pm
by pymsoft
bueno, el mensaje de error cambió:
teve.c
c:\programmi\windows ce tools\wce400\standardsdk\mfc\include\afxv_w32.h(137) : fatal error C1083: Cannot open include file: 'zmouse.h': No such file or directory
El tema es que ese archivo si que no lo tengo por ningun lado.
Posted: Fri Feb 09, 2007 4:07 pm
by pymsoft
creando un zmouse.h sin nada dentro (visto que sirve solo para la ruedita del mouse), me da este error:
c:\programmi\windows ce tools\wce400\standardsdk\mfc\include\afxv_cpu.h(23) : fatal error C1189: #error : afxv_cpu.h is only for MIPS R4000, DEC AXP, and IBM PowerPC builds
gracias
Posted: Fri Feb 09, 2007 6:17 pm
by Antonio Linares
Pedro,
Que contiene Barcode.h ?
La idea es modificarlo para que sólo tenga la declaración de la clase que vas a usar
Posted: Mon Feb 12, 2007 10:10 am
by pymsoft
Este es el contenido de barcode.h
Code: Select all
// Barcode.h : main header file for the BARCODE DLL
//
#if !defined(AFX_BARCODE_H__C9134DC0_653B_4807_B317_1D4B2A6971D8__INCLUDED_)
#define AFX_BARCODE_H__C9134DC0_653B_4807_B317_1D4B2A6971D8__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include "../inc/BarcodeType.h"
/////////////////////////////////////////////////////////////////////////////
// CBarcodeApp
// See Barcode.cpp for the implementation of this class
//
class __declspec(dllexport) CBarcode
{
public:
INT Bar_PortOpen(HWND hWnd);
INT Bar_PortClose(HWND hWnd);
INT DeSelectScanner(HANDLE hPwr, HWND hWnd);
INT ReadyForBarIO();
INT Bar_ScanData(int *sType, char *sData, int *iSize);
INT CloseScannerDeviceHandle();
INT Bar_ScannerEnd(HANDLE hPwr, HWND hWnd);
INT Bar_ScannerStart(HANDLE hPwr, HWND hWnd);
INT ClosePrtDeviceHandle();
INT SelectPrinter(HANDLE hPwr, HANDLE hWnd);
INT OpenPrtDevice();
HANDLE GetPrtDeviceHandle();
INT Bar_PowerOff(HWND hWnd);
INT SelectScanner(HANDLE hPwr, HWND hWnd);
INT OpenScannerDevice();
HANDLE GetScannerDeviceHandle();
int Bar_PowerOn(HWND hWnd);
CBarcode();
virtual ~CBarcode();
};
class CBarcodeApp : public CWinApp
{
public:
CBarcodeApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBarcodeApp)
public:
virtual int ExitInstance();
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
//{{AFX_MSG(CBarcodeApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BARCODE_H__C9134DC0_653B_4807_B317_1D4B2A6971D8__INCLUDED_)
y este es el contenido de barcodetype.h
Code: Select all
#define NOT_APPLICABLE 11
#define B_CODE_39 12
#define B_CODABAR 13
#define B_CODE_128 14
#define B_DISCRETE_2D5 15
#define B_IATA_2D5 16
#define B_INTERLEAVED_2D5 17
#define B_CODE_93 18
#define B_UPC_A 19
#define B_UPC_A_2SUP 20
#define B_UPC_A_5SUP 21
#define B_UPC_E0 22
#define B_UPC_E0_2SUP 23
#define B_UPC_E0_5SUP 24
#define B_EAN_8 25
#define B_EAN_8_2SUP 26
#define B_EAN_8_5SUP 27
#define B_EAN_13_5SUP 28
#define B_EAN_13 29
#define B_EAN_13_2SUP 30
#define B_MSI_PLESSEY 31
#define B_EAN_128 32
#define B_UPC_E1 33
#define B_UPC_E1_2SUP 34
#define B_UPC_E1_5SUP 35
#define B_TRIOPTIC_CODE_39 36
#define B_BOOKLAND_EAN 37
#define B_COUPON_CODE 38
#define B_PDF417 39
#define DATA_ERROR 40
#define NO_RESPONSE 41
#define NOT_SUPPORTED 42
Gracias
Posted: Mon Feb 12, 2007 11:42 am
by Antonio Linares
Pedro,
Prueba a quitar los includes que hay dentro de barcode.h y compila a ver que errores aparecen
Posted: Mon Feb 12, 2007 12:30 pm
by pymsoft
Antonio, los errores son los siguientes:
c:\lavwin\teve\mobitron\inc\barcode.h(47) : error C2504: 'CWinApp' : base class
undefined
c:\lavwin\teve\mobitron\inc\barcode.h(64) : error C2143: syntax error : missing
';' before '}'
teve.prg(4079) : error C2440: 'initializing' : cannot convert from 'const int' t
o 'class CBarcode'
No constructor could take the source type, or constructor overload resol
ution was ambiguous
teve.prg(4153) : error C2678: binary '==' : no operator defined which takes a le
ft-hand operand of type 'class CBarcode' (or there is no acceptable conversion)
teve.prg(4155) : error C2679: binary '=' : no operator defined which takes a rig
ht-hand operand of type 'class CBarcode *' (or there is no acceptable conversion
)
teve.prg(4158) : error C2143: syntax error : missing ';' before 'return'
teve.prg(4158) : error C2819: type 'CBarcode' does not have an overloaded member
'operator ->'
c:\lavwin\teve\mobitron\inc\barcode.h(23) : see declaration of 'CBarcode
'
teve.prg(4158) : error C2227: left of '->Bar_PowerOn' must point to class/struct
/union
teve.prg(4159) : error C2143: syntax error : missing ';' before '}'
teve.prg(4162) : error C2678: binary '==' : no operator defined which takes a le
ft-hand operand of type 'class CBarcode' (or there is no acceptable conversion)
teve.prg(4164) : error C2679: binary '=' : no operator defined which takes a rig
ht-hand operand of type 'class CBarcode *' (or there is no acceptable conversion
)
teve.prg(4167) : error C2143: syntax error : missing ';' before 'return'
teve.prg(4167) : error C2819: type 'CBarcode' does not have an overloaded member
'operator ->'
c:\lavwin\teve\mobitron\inc\barcode.h(23) : see declaration of 'CBarcode
'
teve.prg(4167) : error C2227: left of '->Bar_PowerOff' must point to class/struc
t/union
teve.prg(4168) : error C2143: syntax error : missing ';' before '}'
Saludos
P.D. Si quieres puedo enviarte los .h, las .lib con un programa que incluya solo las llamadas a funciones contenidas allí.
Posted: Mon Feb 12, 2007 1:28 pm
by pymsoft
Ahora dejé solo esta parte de codigo para que fuera todo mas claro:
Code: Select all
#include "FWCE.ch"
FUNCTION Main()
msginfo( Bar_PowerOn() )
RETURN NIL
#pragma BEGINDUMP
#include "hbapi.h"
#include "windows.h"
#include "c:\lavwin\teve\mobitron\inc\Barcode.h"
static CBarcode * bar = NULL;
// BARCODE //
HB_FUNC( BAR_POWERON ) // param: hWnd
{
if( bar == NULL )
{
bar = new CBarcode;
}
Sleep(30);
bar->Bar_PowerOn( (HWND) hb_parnl( 1 ) );
}
#pragma ENDDUMP
Ahora el error es el siguiente:
laser.c
c:\lavwin\teve\mobitron\inc\barcode.h(47) : error C2504: 'CWinApp' : base class undefined
c:\lavwin\teve\mobitron\inc\barcode.h(64) : error C2143: syntax error : missing ';' before '}'
Saludos
Posted: Mon Feb 12, 2007 2:00 pm
by Antonio Linares
Quita esta declaración del fichero de cabecera ya que no vas a usar esta clase:
Code: Select all
class CBarcodeApp : public CWinApp
{
public:
CBarcodeApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBarcodeApp)
public:
virtual int ExitInstance();
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
//{{AFX_MSG(CBarcodeApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Posted: Mon Feb 12, 2007 4:30 pm
by pymsoft
Antonio, resuelto este problema de la clase no usada.... tengo esta funcion para hacer el wrapper, pero no se como:
INT Bar_ScanData(int *sType, char *sData, int *iSize);
bar.Bar_ScanData(&sBarcodeType, &sBarcodeData[0], &iBarcodeSize);
hice asi:
Code: Select all
HB_FUNC( SCANDATA ) // param: sBarcCodeType, sBarcodeData, iBarcodeSize
{
// bar->Bar_ScanData(&sBarcodeType, &sBarcodeData[0], &iBarcodeSize);
bar->Bar_ScanData( hb_parni(1), hb_parc(2), hb_parni(3) );
}
pero claramente, no llega a compilar dandome este error:
teve.prg(4254) : error C2664: 'Bar_ScanData' : cannot convert parameter 1 from 'int' to 'int *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Gracias
Posted: Tue Feb 13, 2007 9:37 am
by Antonio Linares
Prueba así. Has de pasar los parámetros por referencia:
Code: Select all
HB_FUNC( SCANDATA ) // param: sBarcCodeType, sBarcodeData, iBarcodeSize
{
int sBarcCodeType = hb_parni(1);
char * sBarcodeData = hb_parc(2);
int iBarcodeSize = hb_parni(3);
bar->Bar_ScanData( &sBarcodeType, &sBarcodeData[0], &iBarcodeSize );
hb_storni( sBarcodeType, 1 );
hb_storc( sBarcodeData, 2 );
hb_storni( iBarcodeSize, 3 );
}
Estás seguro de que es &sBarcodeData[0] ? Lo lógico sería sBarcodeData
Posted: Tue Feb 13, 2007 10:09 am
by pymsoft
Antonio, muchas gracias, ya verè ahora de hacerlo funcionar.
este es el ejemplo del manual:
Code: Select all
Example using Scan Key
CBarcode bar;
BOOL CBarAppDlg::PreTranslateMessage(MSG* pMsg)
{
char sBarcodeData[128];
int iBarcodeSize, sBarcodeType;
int iRetValue;
TCHAR cKeyCode;
HANDLE hScannerPwr;
UINT iMessage;
iMessage = pMsg->message;
cKeyCode = pMsg->wParam;
if (iMessage == WM_KEYUP) {
switch (cKeyCode)
{
case VK_F3:
case VK_F4:
hScannerPwr = bar.GetScannerDeviceHandle();
bar.Bar_ScannerStart(hScannerPwr, m_hWnd);
iRetValue = bar.Bar_ScanData(&sBarcodeType,
&sBarcodeData[0], &iBarcodeSize);
bar.Bar_ScannerEnd(hScannerPwr, m_hWnd);
bar.CloseScannerDeviceHandle();
break;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Saludos
Posted: Tue Feb 13, 2007 12:48 pm
by pymsoft
Antonio, muchas gracias por tu ayuda.
Ya puedo leer codigos de barra desde mi programa en FWH.