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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| Global
DrawerHandle est un entier
DrawerNumber est un entier court
ngHdlDLL est un entier
ngHdlDLL = ChargeDLL( "MSPOS_ISB.DLL")
si ngHdlDLL = 0 alors
FinProgramme( "impossible de charger la DLL <MSPOS_USB.DLL>")
fin
Procedure DrawerOption_Click(Index est un entier)
DrawerNumber = Index //Get the new drawer ID number
SI DrawerHandle > 0 ALORS //Check to see if we already have a valid handle
//If so release the handle call "ReleaseDrawerHandle"
AppelDLL32( "MSPOS_USB.DLL", "Call ReleaseDrawerHandle",DrawerHandle)
DrawerHandle = 0 //Reset the handle to 0
FIN //Si
AppelDLL32( "MSPOS_USB.DLL", "Call Status_Button_Click") //Call the "Get Status" button routine
//Fin procedure
//Je ne traite pas cette Procedure qui ne fait appel qu''a des elelements de fenêtre
Procedure Form_Load()
Procedure Form_Terminate()
//If we have a valid handle then release it
SI DrawerHandle > 0 Alors
AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
FIN
//Fin Procedue
Procedure Form_Unload(Cancel est un entier)
//If we have a valid handle then release it
SI DrawerHandle > 0 ALORS
AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
FIN
//Fin procedure
Procedure mnuAbout_Click()
//Pareil interfacage avec la fenetre
Procedure mnuExit_Click()
//If we have a valid handle then release it
SI DrawerHandle > 0 Alors AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
//Fin procedure
Procedure Open_Button_Click()
local
Result est un entier
GetHandle( ) //Get a handle for the device if we do not have one
SI DrawerHandle = 0 ALORS RETOUR //If not valid then exit
Result = AppelDLL32( "MSPOS_USB", "OpenDrawer", DrawerHandle) //Else call "OpenDrawer" function
//Catch errors on the USB Device
SI Result = 0 ALORS //If it returned a 0 we had an error
USBError( )
Fin
//Fin procedure
Procedure USBError()
//This gets called when there was a reported error getting or sending data
//From the USB bus and the device. This sub will set the form porperties to
//not allow user interaction if the device communication failed.
//INTERFACAGE AVEC L''ECRAN
//Status.Caption = "USB Device NOT Connected!"
//Status.ForeColor = &HFF
//Shape1.BorderColor = &H0
//Shape1.FillColor = &H0
//Label2.Caption = "OFFLINE"
//Open_Button.Enabled = False
//Status_Button.Enabled = False
//mnuCashDrawer.Enabled = False
AppelDLL32( "MSPOS_USB", "ReleaseDrawerHandle", DrawerHandle)
DrawerHandle = 0
//Fin procedure
Procedure Status_Button_Click()
local
Result est un entier
GetHandle( ) //Get a handel for teh device if we do not have one
SI DrawerHandle = 0 ALORS RETOUR //If not valid then exit
Result = AppelDDL32( "MSPOS_USB", "GetDrawerStatus", DrawerHandle) //Else call "GetDrawerStatus" function
SI Result = 0 ALORS //If it returned a 0 we had an error
USBError( )
SINON
SI Result = 2 ALORS //If it returned a 2 we have an open cash drawer
//INTERFACAGE AVEC LA FENETRE
Label2.Caption = "OPEN"
Shape1.FillColor = &HFF00&
Shape1.BorderColor = &HFF00&
SINON //If it returned a 1 we have a closed drawer
//INTERFACAGE AVEC LA FENETRE
Label2.Caption = "CLOSED"
Shape1.FillColor = &HFF
Shape1.BorderColor = &HFF
FIN
FIN
//Fin Procedure
Procedure Timer1_Timer()
//Gestion d''un Timer
//Fin Procedure
Procedure GetHandle()
SI DrawerHandle > 0 ALORS RETOUR //If we have a handle already then exit
//Call the "GetDrawerHandle" function
DrawerHandle = AppelDLL32( "MSPOS_USB", "GetDrawerHandle", DrawerNumber)
SI DrawerHandle > 0 ALORS //If it retured a valid handle set the form
//INTERFACAGE AVEC LA FENETRE
Status.Caption = "USB Device Connected"
Status.ForeColor = &HFF00&
Open_Button.Enabled = True
Status_Button.Enabled = True
MainForm - 3
mnuCashDrawer.Enabled = True
Status_Button_Click( ))
SINON
USBError( ) //Else we had an error
FIN
//Fin procédure |
Partager