Tuto WINDEV Mobile 25

124 Part 5: Android and iOS: Developing an application Taking photos We will now enter the WLanguage code to take a photo and to display it in the Image control of the product form. ▶ To take photos: 1. Select "Code" from the popup menu of the Button control (right click). 2. Write the following WLanguage code in the "Click" event: // Local variable sPhoto is string // Start the camera sPhoto = VideoStartApp(viPictureCapture) IF sPhoto <> "" THEN IMG_Photo = sPhoto END In this WLanguage code, VideoStartApp is used to launch the native camera application on the device in order to record video or to take a photo. 3. Save the modifications by clicking among the quick access buttons. 4. Close the code window (click X at the top right corner of code editor). Selecting a photo in the photo album We are going to add a Button control used to select a photo in the device album and to associate it with the product. ▶ To create the Button control for selecting the photo, we are going to "Copy - Paste" the photo capture Button control that was just created: 1. Select the "BTN_Camera" Button control that was just created. 2. Press Ctrl + C: the Button control is copied to the clipboard. 3. Press Ctrl + V: the mouse cursor changes and the control shadow appears under the cursor. 4. Click in the window beside the "BTN_Camera" control: the new Button control is automatically created. 5. Open the control description window (double-click the control): • Give a name to the control: "BTN_Photo_Album". • Select an image in the image catalog. Remark: Don’t forget to change the default image name. 6. Validate the description window. Remark: This button control corresponds to a "Copy - Paste" of the photo capture Button control, the style characteristics are automatically the same. There is no need to modify them! ▶ The WLanguage code associated with this Button control is used to open the device’s photo album and select an image to display it in the Image control of the product form. 1. Select "Code" from the popup menu of button (right mouse click).

RkJQdWJsaXNoZXIy NDQ0OA==