PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 25 → WX - Leitura de Codigo de Barras sem usar a biblioteca Zxling apenas usando a camera
WX - Leitura de Codigo de Barras sem usar a biblioteca Zxling apenas usando a camera
Débuté par BOLLER, 02 nov. 2017 16:11 - 1 réponse
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 02 novembre 2017 - 16:11
Prezados,

Para nao usar a biblioteca do Zxling que baixa no celular o aoo Barcode reader devido o comando BCapture, vamos precisar que voce crie uma nova janela e nela coloque o controle camera fotografica.





No CODE do controle da camera fotografica coloque esse código





Procedure DecodeBarCode(bc is BarCodes)
<Compile IF ConfigurationType=Android>
VibrationTrigger(300)
<ELSE>
VibrationTrigger()
<END>
WIN_04_CacaTesouro_Menu.CodigoBarras(StringToUTF8(bc..Content))

Close()


Nas propriedades do controle de camera fotografica defina essa opção abaixo:





No botao que chama essa Window coloque:

OpenMobileWindow(WIN_BarCode)



// Summary: <specify the procedure action>
// Syntax:
//CodigoBarras (<sEdit_codigobarras> is string)
//
// Parameters:
// sEdit_codigobarras (ANSI string): <specify the role of edit_codigobarras>
// Return Value:
// None
//
// For instance:
// Indicate an example.
//
Procedure CodigoBarras(sEdit_codigobarras is string)
HourGlass(True)
EDT_BarCode = sEdit_codigobarras

IF EDT_BarCode <> "" THEN

// Is it a valid bar code?
ok is boolean = HReadSeekFirst(t006_campanhasXprodutos,t006_campanhasXprodutos.t006_codigoProduto,EDT_BarCode,hKeepFilter)

IF HFound(t006_campanhasXprodutos) = True AND ok = True


//Registra no Servidor WEBSERVICE
//---------------------------------------------------------------------------
ok = WS_CapturaEAN(EDT_BarCode,gbCapturado)

IF ok = True THEN
Som_OK()

CriaLoopers(0)

sNomeProduto is string = t006_campanhasXprodutos.t006_nome_produto

OpenMobileWindow(WIN_05_CacaTesouro_ListaDetalheItem,EDT_BarCode,gbCapturado)

WIN_04_CacaTesouro_Menu..Plane = 3
ELSE
Som_Erro()
END


ELSE
Som_Erro()

Error("Produto não encontrado na base de dados")

END

END
HourGlass(False)


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 02 novembre 2017 - 16:14
Hi Adriano,

Some information:

