ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Bar Code functions
  • Use conditions
  • Handling errors
  • Application in the background: Specific case from Android 10
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Decodes the information stored in a bar code by using the device camera (Android, iPhone, iPad).
Tip: Prefer the Camera field:
  • AndroidiPhone/iPadIOS WidgetMac Catalyst The Camera control can also be used to decode bar codes directly. For more details, see Camera field: decode barcodes.
  • Android It is recommended to replace this function with an application window containing a Camera control that allows decoding bar codes. For more details, see Camera field: decode barcodes.
Example
// Décodage d'un code-barres QR Code
cb is BarCode
cb = BCCapture()
IF ErrorOccurred = False _AND_ cb.ContentType = bcTypeEmail THEN
    	Info("Adresse email : " + cb.RawValue)
END
Syntax
<Result> = BCCapture([<Bar code type> [, <Enable flash>]])
<Result>: BarCode variable
BarCode variable initialized with the information read in the bar code.
iPhone/iPadIOS WidgetMac Catalyst Note: The Property TypeCodeBars property of the BarCode type variable is not updated: it still corresponds to "QRCode".
<Bar code type>: Optional Integer constant
Type of bar code that can be decoded:
BC_AZTECAztec bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_CODE128Code128 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_CODE39Code39 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_CODE93Code93 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_DATAMATRIXDATAMATRIX bar code.
iPhone/iPadIOS WidgetMac Catalyst Not available.
BC_EAN128EAN128 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_EAN13EAN13 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_EAN8EAN8 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_INTER2OF5Interleaved 2 of 5 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_PDF417PDF417 bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_QRCODEQR Code bar code.
BC_UPCAUPC-A bar code.
iPhone/iPadIOS WidgetMac Catalyst Not available.
BC_UPCEUPC-E bar code.
iPhone/iPadIOS WidgetMac Catalyst This type of bar code is available from iOS 7.
BC_ALLAll the types of bar codes supported by this function can be decoded.

If this parameter is not specified, all types of codes supported by this function can be decoded.
iPhone/iPadIOS WidgetMac Catalyst As of IOS 7, the following strikethrough codes can be decoded: QR Code, UPCE, Code39, Code39Mod43, EAN13, EAN8, Code93, Code128, PDF417 and Aztec.
<Enable flash>: Optional boolean
iPhone/iPadIOS WidgetMac Catalyst Flash management mode:
  • True to enable the flash,
  • False (default) to disable the flash.
Remarks

Use conditions

AndroidAndroid Widget In an Android application:
  • BCCapture opens a new window that displays the camera preview stream. Then, you must:
    • center the bar code to decode in the relevant area.
    • tap to read the bar code.
  • Bar code decoding:
    • Up to version 2025barcode decoding uses the Zxing library (http://code.google.com/p/zxing). If this library is not on the device, it will be automatically available for download.
      Please note: This library requires that you use the device's landscape mode.
    • From version 2025 Update 1strikethrough decoding uses ML Kit's barcode reading API.
iPhone/iPadIOS WidgetMac Catalyst For iPhone/iPad applications:
  • BCCapture opens a new window that displays the camera preview stream. Then, you just need to center the bar code to decode in the relevant area.
  • The window used to take photos is included in the WINDEV Mobile application. No additional library is required.

Handling errors

To determine whether the bar code failed to be read, use the ErrorOccurred variable.
The function will fail in the following cases:
  • if it is used in the simulator,
  • if it is used in the emulator,
  • if it is used in a device not equipped with a camera.
  • iPhone/iPadIOS WidgetMac Catalyst if the "Cancel" button was used. In this case, the TypeBarCode property of the BarCode variable will be different from BC_QRCODE.
Android If the barcode is decoded but its type is not recognized, the TypeBarCode property of the BarCode variable will correspond to the BC_UNKNOWN constant.
AndroidAndroid Widget

Application in the background: Specific case from Android 10

Starting with Android 10, it is no longer possible to open a window when the application is in the background.
BCCapture can open a window. If this function is used while the application is in the background, a fatal error will occur.
Tips:
  • It is possible to determine if the application is in the background using InBackgroundMode.
  • If an application needs to interact with the user while it is in the background, the solution is to display a notification (via the Notification type). The application will be brought back to the foreground when the notification is clicked, if the ActivateApplication property is set to True. You can also open a window from the procedure passed to the ActionClick property.
Related Examples:
WM Stocks Cross-platform examples (WINDEV Mobile): WM Stocks
[ + ] This application is used to perform stocktaking and to save the results in a database.
The example is used to create entries/exits in the stock, by directly scanning the bar code of products.
It is optimized to be run on tablets.
Android Inventory Android (WINDEV Mobile): Android Inventory
[ + ] This application is used to perform inventories and to save the results in a database.
Business / UI classification: Neutral code
Component: wd300android.aar
Minimum version required
  • Version 16
Comments
Click [Add] to post a comment

Last update: 03/28/2025

Send a report | Local help