Richard Coleman
Objet : Re: Using OPOS with PowerBuilder
Répondre à l'auteur | Transférer | Imprimer | Afficher le fil | Afficher l'original | Signaler ce message | Rechercher les messages de cet auteur
I created a non-visual object to handle all of this. The instance variables
are:
Private:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| OleObject oPOSPrinter
boolean ib_Created = FALSE
string is_DataToPrint
long il_LineSize
integer ii_LineCount
// Some printer specific constants
CONSTANT LONG PTR_MM = 4
CONSTANT LONG OPOS_SUCCESS = 0
CONSTANT LONG PTR_S_SLIP = 4
CONSTANT LONG OPOS_E_TIMEOUT = 112
CONSTANT LONG OPOS_E_ILLEGAL = 106
CONSTANT LONG OPOS_EPTR_COVER_OPEN = 201
CONSTANT LONG OPOS_EPTR_SLP_EMPTY = 204
CONSTANT LONG OPOS_E_EXTENDED = 114
CONSTANT string is_CRLF = '~r~n'
CONSTANT string is_Esc = char('~h1B') |
The code to initialize it is in a function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| // This function opens the connection to the POS Printer, claims the device
and
// sets it up for appropriate printing.
long ll_ReturnValue
string ls_Params[]
// Create the Active X Object
oPOSPrinter = CREATE OleObject
ll_ReturnValue = oPOSPrinter.ConnectToNewObject ( "OPOS.POSPrinter" )
IF ll_ReturnValue <> opos_success THEN
// gnv_app.inv_error.of_Message ( 'ACC-00096' )
RETURN -1
END IF
// Open the unit
ll_ReturnValue = oPOSPrinter.Open('Unit1')
IF ll_ReturnValue <> opos_success THEN
gnv_app.inv_error.of_Message ( 'ACC-00097' )
RETURN -1
END IF
// And get exclusive access to it
ll_ReturnValue = oPOSPrinter.ReleaseDevice()
ll_ReturnValue = oPOSPrinter.ClaimDevice(1000)
IF ll_ReturnValue <> opos_success THEN
IF ll_ReturnValue = OPOS_E_ILLEGAL THEN
ls_Params[1] = 'being unable to locate the slip printer'
ELSE
ls_Params[1] = 'unknown error #' + string ( ll_ReturnValue )
END IF
gnv_app.inv_error.of_Message ( 'ACC-00098', ls_Params )
RETURN -1
END IF
// Set some properties
oPOSPrinter.DeviceEnabled = TRUE
oPOSPrinter.MapMode = PTR_MM
oPOSPrinter.SlpLetterQuality = True
ib_Created = TRUE
RETURN 1 |
There are a few other functions in use (12 in fact). What version of PB are
you using? My code is in PB 9.0.2. I could copy all of the code (Edit
Source) and send it. Let me know. Might be able to move it to a PBL and
send that, but we are using CornerStone on top of PFC and it might cause you
some grief. It's inherited from n_base, so it might not.
Richard
<David> wrote in message news:433c0afe.2544.1681692777@sybase.com...
> > Hi, have anyone use OPOS with Powerbuilder before? what do
> > i need to do to access OPOS function to send commands to a
> > printer?
> I might need to access OPOS activeX control, I have try to
> use OLEControl but it does not allow me to get access to the
> OPOS functions.
Partager