The CBCapture FUNCTION uses the Zxing library (http://code.google.com/p/zxing).
IF this library is not present on the device, its download will be automatically proposed, the download of this library also installs an integrated visualization application.

IN order not to have this download IN addition to the WINDEV Mobile Android application, you should not Use CBCapture, but put a window with a camera field, with the BarCode decoding option IN the details of the field Description, AND a BarCode decoding option IN the field decoding code of this type:

=====

A função CBCapture usa a biblioteca Zxing (http://code.google.com/p/zxing).
Se esta biblioteca não estiver presente No dispositivo, seu download será proposto automaticamente, o download desta biblioteca também instala um aplicativo de visualização integrado.

Para não ter este download além DO aplicativo WINDEV Mobile Android, você não deve usar o CBCapture, mas coloque uma janela com um campo de câmera, com a opção de decodificação de código de barras nos detalhes da descrição DO campo e uma opção de decodificação de código de barras em o código de decodificação de campo deste tipo:

=====

Procedure CodeBarDecode(cbRead is a< /font> BarCode)
<Compile IF ConfigurationType=Android>
VibrationTrigger(500)
<ELSE>
VibrationTrigger()
<END>

// Exécution ici du code souhaité en fonction du type de code barre, exemple :
SWITCH cbRead..ContentType
CASE bcTypeEmail // Adresse email
EmailReset()
Email.NbRecipient = 1
Email.Recipient[1] = cbRead..Content
Email.Subject = "Post subject"
Email.Message = "Text of the message"
EmailRunApp()
IF ErrorOccurred THEN
Error("Unable to display the email sending window",ErrorInfo())
END

CASE bcTypePhone // Numéro de téléphone
tapiDialerCall(cbRead..Content)
IF ErrorOccurred THEN
Error("Cannot call the phone",ErrorInfo())
END

CASE bcTypeSMS // Numéro de SMS
SMSReset()
SMS.Subscript=1
SMS.Message="Message sms"
SMS.Number=cbRead..Content
SMSRunApp()
IF ErrorOccurred THEN
Error("Unable to send an SMS",ErrorInfo())
END

CASE bcTypeContact //Description d'un contact
IF YesNo(StringBuild([
Add to contact ?
%1 %2
%3 %4
],mContact.FirstName,mContact.Name,mContact.OfficePhone+" "+mContact.HomePhone+" "+mContact.MobilePhone,mContact.Email)) THEN
//mContact
UnContact is a Contact
UnContact.Nom = mContact.Name
UnContact.Prénom = mContact.FirstName

uneAdresse is an Address
IF mContact.OfficeAddress<>"" THEN
uneAdresse.Rue=mContact.OfficeAddress
<Compile IF ConfigurationType=Android>
uneAdresse.Type=addressWork
<ELSE>
uneAdresse.Etiquette="Bureau"
<END>
Add(UnContact.Adresse,uneAdresse)

END
IF mContact.HomeAddress<>"" THEN
uneAdresse.Rue=mContact.HomeAddress
<Compile IF ConfigurationType=Android>
uneAdresse.Type=addressHome
<ELSE>
uneAdresse.Etiquette="Domicile"
<END>
Add(UnContact.Adresse,uneAdresse)

END

unTel is a Phone
IF mContact.OfficePhone<>"" THEN
unTel.Numéro=mContact.OfficePhone

<Compile IF ConfigurationType=Android>
unTel.Type=phoneWork
<ELSE>
unTel.Etiquette="Bureau"
<END>
Add(UnContact.Téléphone,unTel)
END
IF mContact.HomePhone<>"" THEN
unTel.Numéro=mContact.HomePhone
<Compile IF ConfigurationType=Android>
unTel.Type=phoneHome
<ELSE>
unTel.Etiquette="Domicile"
<END>
Add(UnContact.Téléphone,unTel)
END
IF mContact.MobilePhone<>"" THEN
unTel.Numéro=mContact.MobilePhone

<Compile IF ConfigurationType=Android>
unTel.Type=phoneCellHome
<ELSE>
unTel.Etiquette="Mobile"
<END>
Add(UnContact.Téléphone,unTel)
END
// Liste les sources de contacts
tabSource is array of ContactSource = ContactListSource()
Source is a ContactSource
IF NOT ErrorOccurred THEN
FOR ALL ELEMENT Source OF tabSource
//comptes Google ??
IF Source..Type = " com.google " THEN
BREAK
END
END
END
IF Source..Type <>"" THEN
ContactAdd(UnContact,Source)
ELSE
ContactAdd(UnContact,Source)
END

END

CASE bcTypeLocation // Position géographique
gPos is a geoPosition=cbRead..Content
geoRunApp(gPos)
IF ErrorOccurred THEN
Error("Cannot launch the map",ErrorInfo())
END

CASE bcTypeMarket // Lien vers une application sur Google Play (pour une application Android uniquement)
ShellExecute(cbRead..Content)
IF ErrorOccurred THEN
Error("Cannot start the store",ErrorInfo< font style="font: 12px/normal Lucida Console; color: rgb(0, 0, 0); font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255);">())
END

CASE bcTypeWiFi // Chaîne de caractères de la forme : <SSID> + TAB + <Protocole de sécurité>+ TAB + <Clé>, Exemple : "MonRéseau<TAB&g t;WPA<TAB>mdp"
ToClipboard(ExtractString(cbRead..Content,3,TAB))
ToastDisplay("The network password <"+ExtractString(cbRead..Content,1,TAB)+"> has been copied to the clipboard")

OTHER CASE //CAS cbTypeTexte //(valeur par défaut lors de la création de la variable) : Texte brut
//CAS cbTypeURL // URL (signet). Pour insérer une adresse http dans le code-barres, utilisez le type cbTypeTexte.
sInfoCodeBarre is string ANSI=StringToUTF8(cbRead..Content)
bTraite is boolean

//<BLOC //**************** URL ?>
IF sInfoCodeBarre[[TO 4]]~=StringToUTF8("HTTP") THEN
bTraite=True
BrowserRunApp(sInfoCodeBarre) &nbsp ;
IF ErrorOccurred THEN
Error("Unable to launch Internet browser",ErrorInfo())
END
END
//<FIN>


//<BLOC //**************** Email ?>>
IF sInfoCodeBarre[[TO 7]]~=StringToUTF8("MATMSG:") THEN
bTraite=True
EmailReset()
Email.NbRecipient = 1
Email.Recipient[1] = ExtractString(ExtractString(sInfoCodeBarre,2,"TO:"),1,";")
Email.Subject = ExtractString(ExtractString(sInfoCodeBarre,2,"SUB:"),1,";")
Email.Message = ExtractString(ExtractString(sInfoCodeBarre,2,"BODY:"),1,";")
EmailRunApp()
IF ErrorOccurred THEN
Error("Unable to display the email sending window",ErrorInfo())
END
END
//<FIN>

//<BLOC //**********************************RDV ?>
IF sInfoCodeBarre[[TO 12]]~=StringToUTF8("BEGIN:VEVENT") THEN
sInfoCodeBarre=StringToUTF8("BEGIN:VCALENDAR"+CR)+sInfoCodeBarre< /font>+StringToUTF8(CR+"END:VCALEN DAR")
END
IF sInfoCodeBarre[[TO 15]]~=StringToUTF8("BEGIN:VCALENDAR") THEN
tabRDV is array of Appointment=iCalendarToAppointment(sInfoCodeBarre)

IF tabRDV..Occurrence>0 THEN
bTraite=True
nIndiceCalendrier is int
FOR EACH unRDV OF tabRDV
nIndiceCalendrier=0 &nb sp;
IF YesNo(StringBuild([
Add Appointment '%3' du %1 to %2 ?
],DateToString(unRDV..StartDate..Date,"JJJJ JJ MMMM AAAA"),TimeToString(unRDV..StartDate..Time,"HHhMM"),unRDV..Title)) THEN
//Il faut sélectionner le calendrier
tabCalendrier is array of Calendar = AppointmentListCalendar()
SWITCH tabCalendrier..Occurrence
CASE 0
Info("Adding impossible there is no calendar")
RETURN
CASE 1
//un seul calendrier
nIndiceCalendrier=1

OTHER CASE
//Choix
FOR n=1 _TO_ tabCalendrier..Occurrence
IF YesNo("Add the appointment to the calendar "+tabCalendrier[n]..Name+"-"+tabCalendrier[n]..AccountName+" ?") THEN
nIndiceCalendrier=n
BREAK
END
END

END
IF nIndiceCalendrier>0 THEN
AppointmentAdd(tabCalendrier[nIndiceCalendrier],unRDV)
IF NOT ErrorOccurred THEN
ToastDisplay("Appointment added")
ELSE
Error("Failed to add appointment",ErrorInfo())
END
END
END
END
END
END

//<FIN>


//si aucun cas trouvé on copie dans le rpesse ppier et On affiche
IF NOT bTraite THEN
ToClipboard(sInfoCodeBarre)
Info("Information retrieved (published in the clipboard) : ",sInfoCodeBarre)
END
END

Please DO not hesitate to Contact me for any additional information.

PCSOFT Véronique BRUNIER
Assistance Directe


--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/
Message modifié, 02 novembre 2017 - 16:16