WinDev Mobile Tutorial
WinDev Mobile Tutorial
Don't forget to visit our site (www.windev.com) on a regular basis to find out whether upgraded
versions are available.
This documentation is not contractually binding. PC SOFT reserves the right to modify or delete
any topic dealt with in this document.
All product names or other trademarks mentioned in this publication are registered trademarks of their respective owners.
PC SOFT 2017: This publication may not be reproduced in part or in whole in any form without the express permission of PC SOFT.
Summary
Introduction
Preliminary points.....................................................................................................................................................9
Overview of the tutorial.............................................................................................................................................9
Legend of symbols used in this guide....................................................................................................................10
How to access the online help?..............................................................................................................................11
If you are familiar with WINDEV Mobile 21...........................................................................................................13
What is WINDEV Mobile used for?.........................................................................................................................13
Summary 3
Touchscreen management.....................................................................................................................................43
Practical example..................................................................................................................................... 43
The different types of controls................................................................................................................................45
4 Summary
PART 4 - Programming concepts
Summary 5
Managing the creation and the modification of a product............................................................................... 112
Modifying the product form...................................................................................................................112
Creating a new product..........................................................................................................................116
Using the camera and displaying an image....................................................................................................... 119
Overview.................................................................................................................................................119
Creating the button for taking photos...................................................................................................119
Taking photos.........................................................................................................................................120
Selecting a photo in the photo album...................................................................................................120
Managing the bar code of the product................................................................................................................ 121
Overview.................................................................................................................................................121
Implementation......................................................................................................................................121
Managing anchors in the Product form.............................................................................................................. 122
Using the Map control.......................................................................................................................................... 124
Creating the window...............................................................................................................................124
Creating the Map control.......................................................................................................................124
Displaying stores on the map................................................................................................................125
Using a Multiline Zone control............................................................................................................................. 126
Creating the window...............................................................................................................................126
Creating the Multiline Zone control.......................................................................................................126
Modifying the Multiline Zone control.....................................................................................................127
Programming the menu.........................................................................................................................130
Application test..................................................................................................................................................... 130
6 Summary
Lesson 5.5. Window with scroll
Overview................................................................................................................................................................ 158
Creating the Form window with swipe................................................................................................................ 158
Creating the Form window.....................................................................................................................158
Creating the internal window.................................................................................................................159
Managing the swipe in the form window...............................................................................................159
Window test.......................................................................................................................................................... 162
Conclusion............................................................................................................................................................. 163
Summary 7
Lesson 6.4. Distributing the application
Overview................................................................................................................................................................ 194
Deployment........................................................................................................................................................... 194
8 Summary
Introduction
Preliminary points
Caution: This manual is a tutorial. We advise you to check the online help when you are using
WINDEV Mobile.
The aim of the tutorial is to help you discover WINDEV Mobile, become familiar with the editors
and teach you the concepts of WINDEV Mobile. This manual does not cover all the features of
WINDEV Mobile.
This manual is intended for the developers who are already familiar with WINDEV. This manual
only presents the main concepts required to develop an application for a mobile device (operating
in Android, iPhone, iPad, Windows Mobile, ...).
If you are not familiar with WINDEV, we recommend that you to read the WINDEV tutorial
beforehand.
Note: To receive the WINDEV tutorial, get in touch with the sales department of PC SOFT.
You should plan on spending a few hours to follow this course and to learn WINDEV Mobile: you'll
find it well worth it!
WINDEV Mobile evolving all the time, the screen shots found in this course may differ from the
windows displayed in your product.
Introduction 9
The tutorial was designed to progressively teach you how to use WINDEV Mobile. By following this
course:
you will discover the main concepts explained informally ; these are the concepts you must
learn and understand.
you will also be asked to perform operations that illustrate the concepts just explained.
As you progress through the tutorial, if you want to take a closer look at a concept or if you want to
get more details about a programming function, see the online help (accessible from the editors).
The size of a lesson is not necessarily proportional to its relevance...
And don't forget to take a look at the examples supplied with WINDEV Mobile: they are very
instructive!
The tutorial may have evolved since this document was published. Don't forget
to check the online version of the tutorial. The PDF file is accessible from the
Tip
menu of WINDEV Mobile: on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "Tutorial (PDF)".
This symbol indicates the duration of the lesson. Please note that the actual time may
vary according to your level of experience.
An example is available to complement the lesson. The examples are available in the
home window of WINDEV Mobile.
This symbol introduces a "Tip": we strongly advise you to read the associated text.
This symbol introduces a "Warning": reading the associated text is extremely important.
This symbol introduces a "Note": we recommend that you read the associated text.
10 Introduction
How to access the online help?
The online help of WINDEV Mobile allows you to get detailed information about the 2500
WLanguage functions. The online help also contains the help about the editors and the controls,
tips, ...
The online help is available at any time in WINDEV Mobile:
In the code editor, a specific help is available for each function via the [F1] key.
Each dialog box displayed by WINDEV Mobile proposes a button allowing you to access the
corresponding help page.
The help menu of the editors ("Help" option available on the "Home" pane, in the "Online help"
group of the WINDEV Mobile menu) allows you to start the online help.
The help can be displayed:
in an Internet browser, if you have access to Internet:
Introduction 11
in a specific "help browser":
We advise you to check the online help on Internet rather than the local online
help. Indeed, the Internet online help is updated on a regular basis.
The online help of WINDEV, WEBDEV and WINDEV Mobile on Internet is available
Notes
from any computer equipped with an Internet access, without the product being
necessarily installed.
Each Web user can add comments about the documentation pages: personal
notes, examples, links...
Note: If you have no access to Internet, you have the ability to start the local help from the product:
1.On the "Home" pane, in the "Environment" group, expand "Options" and select "General
options of WINDEV Mobile".
2.In the "Help" tab, select:
the access mode to the help database.
12 Introduction
the content of the help: help common to WINDEV, WEBDEV and WINDEV Mobile or help
about the product currently used.
Introduction 13
Unlike other programming languages, there is no need to find and add modules to be able to
design, check and install an application.
The 5GL (5th Generation Language) of WINDEV Mobile, named WLanguage, will surprise you by
its simplicity: a few hours are all you need to get the hang of it, a week is usually all it takes to fully
master its potential!
No more programming hassle, WLanguage is available in English and in French!
14
:
Introduction
PART 1
Overview of
WINDEV Mobile
16 Part 1: Overview of WINDEV Mobile
Lesson 1.1. Discover WINDEV Mobile
The editor
The development environment of WINDEV Mobile includes a specific interface and several editors
allowing you to create the different elements of your applications.
For example, the window editor is used to create windows, the report editor is used to create
reports, ...
All the editors are using the same environment:
1. Menu of editors, displayed in the shape of a ribbon (we'll see how to use it in the next paragraph).
2. Current editor (window editor here). This space allows you to view the element currently created
or modified in WYSIWYG (What You See Is What You Get).
3. Panes. The interface of WINDEV Mobile includes several panes allowing you to quickly access
different types of information.
Some examples:
the "Project explorer" pane (displayed on the right) is used to list all the project elements by
category.
the search pane (displayed at the bottom) is used to perform searches in the entire project and
in its elements.
These panes can be hidden by pressing [CTRL] + [W] if necessary.
4. Bar of opened documents. This bar is used to quickly view all the opened elements. A simple
click on the button corresponding to the element displays it in its own editor.
The different ribbon panes are used to access the options of the different editors for the current
project. Several types of panes are available:
the current pane.
the popup panes, specific to the current element.
the available panes.
Depending on the selected environment theme (light or dark), the colors used to identify these
different panes are different. SeeThe environment colors, page 21 for more details.
The options displayed in the ribbon differ according to the selected pane. Several types of options
are available:
Options to check,
Buttons to click,
Button with arrow used to expand the options. Two types of buttons with arrow are available:
the buttons with arrow used to expand a menu
the buttons with arrow used to expand a menu (click on the arrow) or to perform a default
action (click on the button icon).
The options are organized by group. Each group of options has a name and it can also include a
group button . This button is used to perform a specific action according to the current
group:displaying the description of the current element, displaying the help, ...
In this tutorial, to identify a menu option, we will be talking about panes and groups.
For example:
To display the help, on the "Home" pane, in the "Online help" group, click "Help".
Note: To improve the readability of this manual, the light theme will be used for the different
images that illustrate the operations to perform.
Android
application
24 Part 2: Android application
Lesson 2.1. My first Android project
Required configuration
Creating an Android project
My first window
My first test
First deployment
Estimated time: 1 h
See the online help for more details (download addresses, ...).
We advise you to restart the computer once JDK and SDK have been installed.
My first project
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My Android project (Answer)".
3.The wizard for project creation starts. The different wizard steps help you create your
project. The information specified in this wizard can be modified later.
4.The first wizard step is used to enter the name of the project, its location and its description.
In our case, this project will be named "My_Android_Project". WINDEV Mobile proposes to
create this project in the "\My Mobile projects\My_Android_Project" directory. You can keep
this location or modify it via the [...] button.
5.Go to the next step via the arrows found at the bottom.
6.The wizard proposes to add documents. Keep the default options and go to the next step
via the arrows found at the bottom.
8.In this example, we are going to generate an application for phones. Select "Generate an
application for phones only" and go to the next step.
You own an Android device and you want to run the test of the created application
Note
on this device? Select "Generate an application for a specific device". The wizard
next step is used to select the requested device.
11.The other wizard steps not being important for our first project, click "End" in the left
section of the wizard.
12.Click the validation button at the bottom of the wizard. The project is automatically created.
13.The window for creating a new element is displayed. This window is used to create all the
elements that can be associated with a project.
Overview
The first window allows the user to display a welcome message via the "Display" button.
You may think this is too basic but we advise you to create this window. You may be surprised by
how intuitive and how easy it is to use the editor of WINDEV Mobile. Furthermore, this window will
allow you to discover concepts that are fundamental for the rest of this tutorial and to see the
entire process for developing an Android application with WINDEV Mobile.
As a new project was created, the window for creating a new element is
automatically displayed.
To display the window for creating a new element, all you have to do is click
among the quick access buttons of WINDEV Mobile:
Note
The skin templates allow you to quickly create outstanding interfaces. A skin
Note
template defines the style of the window as well as the style of all controls that
will be used in this window. No ugly interface anymore.
4.Validate. The window is automatically created in the editor. The backup window of the
created element is displayed. This window is used to specify:
the title of the element. For a window, this title will be displayed in the Action Bar of the
window.
the name of the element that corresponds to the window name. This name will be used in
programming.
the location of the element. This location corresponds to the backup directory of the physical
file corresponding to the element. The window is a "WDW" file, saved in the project directory.
Let's take a look at the window name proposed by WINDEV Mobile: this name
starts with the letters "WIN_". This prefix is automatically added because the
project is using a programming charter.
The programming charter is used to define a prefix for each type of object,
allowing you to quickly identify the element:
Note
Displaying a message
You are now going to create a button used to display a message.
To create the "Display" button:
1.On the "Creation" pane, in the "Usual controls" group, click . The button appears in
creation under the mouse.
2.Move the mouse toward the position where the control will be created in the window (at the
top of the window for example). To drop the control in the window, all you have to do is perform
a click in the window.
3.Perform a right mouse click on the control that was just created. The popup menu of the
control is displayed. Select "Description" from this popup menu. The description window of the
button is displayed.
To modify the name and caption of the button, we have been using the
description window of the control (also called "7-tab window").
The name and caption of the button can also be modified from the window
Notes
currently in edit:
1.Click the control to select it.
2.Press the [ENTER] key or the [SPACE] key: the caption becomes editable.
3.Type the new caption and validate.
Validate the description window of the control (green button). The new control caption
appears in the window editor.
We are going to display a message in a dialog box (a small window proposed by the system).
To do so, we will be using our first WLanguage function: Info.
The code editor proposes different processes for each type of control. These
processes correspond to the events linked to the control.
Therefore, two processes are displayed for the "Button" control:
Notes
Note about the assisted input: As soon as the first two characters are typed, WINDEV Mobile
proposes all the words of the WLanguage vocabulary containing these characters. The assisted
development is a very powerful feature. No more mistake when typing the name of an element:
the syntax errors are reduced. All you have to do is select the requested word and validate by
pressing [ENTER]. You can focus on the algorithm.
When typing this code in the code editor, you have noticed that different colors
are used by the different elements. This is the syntactic coloring. The code editor
allows you to easily identify the different elements handled by the code:
the WLanguage functions are colored in blue,
Notes
First test
For an Android application, WINDEV Mobile allows you to run the test of the application on the
development computer via the simulation mode. This test simulates an Android device on the
development computer. This test is useful when the developer has no Android device. However,
this test does not allow you to use the hardware components of the device (GPS, SMS, camera, ...).
WINDEV Mobile also allows you to run a test of the application via the Android
Notes
Any developer knows that running a program test can be a long and tiresome job. In WINDEV
Mobile, a SINGLE CLICK allows you to run the test of the window, report or procedure while
you are creating it. This is both simple and fast!
Click the "x" button found in the simulator shell to close the window.
The editor of WINDEV Mobile is redisplayed.
First deployment on the device
Principle
To run the application in stand-alone mode on the Android device, you must:
Connect the device via a USB port.
Generate the application. An "apk" file will be created. This file contains all the elements required
to run the application on an Android device.
Select your device at the end of generation. Copying the application ("apk" file) can take several
seconds.
Let's take a look at these different steps.
7.Go to the next step by clicking the arrow keys at the bottom of the window. This step is used
to define:
the splash screen of the application,
the information saved in the manifest,
the start mode of the application (when the device is started or not).
8.Go to the next step. The wizard is used to define the version number of the application.
9.Go to the next step. This step is used to sign the application. The wizard proposes a
generic signature that can be used for the application tests. A specific signature is required to
distribute the application. See the online help for more details.
10.Go to the next step. The wizard allows you to include specific files (data files, images, ...).
This possibility will not be used in our example. Keep the default options.
11.Go to the next step. The wizard allows you to include specific libraries. Keep the default
options.
12.Go to the next step. The wizard allows you to include Maven dependencies used by the
project. Keep the default options.
19.To copy and run the application on the device linked to the computer or on an emulator,
click Deploy.
20.A new window is displayed, allowing you to select the runtime device. If you own an Android
device connected to the development computer, select the device connected to the PC.
That's it, our first application is generated and run on the Android device.
Caution: The USB debugging must be enabled in order to run the tests on the
Notes
phone. If this operation is not performed, the phone will not be detected by
WINDEV Mobile.
To enable the USB debugging:
1.On the phone, select the "Parameters" menu.
2.Select "About the device".
3.Click "Build number" several times to enable the developer mode.
4.Move one level up.
5.The "Development option" choice appears. Select this option.
6.Check "USB debugging".
Note: The operations to perform may change according to the version of the
phone and to its make. For example, for a Samsung Galaxy Notes 3, you must
"tap" several times the "Version number" control found in the "About the device"
option in order to enable "Development option". In any case, a Google search with
"usb debugging <device name>" allows you to get the operating mode adapted to
the device used.
Window orientation
In Android, a window can have one of the following orientations:
Free: the window follows the orientation of the device,
Locked in portrait mode,
Locked in landscape mode.
This orientation is defined in the "GUI" tab of the description window of the window ("Description"
from the popup menu of the window).
Practical example
Open (if necessary) the "My_Android_Project" project that was created in the previous lesson.
Answer
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My Android project (Answer)".
In our example, the project was created for a phone and its test was run in portrait mode in the
simulator.
We are now going to run its test in landscape mode in the simulator.
Run the project test ( among the quick access buttons).
1.The window is displayed in portrait mode.
2.In the simulator, click the menu in the shell ( ).
3.A popup menu is displayed. Modify the window orientation with the "Rotation" option.
4.The window orientation changes on the screen. In our example, the button location does not
change: it does not adapt to the screen orientation.
In the window displayed in the editor, you will notice the little red arrows in the
control. These arrows indicate that the control is anchored.
Practical example
Open (if necessary) the "My_Android_Project" project that was created in the previous lesson.
Answer
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My Android project (Answer)".
The publication of applications on Google Play must comply with specific rules:
During the first publication, you must register beside the Google Play service via a Google
account. Once registered, you have the ability to publish or update as many applications as you
want as many times as necessary.
The published application must be signed with a private cryptographic key. You have the ability
to sign your own application: using a third-party organism is not mandatory. The validity period
of the certificate must end after October 23, 2033.
The applications generated by WINDEV Mobile are automatically signed by using the
information specified in the generation wizard ("Signature of the application" screen) with a
sufficient validity period.
Caution: The published application must not be signed with a generic key (whose use must be
limited to the tests in GO mode).
An icon must be associated with the application. The generation wizard of WINDEV Mobile
allows you to define the icon to use.
Note: Google Play is the most common application but other ones are available.
Caution: The "Unknown sources" option must be enabled on the phone to allow this setup mode.
To enable this option, go to the "Parameters" menu of the phone, in the "Applications" sub-menu.
iOS
application
50 Part 3: iOS application
Lesson 3.1. My first iOS project
Required configuration
Creating an iOS project (iPhone or iPad)
My first window
My first test
First deployment
Why a PC?
WINDEV Mobile 22 is a Windows application that can be used in Windows 7, 10, ...
The application will be created on PC before it is compiled on Mac.
This PC requires no setup of Mac/Apple tools.
Why a Mac?
A Mac is required because the project generated on PC must be compiled in a specific compiler to
generate iOS applications. The minimum version of the operating system must be iOS 8.
Xcode is a development environment that is used to develop iOS applications (iPhone and iPad).
This tool will be used to compile the applications generated with WINDEV Mobile.
The minimum version of Xcode must be version 8.
See the online help for more details (download addresses, ...).
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My iOS project (Answer)".
3.The wizard for project creation starts. The different wizard steps help you create your
project. The information specified in this wizard can be modified later.
1.Click among the quick access buttons in the menu of WINDEV Mobile.
2.The window for creating a new element is displayed: click "Project".
In our case, this project will be named "My_iOS_Project". WINDEV Mobile proposes to create this
project in the "\My Mobile projects\My_iOS_Project" directory. You can keep this location or
modify it via the [...] button.
4.Go to the next step via the arrows found at the bottom.
5.The wizard proposes to add documents. Keep the default options and go to the next step.
6.The wizard proposes to choose the type of devices affected by the project:
Generate an application for iPhone and iPad.
Generate an application for iPhone only.
Generate an application for iPad only.
Generate an application for a specific device.
only".
In this case, WINDEV Mobile proposes the smallest resolution to create the
application windows. Using anchors (see page 67 and page 122) will allow the
application to operate on all devices.
10.The other wizard steps not being important for our first project, click "End" in the left
section of the wizard.
11.Click the validation button at the bottom of the wizard. The project is automatically created.
12.The window for creating a new element is displayed. This window is used to create all the
elements that can be associated with a project.
Overview
The first window allows the user to display a welcome message via the "Display" button.
You may think this is too basic but we advise you to create this window. You may be surprised by
how intuitive and how easy it is to use the editor of WINDEV Mobile. Furthermore, this window will
allow you to discover concepts that are fundamental for the rest of this tutorial and to see the
entire process for developing an iOS application with WINDEV Mobile.
As a new project was created, the window for creating a new element is
automatically displayed.
To display the window for creating a new element, all you have to do is click
among the quick access buttons of WINDEV Mobile:
Note
The skin templates allow you to quickly create outstanding interfaces. A skin
Note
template defines the style of the window as well as the style of all controls that
will be used in this window. No ugly interface anymore.
4.Validate. The window is automatically created in the editor. The backup window of the
created element is displayed. This window displays:
the title of the element. For a window, this title will be displayed in the Action Bar of the
window.
the name of the element that corresponds to the window name. This name will be used in
programming.
the location of the element. This location corresponds to the backup directory of the physical
file corresponding to the element. The window is a "WDW" file, saved in the project directory.
Let's take a look at the window name proposed by WINDEV Mobile: this name
starts with the letters "WIN_". This prefix is automatically added because the
project is using a programming charter.
The programming charter is used to define a prefix for each type of object,
allowing you to quickly identify the element:
Note
Displaying a message
You are now going to create a button used to display a message.
To create the "Display" button:
1.On the "Creation" pane, in the "Usual controls" group, click . The button appears in
creation under the mouse.
2.Move the mouse toward the position where the control will be created in the window (at the
top of the window for example). To drop the control in the window, all you have to do is perform
a new left mouse click.
3.Perform a right mouse click on the control that was just created. The popup menu of the
control is displayed. Select "Description" from this popup menu. The description window of the
button is displayed.
Modify the control characteristics by typing the following information:
currently in edit:
1.Click the control to select it.
2.Press the [ENTER] key or the [SPACE] key: the caption becomes editable.
3.Type the new caption and validate.
Validate the description window of the control (green button). The new control caption
appears in the window editor.
We are going to display a message in a dialog box (a small window proposed by the system).
To do so, we will be using our first WLanguage function: Info.
The programming language supplied with WINDEV Mobile is named WLanguage.
Notes
The code editor proposes different processes for each type of control. These
processes correspond to the events linked to the control.
Therefore, two processes are displayed for the "Button" control:
Notes
Note about the assisted input: As soon as the first two characters are typed, WINDEV Mobile
proposes all the words of the WLanguage vocabulary containing these characters. The assisted
development is a very powerful feature. No more mistake when typing the name of an element:
the syntax errors are reduced. All you have to do is select the requested word and validate by
pressing [ENTER]. You can focus on the algorithm.
When typing this code in the code editor, you have noticed that different colors
are used by the different elements. This is the syntactic coloring. The code editor
allows you to easily identify the different elements handled by the code:
the WLanguage functions are colored in blue,
Notes
Principle
To run the application in stand-alone mode on the device, you must:
Generate the iOS application (or Xcode project) in WINDEV Mobile.
Transfer the generated Xcode project onto Mac in order to compile it.
Compile the project in Xcode in order to generate the program.
Then, the program can be installed on the connected device or started in the xCode emulator. It
will run in stand-alone mode.
Let's take a look at these different steps.
Implementation
This identifier will be used to save your application in order to run its test and to
deploy it. By default, WINDEV Mobile automatically proposes an identifier that
respects the development standard of Apple. This identifier can be modified.
5.Go to the next step. You have the ability to specify the path of the different application icons.
Several icons can be supplied:
icons for iPad and iPad Retina (only if the application proposes windows for iPad).
icons for all the iPhone models (for example, iPhone 4 has a different resolution with the
Retina screen).
Then, you have the ability to run the test of your application on your iPhone or iPad.
Window orientation
In iPhone or iPad, a window can have one of the following orientations:
Free: the window follows the orientation of the device,
Locked in portrait mode,
Locked in landscape mode.
Practical example
Open (if necessary) the "My_iOS_Project" project that was created in the previous lesson.
A corrected project is available. This project contains the different windows
Answer
created in this lesson. To open the corrected project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My iOS project (Answer)".
In our example, the project was created for a phone and its test was run in portrait mode in the
simulator.
We are now going to run its test in landscape mode in the simulator.
4.The window orientation changes on the screen. In our example, the button location does not
change: it does not adapt to the screen orientation.
We are now going to modify our window in order for the "Display" button to be centered in the
window and to remain centered regardless of the device orientation.
Stop the test and go back to the editor.
To center the button in the window:
1.Select the button (click the button).
2.On the "Alignment" pane, in the "Centering and distribution" group, click "Center in the
parent (horz)".
In order for the button to remain centered in the window, we are going to use the control
anchoring:
1.Select the button (click the button).
2.Display the popup menu (right mouse click).
In the window displayed in the editor, you will notice the little red arrows in the
control. These arrows indicate that the control is anchored.
Touchscreen management
One of the most important aspects of the interface for a mobile application is the management of
the touchscreen feature.
A "multitouch" feature is a technique allowing the user to interact with a device via several contact
points.
Handling images is one of the most common features of the multi-touch. The display size on a
phone being reduced, it is often necessary to zoom an image and/or move inside an image.
This allows you to perform a zoom on an image via the contact of 2 fingers moving apart.
Open (if necessary) the "My_iOS_Project" project that was created in the previous lesson.
Answer
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My iOS project (Answer)".
this feature, the application must be deployed on the mobile device. We will
see how to do this in Android and iOS: Developing an application, page
93.
Deployment
Three methods can be used to deploy the application on a device (iPhone or iPad).
Via App Store: This type of distribution allows you to distribute your application without any
restrictions via the sales network of App Store. Your application will include the signature linked
to your certificate but it will not be linked to a single device.
Via an In-House network: This type of distribution allows you to distribute your application via a
Web server to a group of users working for the same company. To use this type of distribution,
you must register to the iOS Developer Enterprise program. Your application will include the
signature linked to your certificate but it will not be linked to a single device.
Via an Ad Hoc network: This type of distribution allows you to install the application on a network
containing up to 100 devices (iPhone or iPad). The application must be recompiled for the target
device by including the certificate for the signature as well as the unique identifier of the device.
Caution: To run the test of the application and/or to deploy the application on a device (iPhone or
iPad), you must register toward the iOS Developer Program. This registration is not free of charge.
The list of registration programs is available from the following address:
http://developer.apple.com/programs/which-program/
Three types of registration are available:
iOS Developer Program - Individuals
iOS Developer Program - Organizations
iOS Developer Enterprise Program
This registration is used to get a developer certificate allowing you to sign your applications in
order to compile them and to distribute them. This certificate is not free of charge. This developer
certificate is required even for a simple setup for test (debug) on a device.
Programming
concepts
74 Part 4: Programming concepts
Lesson 4.1. Concepts and terminology
Main concepts
WINDEV Mobile allows you to easily create an application. But what is an Application?
An application is a tool used to automatically perform tasks, actions.
To create an application, WINDEV Mobile proposes to create a project. A project links and
organizes the different program elements. The program corresponding to the application will be
created from the project.
If your application is using data, WINDEV Mobile allows you to define the structure of the database
via the analysis. The WINDEV Mobile analysis contains the description of the files (also called
"Tables" in several databases). These files will contain the application data.
Notes
Describing the data files in the analysis does not mean that they are created. The
data files are physically created when running the application.
One or more WINDEV Mobile projects can be linked to the same analysis. In this case, we talk of
shared analysis. For example, an application for business management can be divided into several
modules. Each module is using the same analysis (at run time, each application can also use the
same data files).
Project 1
Analysis
Project 2 Project N
What is a variable?
In a programming language, a variable is used to store data. These memory sections contain
strings, numbers, etc.
The variables are used to perform calculations, to perform comparisons or to store information
that will be used later.
Declaring a variable
The variable must be declared (which means created) before it can be used.
Example of simple declaration:
Price is currency
Price represents the name of the variable.
is allows you to declare the variable. The common language is used in WLanguage.
currency corresponds to the type of variable.
In WLanguage, the " character (double quote) is the character used to delimit a
Notes
character string. In the above example, the doubles quotes are used to assign the
Doe value to the LastName variable.
The content of a variable can be read and handled: all you have to do is use the name given to the
variable in order to access it.
The following example is used to read and display the content of the Price variable on the screen:
Info(Price)
Use the type corresponding to the information that must be stored. Therefore,
you will optimize the memory and you will avoid calculation or process errors
when using variables in the WLanguage functions.
Other types are available like the arrays, the structures, the dates, the times, ...
Advanced variables are also available. These advanced types group all the
Notes
Project
Global variables
Global procedures
GUI
(Windows, Pages, Mobile windows, Reports)
Global variables
Local procedures
Processes
Local variables
// Declaration of variables
Ctr is int
V1 is int
Res is numeric
// Assignment
Ctr = 10
V1 = 3
// Use of {} operators
Ctr = Ctr + 3 // Ctr is equal to 13
Ctr ++ // Ctr is equal to 14
Ctr -= 8 // Ctr is equal to 6
Ctr = Ctr * V1 // Ctr is equal to 18
Res = Ctr / 5 // Res is equal to 3.6
Tips
It is very convenient to name the variables with long names (and to avoid short names such as
i, j, k, ...). When reading the program again, you will be able to easily find out the purpose of the
variable.
To define the name of variables, all the Unicode characters (including the accented characters)
are accepted. Meaning improved readability ! Caution: some characters are not allowed: space,
=, dot, comma, ...
It is very important to give the proper type to the variable according to its use. For example, to
store several digits, you may have to:
use a numeric variable if this variable must be used for calculations.
use a string variable if this variable must be used to store digits without performing
calculations (to store the social security number for example).
The IF statement
This statement is used to run an action or another one according to the result of an expression. If
the expression is checked, a process is run ; if the expression is not checked, another process can
be started.
The IF statement can be used as follows:
Code sample: The following code selects a number at random and displays a message according
to the value.
Tot is currency
// Selects a number at random between 100 and 4000
Tot = Random(100, 4000)
IF Tot>2000 THEN
Info("The amount is greater than 2000")
ELSE
Info("The amount is less than or equal to 2000")
END
Note: Several code lines can be run during the process corresponding to a condition. In this case,
the following syntax must be used:
SWITCH <Expression>
CASE Value 1:
Process 1...
CASE Value 2:
Process 2...
...
CASE Value N:
Process N...
OTHER CASE
Process ...
END
Example: The following code retrieves today's date and displays a different message according to
its value. A specific message is displayed for the 1st and for the 15th of the month. In the other
cases, today's date is displayed.
D is Date
D = Today()
SWITCH D..Day // Checks the day of the date
CASE 1 : Info("Today is the first day of the month")
CASE 15 : Info("Today is the 15th of the month.")
OTHER CASE: Info("Today is: "+ DateToString(D))
END
Notes:
If the code line "CASE 1:..." is run, the other code lines corresponding to the possible values are
not run.
Several values can be grouped in the same case. The different values are separated by a
comma. For example:
Sub is int = 2
SWITCH Sub
CASE 1,2: Info("Case 1 or 2")
CASE 3: Info("Case 3")
OTHER CASE: Info("Other case")
END
Several code lines can be run during the process corresponding to a condition. In this case, the
following syntax must be used:
SWITCH <Expression>
CASE Value 1:
Process 1 - Code line 1...
Process 1 - Code line 2...
CASE Value N:
Process N - Code line 1...
Process N - Code line 2...
END
For example, the following code runs the process 2000 times:
Note: An increment step can be defined for the subscript via the STEP keyword. For example, the
following code runs the process 2000 times and the nCtr variable decreases from 10 to 10:
Counter is int
Counter = 10
LOOP
// Process to run
Counter = Counter - 1
IF Counter = 0 THEN BREAK
END
The LOOP statement and the FOR statement can have the same behavior: all you
have to do is use the syntax with exit according to the number of iterations:
LOOP (<Number of Iterations>)
...
Tip
END
Example:
LOOP(10)
// Process to run
END
For example:
Counter is int
Counter = 0
WHILE Counter<10
// Process to run
Counter = Counter + 1
END
Types of procedures
Threee types of procedures are available:
Global procedure: can be used in all the processes of the project (declared in a set of
procedures).
Procedure local to a Window, Page or Mobile Window: can be used in all the processes related
to the object where this procedure was declared.
Procedure internal to a process: can only be used in the process where it was declared.
Scope of procedures
Notes
The procedures comply with the scope rules presented for the variables (see
The scope of variables, page 81).
Local procedure
To create a local procedure, you must:
1.Select the element associated with the procedure (window, page, ...).
2.Create a local procedure (via the "Project explorer" pane, expand the name of the element,
"Local procedures" folder).
3.Give a name to the procedure.
4.Type the code of the local procedure. The procedure code has the following format:
Calling a procedure
To call a procedure, use the name of the procedure (with the possible parameters that will be
passed to it).
Parameters of a procedure
What is a parameter?
A parameter is a value sent to a procedure during the call to the procedure.
The following example is used to call the Multiply10 procedure and to pass in parameter the value
that will be handled in the procedure:
Multiply10(50)
You have the ability to pass from 0 to several values in parameter to a procedure. These values
can have any type (like for the variables).
The parameter is specified in the procedure declaration in the format of a variable. For example,
for the Multiply10 procedure, the code of the procedure is:
PROCEDURE Multiply10(P)
P=P*10
To specify the role of the parameter in the procedure, you have the ability to
Notes
In the following example, the Multiplication procedure expects two Integer parameters and returns
the result of the multiplication.
The code of the procedure is as follows:
res is int
res = Multiplication(10, 50)
// Res is equal to 500
T is int
T = 12 // T is set to 12 before the call
Test_address(T)
// T is set to 24 after the call
To avoid modifying the value of the variable corresponding to the parameter, the parameters
must be passed by value. Passing parameters by value allows you to handle a copy of the
parameter value. If the procedure code modifies the value of the variable, the value of the variable
corresponding to the parameter is not modified.
To force a parameter to be passed by value to a procedure, the LOCAL keyword must be used in
front of the parameter name in the declaration of the procedure. This keyword indicates that the
following parameter will not be modified by the procedure.
Example:
The code of the procedure is as follows:
T is int
T = 12 // T is set to 12
Test_value(T)
// T does not change
When declaring a procedure, the optional parameters are the last parameters
(they are always specified after all the mandatory parameters).
In the following example, the Multiplication procedure is using an optional parameter, Nb2. This
optional parameter is indicated after the mandatory parameters, by specifying its default value. In
this example, the default value of the optional parameter is set to 10.
res is int
res = Multiplication(6)
// Res is equal to 60
In this example, the second parameter was not specified. Therefore, its default value will be used.
Result of a procedure
The procedures can return one or more results. The result can be typecasted. The RESULT keyword
must be used to return a value.
See the online help (keyword: "Result") for more details.
This part can be followed both by the developers of Android applications and by
Note
We are going to develop a multi-platform project that can be used both on an Android platform and
on an iOS platform.
Most of the time, when developing an application for Mobile, this application must operate both
on Android and on iOS.
With WINDEV Mobile, there is no need to develop two different projects, to maintain them and to
make them evolve in parallel. All you have to do is create a single project associated with several
platforms, Android and iOS for example: this is called a multi-platform project.
Each project element (windows, queries, ...) can be associated with one or more platforms.
If a window is common to several platforms, the specific features of the platform can be managed
via the layouts. The layout is used to define several views of a window in the same project without
duplicating this window.
When the project is developed, all you have to do is select the requested configuration to create
and deploy the application on the selected platform.
In iOS and Android, only the HFSQL database is accessible in native mode. Both
the Classic mode and the Client/Server mode are available.
HFSQL Classic
In HFSQL Classic mode, the data files are stored on the device (iPhone, iPad,
Android phones or tablets).
In this case, the application is stand-alone. No Wi-Fi or 4G connection is required.
The data is stored in the device memory. The maximum storage size depends on
the amount of memory on the device.
If the data typed on the mobile device must be synchronized with a database
found on a server (HFSQL or other), the replication must be implemented (see
the online help).
Manta server
Hxxx
functions
,
(read,
write...)
Replication HFSQL
Client/Server
databases
Database
Mobile Device 1
Windows or Linux
HFSQL server
Mobile Device 2
Manta server
Note
HFSQL
Client/Server
databases
Mobile Device N
To access this computer and this database, a method for communicating with
the server must be enabled in the mobile application (Wi-Fi or 4G) in order to
connect via the network or Internet.
The response times depend on the quality of the Wi-Fi or Internet network and on
the amount of requested data.
The access to the data will be performed by the Hxxx functions of WLanguage
and/or by SQL queries.
For more details, see the online help.
Start WINDEV Mobile 22 (if not already done). Close (if necessary) the current project in order
to display the home window.
Open the "WM Managing Products" project.
To do so, in the home window, click "Tutorial" and select the "iOS/Android application
(Exercise)" project.
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "iOS/Android application (Exercise)".
created in this lesson. To open the corrected project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "iOS/Android application (with
windows)".
To enable the iOS platform, all you have to do is create a project configuration:
1.On the "Project" pane, in the "Project configuration" group, expand "New configuration" and
select "iPhone/iPad application".
The project configurations are used to define the different types of generation
supported by the project: Android, iOS, component, ...
The project elements can be:
common to several configurations (a window used in iOS and Android for
Note
example).
specific to a configuration (a class used by a component for example).
You can work on a specific configuration at any time: the elements that do not
belong to this configuration are grayed in the project editor.
See the online help for more details.
only".
In this case, WINDEV Mobile proposes the smallest resolution to create the
application windows. Using anchors (see page 68 and page 125) will allow the
application to operate on all devices.
3.To select a specific configuration, all you have to do is double-click the name of the
requested configuration.
4.The iOS configuration that was just created is automatically selected.
The wizard for window creation proposes several preset windows. These windows
propose modern interfaces for your applications.
Notes
Most of these windows can be generated from your data, by including the
WLanguage code required for them to operate. They can be used straightaway.
If you are using an iOS configuration, the window for creating a new window
contains additional options, specific to iOS.
Notes
A "Looper" window can be created for an iOS platform and for an Android
platform.
5. The wizard proposes to choose the data source associated with the window. In our case, it
will be the "Product" data file:
The "Data files" option is selected by default.
Select the Product file.
Generate a creation button in the Action Bar: If this option is selected, the wizard proposes
to generate a form window in edit.
Enable the deletion by row swipe: If this option is selected, the user will have the ability to
delete a looper element by swiping the corresponding row.
Generate an opening code for the form: If this option is selected, the wizard proposes to
generate a form window in edit or in read-only.
13.In our example, keep the default options. Go to the next step.
14.Give a title and a name to the generated window. Type the window title: "List of products".
The window name is automatically filled.
The data automatically appears in the window displayed in the editor. This
Notes
concept is called "Live Data": you see the data found in your files in real time!
This feature is very useful to adapt the size of controls to their content.
We are going to run a first test in the simulator to see the result. Click among the quick
access buttons (or press [F9]).
To run the test on another platform, all you have to do is enable this platform by
double-clicking its name in the project explorer.
Note: In this part, the images representing the tests correspond to an Android
shell.
Creating controls
To create the different edit controls used to display information about the product:
1.Display the "Analysis" pane if necessary: on the "Home" pane, in the "Environment" group,
expand "Panes" and select "Analysis". The different data files described in the "WM Managing
Products" analysis appear in the pane.
2.With the mouse, select the items of the "Product" file displayed in the pane (except for the
"ProductID" item).
3.Drag and Drop these items to the window that was just created.
4.Resize the controls ("Name", "BarCode", "Reorder Date" and "Description") so that they are
visible in the window.
FileToScreen is used to display in the controls the data found in the data file, for the current
record. In our case, the current record will be the record selected in the Looper control of the
"WIN_List_of_products" window.. This looper is linked to the Product file.
3.Close the code window.
4.Save the window.
2.Right-click the Looper control and select "Code" from the popup menu.
3.In the code window that is displayed, enter the following code in the "Selecting a row of..."
process:
OpenMobileWindow(WIN_Product_form)
The assisted code input is going to help you: as soon as you type the opening
bracket "(", a drop-down list proposes the name of all the existing windows found
in the project. All you have to do is select the window with the keyboard or with
Notes
the mouse.
If the window name is not displayed in the list, it means that this window was not
saved beforehand.
3.Click number 2. The interface for entering an option in the toolbar is displayed.
4.Click the "+" button to add an option. A new default option is created at the top right.
5.Modify the characteristics of this option:
In the "Caption" area, type "Validate".
At run time, the caption of the option appears in the Action Bar:
Notes
To go back to the interface for describing the Action Bar, all you have to do is click
the button .
6.The code of this option will be used to save the modifications performed in the "WIN_
Product_form" window. To type this code:
Select (if necessary) the Action Bar control of the window.
Click the "OK" button.
A drop-down menu with the "Validate" option is displayed.
Notes
This drop-down menu is visible in edit to enter the WLanguage code associated
with the option. This drop-down menu will not be displayed at run time.
2.Right-click the window background and select "Code" from the popup menu. The following
code is automatically displayed in the "Closing a child window" process:
LooperDisplay(LOOP_Product,taCurrentSelection)
4.Click number 2. The interface for entering an option in the toolbar is displayed.
5.Click the "+" button to add an option. A new default option is created at the top right. Modify
the characteristics of this option:
In the "Caption" area, type "New product".
HReset initializes the variables of the items found in the "Product" data file with the default
values to manage a new record. Save the modifications by clicking among the quick access
buttons.
7.Close the code window (click the cross in the top right corner of the code editor).
Let's now check the management of the addition of a new record into the window of the
product form.
1.Display the "WIN_Product_form" window in the editor: click the corresponding button in the
bar of opened elements.
2.Display the code of the validation option in the Action Bar:
Select the Action Bar.
Click the "OK" button.
A drop-down menu with the "Validate" option is displayed.
Select "Code" from the popup menu of the "Validate" option (right mouse click).
The "Click" process does not change:
ScreenToFile()
HSave(Product)
Close()
If your project is using several platforms, run a GO for each one of the platforms.
Notes
The differences regarding the display and the operating modes will appear in the
simulator.
This paragraph requires a device equipped with a camera. If this is not the case,
go to the next paragraph directly.
Caution!
Overview
We are going to manage the product photo by using the device camera.
To do so, we are going to:
create a button to start the camera. The photo will be retrieved in the format of an image in
memory and displayed in the Image control of the product.
create a button used to select a photo in the album found on the mobile.
Taking photos
We are going to enter the code used 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 (right mouse click).
2.Type the following code in the "Click" process:
// Local variable
sPhoto is string
// Start the camera
sPhoto = VideoStartApp(viPictureCapture)
IF sPhoto <> "" THEN
IMG_Photo = sPhoto
END
In this code, VideoStartApp is used to start the native camera application of the device in order
to save a video or to take a photo.Save the modifications by clicking among the quick access
buttons.
3.Close the code window (click the cross in the top right corner of the code editor).
In this code, AlbumPicker is used to retrieve the photo selected in the photo album.Save the
modifications by clicking among the quick access buttons.
3.Close the code window (click the cross in the top right corner of the code editor).
Overview
The "Product" data file contains a "Bar_Code" item. This item is used to store the value of a bar
code. Some devices (especially the ones equipped with a camera) can scan a bar code to retrieve
its value.
The bar code will be managed via the camera of the device and by a specific WLanguage function.
Implementation
In this code, BCCapture is used to decode the information stored in a bar code by using the
camera of the device.Save the modifications by clicking among the quick access buttons.
3.Close the code window (click the cross in the top right corner of the code editor).
To define the anchoring that will be applied the different window controls:
1.Select the following controls (click each control while keeping the CTRL key down):
the photo of the product,
the button for taking photos,
the button for selecting a photo in the album.
4.Validate.
To define the anchoring that will be applied the edit controls:
1.Select the following edit controls (click each control while keeping the CTRL key down):
LastName
Bar code
Reorder date
Description
2.Display the popup menu of the selection (right mouse click) and select "Anchor".
3.Select "Width" ( ).
4.Validate.
Repeat this operation for the button used to manage bar codes. In this case, select "Right"
( ).
4.We are going to delete the blank line that is useless in our example:
Select the blank line (the first line) with the mouse.
Click the "Delete" button.
We are now going to write the code used to perform each menu action:
1.Right-click the Multiline Zone control and select "Code".
Caution: make sure you select the Multiline Zone control and not one of the controls included in
it.In the code editor, enter the following code in the "Selection (click) of a line in..." section:
SWITCH MZ_MENU
CASE 1 // List of products
OpenMobileWindow(WIN_List_of_products)
CASE 2 // Map of stores
OpenMobileWindow(WIN_Map_of_stores)
CASE 3 // Exit from the application
Close()
END
Application test
The last step consists in specifying that the menu window is the first application window. To do so,
we are going to run a full test of the project and define the first project window.
To define the first project window:
1.Select the "WIN_Menu" window in the project explorer.
2.Display the popup menu.
3.Select "First project window". A specific icon (with a small 1) is displayed in front of the
name of the window, in the project explorer.
Until now, the test of windows was run individually by clicking among the quick access buttons.
To run the project test:
1.Click among the quick access buttons.
2.Your project starts with the menu window. Click an option of your menu to check whether
the different links are correct.
If the "WM Managing Products" application was not created, a sample project is
available. This project allows you to follow this lesson.
To open this intermediate project, on the "Home" pane, in the "Online help"
Answer
The anchors have already been used in the "WIN_Product_form" window. In test mode, we get
the following interfaces:
All the controls found in portrait mode are also displayed in landscape mode but a lot of space is
not used and the window must be scrolled to access all the controls.
We are going to improve the display in landscape mode via layouts.
The layout is used to define several views of a window in the same project without
duplicating this window.
This gives you the ability to define:
a specific view for the portrait mode,
Notes
Select the "Name" and "Reorder date" controls and position them on the right of the photo
and buttons.
Select the "Price" and "Quantity" controls and move them below the photo of the product on
the left.
Select the "Description" control and position it on the right of the quantity. Reduce the
control height if necessary.
Select the Image control. The Image control as well as the two buttons are enclosed by a red
line. Indeed, an anchoring conflilct occurs with the Name control.
specified criteria.
This type of query is called a select query because the SELECT command is used
in SQL language.
To open this project, on the "Home" pane, in the "Online help" group, expand
"Tutorial" and select "iOS/Android application (with windows)".
a corrected project is available. This project contains all the windows created
in this part and it allows you to check your operations.
To open this corrected project, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "iOS/Android application (Answer)".
To build the query, we are going to select the elements that will be displayed in the result.
1.The query must be used to display the characteristics of the selected product:
Select the "Product" file in the "Analysis" area of the window.
Click the arrow to select all the file items in the query.
3.In the window that is displayed, we are going to specify that the selection condition
corresponds to a parameter:
Select "contains".
Select "the parameter".
Keep the parameter name automatically proposed: "paramName".
4.Validate the description window of the condition. The number "1" appears on the right of the
"Product.Name" item, indicating that a selection condition was defined.
4.Validate the window. The query result corresponding to the specified parameters is
displayed.
5.Close the window.
We are now going to create the interface of our window based on this query.
The wizard for window creation proposes several preset windows. These windows
Notes
We are now going to modify the "WIN_List_of_products_Advanced" window in order to display
the Product form that was created in a previous lesson.
1.Right-click the Looper control and select "Code".
Caution: make sure you select the Looper control and not one of the controls included in it.In
the code editor, type the following code in the "Initializing..." section:
QRY_Products.ParamName = Null
2.This code line is used to initialize the value of the parameter found in the "QRY_Products"
query used by the Looper control. By default, the value of this parameter is set to "Null",
allowing you to ignore the parameter. Therefore, all the products will be displayed in the
window.
3.In the code editor, type the following code in the "Selecting a row..." section:
HReadSeek(Product,ProductID,QRY_Products.ProductID)
OpenMobileWindow(WIN_Product_form)
ActionBarSearchVisible(True)
A specific internal window can be used to manage the "Pull to refresh" feature. In
Notes
this example, we will be using the default window. See the online help for more
details.
3.As already seen for the search management, LooperDisplay is used to redisplay the Looper
control. The taReExecuteQuery constant is used to re-run the base query of the Looper control
and therefore to take into account the new records entered in the database.
4.Save the modifications by clicking among the quick access buttons.
5.Close the code window (click the cross in the top right corner of the code editor).
Run the test of the window that was just modified in the simulator ( among the quick
access buttons).
Click the top of the looper with the mouse and move the mouse to the bottom.
Release the mouse. The looper is updated.
4.Validate.
5.Display the description window of the internal window ("Description" from the popup menu).
7.Validate.
8.Save the window by clicking among the quick access buttons.
To add the menu options into the internal window:
1.Open the "WIN_Menu" window that was created beforehand (double-click its name in the
project explorer for example).
2.Copy the controls found in the "WIN_Menu" window to the "IW_MLZ_Options" internal
window:
Select all the elements found in the "WIN_Menu" window (CTRL A).
Copy the elements (CTRL C).
Display the "IW_MLZ_Options" window (click its name in the bar of opened elements).
Paste the elements (CTRL V).
3.Via the selection handles, modify the width of the Multiline Zone control so that it is entirely
displayed in the internal window. Via the anchors, all the controls found in the Multiline Zone
are also modified. You get the following window:
by:
CASE 1 // List of products
WinSlidingVisible(swLeft,False)
In this code, WinSlidingVisible is used to make the sliding window displayed from the left
invisible. Therefore, the list of products is displayed.
4.Save the modifications by clicking among the quick access buttons.
5.Close the code window (click the cross in the top right corner of the code editor).
To associate the internal window with the "WIN_List_of_products_Advanced" window:
1.Display the "WIN_List_of_products_Advanced" window (click its name in the bar of opened
elements).
2.Display the description window.
3.In the "Details" tab, in the "Left sliding window" area, select the "IW_MLZ_Options" window.
The "Swipe" option is used to automatically manage the display of the sliding window during
the swipe.
4.Validate.
6.Accept.
We are going to check the operating mode of the sliding menu in the simulator:
1.In the project explorer, define the "WIN_List_of_products_Advanced" window as first project
window (indeed, the "WIN_Menu" window is now useless).
Select the "WIN_List_of_products_Advanced" window in the project explorer.
Display the popup menu.
Select "First project window". A specific icon (with a small 1) is displayed in front of the name
of the window, in the project explorer.
2.Click among the quick access buttons.
3.When clicking the menu of the Action Bar, the sliding window of the menu appears.
windows created in this part and it allows you to check your operations.
To open this corrected project, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "iOS/Android application (Answer)".
To simplify the creation of the internal window, we are going to create it from the "WIN_
Product_form" window found in our project:
1.Open (if necessary) the "WIN_Product_form" window in the editor (double-click its name in the
project explorer for example).
2.Select all the controls found in the portrait layout (CTRL A).
3.Display the popup menu and select "Refactoring .. Create an internal window from the
selection".
4.The internal window is automatically created and the backup window is displayed. Give the
"IW_Product" name and validate.
5.Display the description window of the internal window and, in the "GUI" tab, modify the
width of the window: 320. This width corresponds to the width of the Internal Window control
that was created in the "WIN_Product_form_Advanced" window.
6.Validate.
5.In the "Content" tab, we are going to configure the mode for filling the internal window. This
window will display the data found in the Product file:
Click "File/Query".
In the source, select the "Product" file.
by
HReadSeek(Product,ProductID,QRY_Products.ProductID)
OpenMobileWindow(WIN_Product_form_Advanced)
We are going to check the operating mode of the project in the simulator:
1.Click among the quick access buttons.
2.In the looper that is displayed, click a product to display its form.
3.Click the product form and move the mouse to the right or to the left. The product form
automatically changes.
Don't hesitate to see the online help to discover and check new features.
If your project is using the Android platform only, the files must be selected in the
EXE directory of the project.
16.End the wizard. The generation is automatically performed in background task. The
icon indicates that the generation is in progress.
18.To copy and run the application on the device linked to the computer or on an emulator,
click Deploy.
19.A new window is displayed, allowing you to select the runtime device. If you own an Android
device connected to the development computer, select the device connected to the PC.
3.Copy the apk file into the "Download" directory of the device.
4.Unplug the device.
5.Start the application for file management on the device.
6.Go to ther "Download" directory and run the apk file. The application is
automatically installed.
This identifier will be used to save your application in order to run its test and to
deploy it. By default, WINDEV Mobile automatically proposes an identifier that
respects the development standard of Apple. This identifier can be modified.
12.Indicate that these data files must be in write mode: check the "Write" box.
15.Go to the next step. This step is used to specify the signature options for Xcode 8. See the
online help for more details.
16.Validate the wizard.
17.The generation is performed in the EXE folder of the project directory. The directory
containing the source code that will be used on Mac is named "Project_name.xcode.gen"
("WM Managing Products.xcode.gen" in our example). This is the directory that must be copied
onto Mac. Click the "Open the generation directory" button.
The other operations must be performed on Mac. You must:
Transfer the WINDEV Mobile project onto Mac.
Compile the project in Xcode.
Universal Windows
application
174 Part 6: Universal Windows application
Lesson 6.1. My first Universal
Windows 10 project
Required configuration
Creating a Universal Windows 10 project
My first window
My first test
First deployment
Estimated time: 1 h
My first project
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My UWA project (Answer)".
3.The wizard for project creation starts. The different wizard steps help you create your
project. The information specified in this wizard can be modified later.
4.The first wizard step is used to enter the name of the project, its location and its description.
In our case, this project will be named "My_UWA_Project". WINDEV Mobile proposes to create
this project in the "\My Mobile projects\My_UWA_Project" directory. You can keep this location
or modify it via the [...] button.
5.Go to the next step via the arrows found at the bottom.
6.The wizard proposes to add documents. Keep the default options and go to the next step.
7.Specify the location of the Windows 10 SDK required to generate applications. If the SDK
was installed, the setup path is automatically proposed ("C:\Program Files (x86)\Windows
Kits\10\bin" for example).
10.In this example, we are going to generate an application for phones. Select "Generate an
application for phones only" and go to the next step.
11.In the left section of the wizard, click "Charters". This step is used to define the
programming charter. Don't modify the suggested options. Go to the next step.
13.The other wizard steps not being important for our first project, click "End" in the left
section of the wizard.
14.Click the validation button at the bottom of the wizard. The project is automatically created.
15.The window for creating a new element is displayed. This window is used to create all the
elements that can be associated with a project.
My first window
Overview
The first window allows the user to display a welcome message via the "Display" button.
You may think this is too basic but we advise you to create this window. You may be surprised by
how intuitive and how easy it is to use the editor of WINDEV Mobile. Furthermore, this window will
allow you to discover concepts that are fundamental for the rest of this tutorial and to see the
entire process for developing a Universal Windows 10 application with WINDEV Mobile.
As a new project was created, the window for creating a new element is
automatically displayed.
To display the window for creating a new element, all you have to do is click
among the quick access buttons of WINDEV Mobile:
Note
The skin templates allow you to quickly create outstanding interfaces. A skin
Note
template defines the style of the window as well as the style of all controls that
will be used in this window. No ugly interface anymore.
4.Validate. The window is automatically created in the editor. The backup window of the
created element is displayed. This window displays:
the title of the element: For a window, this title will be displayed in the Action Bar of the
window.
the name of the element that corresponds to the window name. This name will be used in
programming.
the location of the element. This location corresponds to the backup directory of the physical
file corresponding to the element. The window is a "WDW" file, saved in the project directory.
5.Specify the title of the "Welcome" element (in this case, the element corresponds to the
WINDEV Mobile window). The name of the element "WIN_Welcome" is automatically proposed.
6.Click the green button to validate the information displayed in the backup window.
Displaying a message
You are now going to create a button used to display a message.
To create the "Display" button:
1.On the "Creation" pane, in the "Usual controls" group, click . The button appears in
creation under the mouse.
2.Move the mouse toward the position where the control will be created in the window (at the
top of the window for example). To drop the control in the window, all you have to do is perform
a click in the window.
3.Perform a right mouse click on the control that was just created. The popup menu of the
control is displayed. Select "Description" from this popup menu. The description window of the
button is displayed.
Modify the control characteristics by typing the following information:
currently in edit:
1.Click the control to select it.
2.Press the [ENTER] key or the [SPACE] key: the caption becomes editable.
3.Type the new caption and validate.
Validate the description window of the control (green button). The new control caption
appears in the window editor.
We are going to display a message in a dialog box (a small window proposed by the system).
To do so, we will be using our first WLanguage function: Info.
The programming language supplied with WINDEV Mobile is named WLanguage.
Notes
The code editor proposes different processes for each type of control. These
processes correspond to the events linked to the control.
Therefore, two processes are displayed for the "Button" control:
Notes
4.Type the following code in the Click process of the BTN_Display control:
Info("Hello")
Note about the assisted input: As soon as the first two characters are typed, WINDEV Mobile
proposes all the words of the WLanguage vocabulary containing these characters. The assisted
development is a very powerful feature. No more mistake when typing the name of an element:
the syntax errors are reduced. All you have to do is select the requested word and validate by
pressing [ENTER]. You can focus on the algorithm.
First test
For a Universal Windows 10 application, WINDEV Mobile allows you to run the application test on
the development computer via the simulation mode. This test simulates a Universal Windows 10
device on the development computer.
Let's now run the window test in simulation mode.
1.Click among the quick access buttons (or press [F9]).
2.Validate (if necessary) the information message regarding the simulator mode.
3.Choose (if necessary) the management mode of the editor during the test (editor minimized
or not).
4.The created window is started in execution.
5.Click the "Display" button.
6.Validate the system window that is displayed.
Principle
A Universal Windows 10 application can be directly run on the development computer if the
system used is Windows 10. To run the application in stand-alone mode on the
development computer, you must:
Generate the Universal Windows 10 application in WINDEV Mobile.
Then, the program will be installed on the computer. It will run in stand-alone mode.
Let's take a look at these different steps.
See the online help for more details about the different deployment modes of a
Universal Windows 10 application
Window orientation
In Universal Windows 10, a window can have one of the following orientations:
Free: the window follows the orientation of the device,
Locked in portrait mode,
Locked in landscape mode.
This orientation is defined in the "GUI" tab of the description window of the window ("Description"
from the popup menu of the window).
Practical example
Open (if necessary) the "My_AWP_Project" project that was created in the previous lesson.
Answer
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My AWP project (Answer)".
In our example, the project was created for a phone and its test was run in portrait mode in the
simulator.
We are now going to run its test in landscape mode in the simulator.
Run the project test ( among the quick access buttons).
1.The window is displayed in portrait mode.
2.In the simulator, click the menu in the shell ( ).
3.A popup menu is displayed. Modify the window orientation with the "Rotation" option.
4.The window orientation changes on the screen. In our example, the button location does not
change: it does not adapt to the screen orientation.
We are now going to modify our window in order for the "Display" button to be centered in the
window and to remain centered regardless of the device orientation.
Stop the test and go back to the editor.
In the window displayed in the editor, you will notice the little red arrows in the
control. These arrows indicate that the control is anchored.
Available databases
Synchronization
Overview
In the Universal Windows 10 applications, only the HFSQL database is accessible in native mode.
Both the Classic mode and the Client/Server mode are available.
HFSQL database
HFSQL Classic
In HFSQL Classic mode, the data files are stored on the device.
In this case, the application is stand-alone. No Wi-Fi or 3G connection is required.
The data is stored in the device memory. The maximum storage size depends on the amount of
memory on the device.
HFSQL Client/Server
In HFSQL Client/Server mode, no data is stored on the device. The data is stored on a computer
on which a HFSQL server is installed.
To access this computer (and therefore the database), a method for communicating with the
server must have been enabled in the mobile application (Wi-Fi or 3G) in order to connect via the
network or Internet.
The response times depend on the quality of the WiFi or Internet network and on the volume of
requested data.
The access to the data will be performed by the Hxxx functions of WLanguage and/or by SQL
queries.
The synchronization
The synchronization mechanism is used to "synchronize" the data stored on a mobile device with
the data stored on a server. The synchronization uses the mechanism of "universal replication".
This technique is available in WINDEV, WEBDEV and WINDEV Mobile.
See the online help (keyword: "Replication") for more details.
Deployment
An application in tile mode can be deployed:
On the local computer directly. The procedure was presented in the previous chapters.
On a phone connected in USB or on a network phone, via the wizard for generating a Universal
Windows 10 application.
On a tablet. In this case, specific operations must be performed. The different steps are
presented in the online help (keywords: "Install, An application on a tablet"). If you own a tablet,
we have the ability to perform this setup.
Via Windows Store. This method is the standard distribution mode of an application in tile
mode. The wizard for generating a Universal Windows 10 application allows you to generate the
application for a deployment via Windows store.
Windows
Mobile
application
196 Part 7: Windows Mobile application
Lesson 7.1. My first Windows
Mobile project
Estimated time: 1 h
My first project
A corrected project is available. To open this project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "My Pocket project (Answer)".
The wizard for project creation starts. The different wizard steps help you create your project.
The information specified in this wizard can be modified later.
1.Click among the quick access buttons in the menu of WINDEV Mobile.
2.The window for creating a new element is displayed: click "Project".
4.Go to the next step via the arrows found at the bottom.
5.The wizard proposes to add documents. Keep the default options and go to the next step.
6.The next step is used to detect the parameters of the device connected to the PC.
If your device is connected, click "Click here to automatically detect the device".
If no device is connected, go to the next step to manually define the characteristics of the
device used.
7.If you have no device, the next wizard step allows you to choose the device that will be used
to develop your application.
Caution: this step is important because the size of your windows will depend on this choice.
For our example, select "Windows Mobile 5/6". Go to the next step.
Overview
The first window allows the user to display a welcome message via the "Display" button.
You may think this is too basic but we advise you to create this window. You may be surprised by
how intuitive and how easy it is to use the editor of WINDEV Mobile. Furthermore, this window will
allow you to discover concepts that are fundamental for the rest of this tutorial and to see the
entire process for developing a Windows Mobile application with WINDEV Mobile.
As a new project was created, the window for creating a new element is
automatically displayed.
To display the window for creating a new element, all you have to do is click
among the quick access buttons of WINDEV Mobile:
Note
The skin templates allow you to quickly create outstanding interfaces. A skin
Note
template defines the style of the window as well as the style of all controls that
will be used in this window. No ugly interface anymore.
4.Validate. The window is automatically created in the editor. The backup window of the
created element is displayed. This window displays:
the title of the element. For a window, this title will be displayed in the title bar of the window.
the name of the element that corresponds to the window name. This name will be used in
programming.
the location of the element. This location corresponds to the backup directory of the physical
file corresponding to the element. The window is a "WDW" file, saved in the project directory.
Let's take a look at the window name proposed by WINDEV Mobile: this name
starts with the letters "WIN_". This prefix is automatically added because the
project is using a programming charter.
The programming charter is used to define a prefix for each type of object,
allowing you to quickly identify the element:
Note
Displaying a message
You are now going to create a button used to display a message.
To create the "Display" button:
1.On the "Creation" pane, in the "Usual controls" group, click . The button appears in
creation under the mouse.
2.Move the mouse toward the position where the control will be created in the window (at the
top of the window for example). To drop the control in the window, all you have to do is perform
a new left mouse click.
3.Perform a right mouse click on the control that was just created. The popup menu of the
control is displayed. Select "Description" from this popup menu. The description window of the
button is displayed.
When typing this code in the code editor, you have noticed that different colors
are used by the different elements. This is the syntactic coloring. The code editor
allows you to easily identify the different elements handled by the code:
the WLanguage functions are colored in blue,
Notes
Any developer knows that running a program test can be a long and tiresome job. In WINDEV
Mobile, a SINGLE CLICK allows you to run the test of the window, report or procedure while
you are creating it. This is both simple and fast!
Click the "x" button found in the simulator shell to close the window.
The editor of WINDEV Mobile is redisplayed.
Principle
To run the application in stand-alone mode on the mobile device, you must:
Connect the device via a USB port.
Generate the application.
Choose to copy and start the executable on the connected mobile. Copying the application can
take several seconds.
Implementation
The executable icon can be chosen in the image catalog of WINDEV Mobile ("Catalog" button).
As soon as an image can be used (in a control, in a window, in a report, ...), the
"Catalog" button is displayed in the description window of the control. This button
allows you to select an image among the images supplied in the image catalog of
WINDEV, WEBDEV and WINDEV Mobile.
Notes
5.The other steps are not required by our application. Click the "2- Copy onto the mobile" link
found on the left of the wizard.
Available databases
Synchronization
HFSQL database
HFSQL Classic
In HFSQL Classic mode, the data files are stored on the device (iPhone or iPad).
In this case, the application is stand-alone. No Wi-Fi or 3G connection is required.
The data is stored in the device memory. The maximum storage size depends on the amount of
memory on the device.
HFSQL Client/Server
In HFSQL Client/Server mode, no data is stored on the device. The data is stored on a computer
on which a HFSQL server is installed.
To access this computer (and therefore the database), a method for communicating with the
server must have been enabled in the mobile application (Wi-Fi or 3G) in order to connect via the
network or Internet.
The response times depend on the quality of the Wi-Fi or Internet network and on the amount of
requested data.
The access to the data will be performed by the Hxxx functions of WLanguage and/or by SQL
queries.
The "Pocket Notes" and "Pocket Telephony" examples (supplied with WINDEV
Example
During the test (in simulation mode) of a WINDEV Mobile application that handles
HFSQL data files, the data files used are the ones found on the PC.
The CDB databases can be accessed from the PC, from the simulator, from the
mobile device.
The standard databases can be accessed from the mobile device only.
Caution: The structure of the CEDB databases is not intended to process a large
Notes
During the test (in simulation mode) of a WINDEV Mobile application that handles
a CEDB database, the database used is found on the Pocket PC.
AS/400
This database format is accessible via a Native Access by the Windows Mobile applications. To
use this Native Access, an additional module is required in addition to WINDEV Mobile.
Contact PC SOFT Sales Department for more details.
For example: application for taking orders in a restaurant. The new orders are automatically
sent to the database found on the PC.
Copying the data files onto the mobile device:
All the data files (or some of them) are copied onto each mobile device beforehand (Pocket
PC for example). Each application handles its own files. To take into account the
modifications performed in each application, the data files must be synchronized
(automatically or not).
Windows PC Mobile Device
File 1
File 1
File 3
File 2
File 2
For example: application for opinion survey in the street. The answers will be available in
the WINDEV application once the data files have been synchronized.
The "Network tasks" example (supplied with WINDEV Mobile) includes a project
that can be used on a Windows Mobile device (Pocket Network tasks) and a
project that can be used on PC (PC Network tasks). These two examples handle
the data files found on the PC.
Copying the data files onto the mobile device (Pocket PC for example)
To update the data files found on the PC with the data entered on the mobile devices, all you have
to do is synchronize the files.
If the data files used are in HFSQL format, all the mobile devices must be connected one by one to
the PC. The automatic HFSQL synchronization via ActiveSync takes everything in charge.
If the data files used are not in HFSQL format, you must program the synchronization between the
WINDEV Mobile application and the WINDEV application. See the examples supplied with WINDEV
Mobile for more details.
Databases in HFSQL format (on the mobile device and on the PC)
Example
Estimated time: 1 h
Start WINDEV Mobile 22 (if not already done). Close (if necessary) the current project in order
to display the home window.
Open the "Pocket Managing Products" project.
To do so, in the home window, click "Tutorial" and select the "Pocket Managing Products
(Exercise)" project.
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "Pocket Managing Products (Exercise)".
A corrected project is available. This project contains the different windows cre-
Answer
ated in this lesson. To open the corrected project, on the "Home" pane, in the
"Online help" group, expand "Tutorial" and select "Pocket Managing Products (An-
swer)".
7.Keep the "Name", "Description" and "Price" items (a checkmark must be found in front of
these items). Go to the next screen.
8.Keep the proposed sort item (ProductID). The products will be sorted in the Table control
according to this item. Go to the next screen.
9.In the "Additional parameters" screen, keep the default options. Go to the next screen.
10.Select the "Vertical" orientation and go to the next screen.
11.Keep the default name ("TABLE_Product") and validate.
12.The Table control appears in the window editor.
13.Resize the control and its columns via the handles in order for the content to be displayed
in the window.
4.Resize the controls ("Name", "BarCode", "Reorder Date" and "Description") so that they are
visible in the window:
Select the requested control.
Use the sizing handles (blue squares) to modify the size of the control.
Respect the following order: "Photo", "Name", "Price", "Quantity", "BarCode", "Reorder Date",
"Description".
6.We are going to view the navigation order in the window: press the [F5] key. The numbers
that are displayed represent the navigation order in the window. Press [F5] again in order for
the numbers to disappear. The navigation order is automatically adapted to the order of the
controls in the window.
7.Save the window.
Run the window test ( among the quick access buttons). The window is displayed with
empty controls.
Close the test window to go back to the editor.
To display the product data:
1.Display the processes associated with the window:
Perform a right mouse click in the area beside the window
Select "Code" from the popup menu that is displayed.
The code editor appears.
2.Type the following code in the "End of initialization of WIN_Product_form" process:
FileToScreen()
FileToScreen is used to display in the controls the data found in the data file, for the current re-
cord.
3.Close the code window (click the cross in the top right corner of the code editor).
4.Save the window.
2.On the "Creation" pane, in the "Usual controls" group, click : the shape of the button
appears under the mouse. Then, click at the bottom of the window to create the button.
3.Select the control and press the [ENTER] key on the keyboard. The caption of the button
becomes editable. Type "Modify the element" and press [ENTER]on the keyboard.
4.Resize the button if necessary (with the handles) in order for the caption to be entirely dis-
played in the button.
5.Right-click the button and select "Code" from the popup menu.
6.In the code window that is displayed, type the following code in the "Click" process:
Open(WIN_Product_form)
TableDisplay(TABLE_Product,taCurrentSelection)
The assisted code input is going to help you: as soon as you type the opening
bracket "(", a drop-down list proposes the name of all the existing windows found
in the project. All you have to do is select the window with the keyboard or with
Notes
the mouse.
If the window name is not displayed in the list, it means that this window was not
saved beforehand.
In the applications for Windows Mobile, the use of a "Cancel" button is not re-
Notes
quired. Indeed, the user can just click the cross (top right of the window) to can-
cel the input performed.
4.Resize the button if necessary (with the handles) in order for the caption to be entirely dis-
played in the button.
We are now going to type the code of the "Validate" button.
1.Right-click the button and select "Code" from the popup menu.
2.In the "Click" process, enter the following code:
ScreenToFile()
HModify(Product)
Close()
HReset initializes the variables of the items found in the Product file with the default values to
manage a new record.
Open is used to open the form window.
TableDisplay is used to update the content of the Table control: the new record will be displayed
in the control.Save the modifications by clicking among the quick access buttons.
5.Close the code window (click the cross in the top right corner of the code editor).
We are now going to modify the window of the product form to manage the addition of a new
record.
1.Display the "WIN_Product_form" window in the editor.
2.We are going to modify the code of the validation button:
Right-click the button and select "Code" from the popup menu.
The test code of the new record can be replaced by HSave. This function is used
to check whether the record is already found in the data file, and it allows you to
Notes
8.Right-click the new option and select "Add before" from the popup menu.
9.In the input area that is displayed, type "Exit" and validate.
Close is used to close the current window. The "Menu" window being the only window, the appli-
cation is automatically closed.
To define the WLanguage code of the "List of products" option:
1.In the window editor, display the "List of products" option. All you have to do is expand the
menu, just like you did at run time.
2.Display the popup menu of the "List of products" option (right mouse click) and select
"Code".
Caution: The setup of a Windows Mobile application can be created with a 32-bit WINDEV Mobile
editor only.
6.For our example, we are going to choose a setup by ActiveSync: check the corresponding
option and go to the next screen.
7.The wizard asks for the setup directory of the application. Keep the default option. Go to the
next screen.
8.Specify the files to install. The wizard proposes the executable. You also have to install the
data files of the application. Click the "Add" button and select the HFSQL files (.fic, .ndx and
.mmo files) found in the EXE directory of your project.
Initial setup
This setup consists in:
creating the executable of the application on the development computer via WINDEV Mobile.
generating the setup program of the application on the development computer via WINDEV Mo-
bile. This program corresponds to a ".MSI" file.
distributing this setup program to the end users.
running this setup program on the PCs. The application will be automatically installed on the
mobile device connected to the current computer, via ActiveSync.
Note: If no mobile device is connected, the setup will be performed during the next synchroniza-
tion between the PC and the mobile device.
To use this application, start the application on the mobile device (double-click the ".EXE" file for
example).
Initial setup
This setup consists in:
creating the executable of the application on the development computer via WINDEV Mobile.
generating the setup program of the application on the development computer via WINDEV Mo-
bile. This setup program corresponds to a ".CAB" file.
copying this setup program onto the mobile devices of the end users (via a memory card, by
GPRS from an Internet site or via the file explorer).
running this setup program on the mobile devices. This program installs all the files required by
the application. At the end of setup, the ".CAB" file is automatically deleted from the device.
To use this application, start the application on the mobile device (double-click the ".EXE" file for
example).
This course has discussed a variety of subjects, but not all the features of WINDEV Mobile, far
from it !
You are now familiar with the main concepts.
We recommend that you spend another day exploring the menu options of WINDEV Mobile, for
each one of the modules.
You can also explore the examples supplied with WINDEV Mobile: some are simple and only
address one topic, while others are more complex. These examples will show you the different
aspects of WINDEV Mobile as well as the development for the different platforms. Reading the
source code is also a good way to learn.
It would take too much time to discuss all the available topics (there are hundreds, even thou-
sands !). WINDEV Mobile proposes several features that were not presented in this tutorial:
sockets and HTTP functions...
queries, queries with parameters, ...
printing, ...
Reminder: To directly receive intermediate updates and tips, don't forget to subscribe to the LST
(quarterly technical magazine + DVD), in French.
Conclusion 233
234 Conclusion