Tutorial Windev Mobile 21

Download as pdf or txt
Download as pdf or txt
You are on page 1of 216

WINDEV Mobile 21

Documentation version 21 - 1 - 0416

Don't forget to visit our site (www.windev.com) on a regular basis to find out whether upgraded
versions are available.

Email address of Free Technical Support: [email protected]

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 2016: 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...................................................................................................................................................11
Overview of the tutorial...........................................................................................................................................11
How to access the online help?............................................................................................................................. 12
Legend of symbols..................................................................................................................................................15
If you are familiar with WINDEV Mobile 20...........................................................................................................15
What is WINDEV Mobile used for?.........................................................................................................................15

PART 1 - Overview of WINDEV Mobile


Lesson 1.1. Discover WINDEV Mobile
Overview...................................................................................................................................................................20
Starting WINDEV Mobile.........................................................................................................................................20
Development environment.....................................................................................................................................21
The editor.................................................................................................................................................. 21
The menu bar (ribbon) in details.............................................................................................................. 22

PART 2 - Android application


Lesson 2.1. My first Android project
Overview...................................................................................................................................................................28
Necessary configuration for Android.....................................................................................................................28
My first project.........................................................................................................................................................28
Creating the project.................................................................................................................................. 28
My first window........................................................................................................................................................32
Overview................................................................................................................................................... 32
Creating the window................................................................................................................................. 32
Display a message................................................................................................................................... 33
First test....................................................................................................................................................................35
First deployment on the device..............................................................................................................................36
Principle.................................................................................................................................................... 36
Implementation........................................................................................................................................ 37

Lesson 2.2. Interface (GUI)


Overview...................................................................................................................................................................42
Choosing the resolution according to the device..................................................................................................42
Orientation of the window.......................................................................................................................................42
Practical example..................................................................................................................................... 43
Management of touchscreen.................................................................................................................................45
Practical example..................................................................................................................................... 45
The different types of controls................................................................................................................................47

Summary 3

Lesson 2.3. Distributing the application


Overview...................................................................................................................................................................49
Deployment via Android Market/Google Play......................................................................................................49
Deployment via a Web server.................................................................................................................................49
Deployment from the PC via ADB (advanced mode)............................................................................................50
Copying the application onto the Mobile device...................................................................................................50

PART 3 - iOS application


Lesson 3.1. My first iOS project
Overview...................................................................................................................................................................54
Required configuration for iOS...............................................................................................................................54
My first project.........................................................................................................................................................55
Create the project..................................................................................................................................... 55
My first window........................................................................................................................................................58
Overview................................................................................................................................................... 58
Creating the window................................................................................................................................. 58
Display a message................................................................................................................................... 59
First test....................................................................................................................................................................61
First deployment on the device..............................................................................................................................62
Principle.................................................................................................................................................... 62
Implementation........................................................................................................................................ 62
Transfer the WINDEV Mobile project onto Mac....................................................................................... 64
Compile the project in Xcode................................................................................................................... 64

Lesson 3.2. Interface (GUI)


Overview...................................................................................................................................................................66
Choosing the resolution according to the device..................................................................................................66
Orientation of the window.......................................................................................................................................66
Practical example..................................................................................................................................... 67
Management of touchscreen.................................................................................................................................69
Practical example..................................................................................................................................... 70
The different types of controls................................................................................................................................71

Lesson 3.3. Distributing the application


Overview...................................................................................................................................................................73
Deployment..............................................................................................................................................................73

Summary

PART 4 - Programming concepts


Lesson 4.1. Concepts and terminology
Overview...................................................................................................................................................................78
Main concepts..........................................................................................................................................................78
Terminology.............................................................................................................................................. 79

Lesson 4.2. Programming concepts


Introduction..............................................................................................................................................................81
Declaring the different types of variables.............................................................................................................81
The different types of variables............................................................................................................... 81
Declaring the variables and their scope................................................................................................. 82
Main statements of WLanguage............................................................................................................................82
Conditional statements........................................................................................................................... 83
Loop statements...................................................................................................................................... 83
Comments................................................................................................................................................ 84
Main WLanguage operators...................................................................................................................................84
The logical operators................................................................................................................................ 84
The comparison operators....................................................................................................................... 85
Procedures and functions.......................................................................................................................................85
Definition.................................................................................................................................................. 85
Local procedure........................................................................................................................................ 85
Global procedure and set of procedures................................................................................................. 85
How to decide whether a procedure is global or local?.......................................................................... 86
About passing parameters...................................................................................................................... 86
Calling a procedure.................................................................................................................................. 86
Creating a procedure............................................................................................................................... 87
Processing strings...................................................................................................................................................88
Main operations performed on a character string................................................................................. 88
Processing numeric values.....................................................................................................................................90
Main operations performed on the numeric values............................................................................... 90
Processing currencies.............................................................................................................................................92
Details....................................................................................................................................................... 92

Summary 5

PART 5 - Android and iOS: Developing an application


Lesson 5.1. Overview
Overview...................................................................................................................................................................98
The sample project used.........................................................................................................................................99
Opening the project................................................................................................................................ 101
Choosing the platform............................................................................................................................ 101
Enabling the iOS platform.................................................................................................................................... 101

Lesson 5.2. Developing the application


Project analysis.................................................................................................................................................... 105
Display the list of products................................................................................................................................... 105
Creating the window...............................................................................................................................106
Creating the form window.................................................................................................................................... 110
Creating the window...............................................................................................................................110
Creating the controls..............................................................................................................................111
Displaying the form from the list of products........................................................................................113
Managing the creation and the modification of a product............................................................................... 114
Modifying the product form...................................................................................................................114
Creating a new product..........................................................................................................................119
Using the camera and displaying an image....................................................................................................... 122
Overview.................................................................................................................................................122
Creating the button for taking photos...................................................................................................122
Taking photos.........................................................................................................................................123
Selecting a photo in the photo album...................................................................................................123
Managing the bar code of the product................................................................................................................ 124
Overview.................................................................................................................................................124
Implementation......................................................................................................................................124
Managing anchors in the Product form.............................................................................................................. 125
Using the Map control.......................................................................................................................................... 127
Creating the window...............................................................................................................................127
Creating the Map control.......................................................................................................................128
Displaying the stores on the map..........................................................................................................128
Using a Multiline Zone control............................................................................................................................. 129
Creating the window...............................................................................................................................130
Creating the Multiline Zone control.......................................................................................................130
Modifying the Multiline Zone control..................................................................................................... 131
Programming the menu.........................................................................................................................133
Test of the application.......................................................................................................................................... 134

Summary

Lesson 5.3. Managing the orientation of windows with the layouts


Overview................................................................................................................................................................ 136
Using anchors....................................................................................................................................................... 137
Running the test of the application..................................................................................................................... 143

Lesson 5.4. Window with search


Overview................................................................................................................................................................ 145
Creating the query used to find the products..................................................................................................... 146
Creating the query..................................................................................................................................146
Test of the query.....................................................................................................................................148
Adding a selection condition.................................................................................................................148
Test of the query with parameters.........................................................................................................150
Creating the interface.......................................................................................................................................... 151
Creating the window............................................................................................................................... 151
Managing the search.............................................................................................................................153
Improving the window.......................................................................................................................................... 155
Managing the "Pull to refresh" feature..................................................................................................155
Using a sliding menu..............................................................................................................................157

Lesson 5.5. Window with scroll


Overview................................................................................................................................................................ 162
Creating the Form window with swipe................................................................................................................ 162
Creating the Form window.....................................................................................................................162
Creating the internal window.................................................................................................................163
Managing the swipe in the form window...............................................................................................163
Test of the window................................................................................................................................................ 166
Conclusion............................................................................................................................................................. 167

Lesson 5.6. Deploy the application


Overview................................................................................................................................................................ 169
Generating the Android application.................................................................................................................... 169
Generating the iOS application........................................................................................................................... 173
Transfer the WINDEV Mobile project onto Mac..................................................................................... 175
Compile the project in Xcode................................................................................................................. 176

Summary 7

PART 6 - Windows Mobile application


Lesson 6.1. My first Windows Mobile project
Overview................................................................................................................................................................ 180
My first project...................................................................................................................................................... 180
Create the project...................................................................................................................................180
My first window..................................................................................................................................................... 183
Overview.................................................................................................................................................183
Creating the window...............................................................................................................................183
Display a message.................................................................................................................................184
First test................................................................................................................................................................. 186
First deployment on the device........................................................................................................................... 187
Principle..................................................................................................................................................187
Implementation......................................................................................................................................187

Lesson 6.2. Databases


Format of the databases...................................................................................................................................... 190
HFSQL database....................................................................................................................................190
CEDB.......................................................................................................................................................191
AS/400...................................................................................................................................................191
Sharing data between two applications............................................................................................................. 192
Handling the same data files.................................................................................................................193
Copying the data files onto the mobile device (Pocket PC for example)..............................................193

Lesson 6.3. Advanced programming


Overview................................................................................................................................................................ 195
Opening the project................................................................................................................................195
Project description.................................................................................................................................195
Display the list of products................................................................................................................................... 196
Creating the window...............................................................................................................................196
Creating the Table control......................................................................................................................196
Creating the form window.................................................................................................................................... 198
Creating the window...............................................................................................................................198
Creating the controls..............................................................................................................................199
Displaying the form from the list of products........................................................................................201
Managing the creation and the modification of a product............................................................................... 202
Modifying the product form...................................................................................................................202
Creating a new product..........................................................................................................................203
Creating a menu window..................................................................................................................................... 205
Creating the window...............................................................................................................................205
Customizing the menu...........................................................................................................................206
Programming the menu.........................................................................................................................207
Running the test of the application..................................................................................................................... 208
Creating the executable....................................................................................................................................... 208

Summary

Lesson 6.4. Distributing the application


Overview................................................................................................................................................................ 211
Setup in MSI format............................................................................................................................................. 212
Initial setup.............................................................................................................................................212
Update in MSI format.............................................................................................................................213
Setup in CAB format............................................................................................................................................. 213
Initial setup.............................................................................................................................................213
Update in CAB format............................................................................................................................. 214

Conclusion

Summary 9

10

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.

Overview of the tutorial

Notes

The tutorial was intended to help you develop on the main mobile platforms:
Android.
iOS (iPhone/iPad).
Windows Mobile/CE.
This tutorial includes the following parts:
Part 1: Overview of WINDEV Mobile.
Part 2: Creating and deploying a first Android application.
Part 3: Creating and deploying a first iOS application.
Part 4: Quick reminder of the main concepts of WINDEV Mobile and WLanguage.
Part 5: Creating an application for data management for Android and iOS. This part is common
to Android and iOS and it allows you de create management windows for these two platforms.
Part 6: Creating applications for Windows Mobile.

WINDEV Mobile can also be used to develop Windows Universal apps applications
(that operate in Windows 10: Windows 10 tablets and PCs running Windows 10).
See the online help for more details.

Introduction 11

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...

Tip

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
menu of WINDEV Mobile: on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "Tutorial (PDF)".

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.

12

Introduction

The help can be displayed:

in an Internet browser, if you have access to Internet:

in a specific "help browser":

Introduction 13

Notes

The online help of WINDEV, WEBDEV and WINDEV Mobile on Internet is available
from any computer equipped with an Internet access, without the product being
necessarily installed. This help is updated on a regular basis.
Each Web user can add comments about the documentation pages: personal
notes, examples, links and so on.

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.

the content of the help: help common to WINDEV, WEBDEV and WINDEV Mobile or help
about the product currently used.

14

Introduction

Legend of symbols

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.

If you are familiar with WINDEV Mobile 20...


If you are familiar with WINDEV Mobile 20, following this tutorial will do no harm: it's a good
opportunity to "review" the features of WINDEV Mobile!

What is WINDEV Mobile used for?


WINDEV Mobile is an IDE (Integrated Development Environment). It allow you to develop
applications in many fields:
Management of stocks
Inventories, tracking of goods
Adjustment and monitoring of machines on an assembly line
Taking orders for fast processing in a temporary outlet (fairs, schools, booth, ...)
Customer forms
Help with making snap decisions on a cell phone
Checking the identity of visitors at an event: trade fair, presentation of products,...
On-call doctors or vets
Taking information in a temporary outlet: trade fair, street poll, stadium,...
Returning leased heavy equipment (tools, vehicles, ...) to a parking lot
...
WINDEV Mobile is a development environment that includes all the tools required to develop an
application.

Introduction 15

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!

16

: 
Introduction

PART 1
Overview of
WINDEV Mobile

18

Part 1: Overview of WINDEV Mobile

Lesson 1.1. Discover WINDEV Mobile


This lesson will teach you the following concepts...
Starting WINDEV Mobile

Estimated time: 10 min

Part 1: Overview of WINDEV Mobile 19

Overview
WINDEV Mobile is an IDE (Integrated Development Environment) allowing you to develop
applications for Android, iOS, Windows Phone, Windows Mobile, .... in a wide variety of fields:
business, industrial, medical, hospitality, ... The developed applications can give access to
information stored in the databases.
This tutorial will explain how to create your applications (with or without database) and how to
improve them by using the different features proposed by WINDEV Mobile.

Starting WINDEV Mobile

Start WINDEV Mobile 21 (if not already done).


If WINDEV Mobile 21 was never started before, a welcome wizard is displayed. This wizard is
used to:
If you own an earlier version of WINDEV Mobile, retrieve the existing configurations.
If you are a new user, configure your environment. See the online help for more details.

If WINDEV Mobile 21 was already started, identify yourself il necessary. The development
environment is started. The home window is displayed. This home window is used to:
create a project,
open an existing project,
open an example,
open one of the projects found in the tutorial.

Let's take a look at the development environment of WINDEV Mobile. To do so, from the home
window:
Click "Tutorial".
Click "iOS/Android application (Answer)".
The corresponding project is opened in the editor.

20

Part 1: Overview of WINDEV Mobile

Development environment
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.

Part 1: Overview of WINDEV Mobile 21

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 menu bar (ribbon) in details
The menu bar of WINDEV Mobile is presented in the shape of a ribbon. This ribbon includes panes
in which the options of the editors are grouped.
We are going to take a closer look at the main elements of the ribbon, as well as how we will be
using it in this tutorial.

The different ribbon elements


The ribbon includes 3 areas:
the button area, on the left (1).
the pane area, at the top (2).
the option area (3).
Let's take a closer look at these areas.
The button area
The button area groups the quick access buttons. These buttons are used
to perform the most usual operations, common to all the editors: save,
open, create, ...
The 3 logos found at the top of this area are specific:
The product logo is used to display the "About" window, the custom
menus and the drop-down menus found in the former interface of the
editors (version 17 and earlier).
The 2 other logos are used to restore the toolbars and the drop-down
menus found in the former interface of the editors (version 17 and earlier).

22

Part 1: Overview of WINDEV Mobile

The pane area

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 name of the current pane is displayed on a white background and an
orange line is displayed above the name.
the popup panes, specific to the current element: The name of the pane is displayed in orange.
the available panes: The name of the pane is displayed in white.
The option area

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 either 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".

Part 1: Overview of WINDEV Mobile 23

24

Part 1: Overview of WINDEV Mobile

PART 2
Android
application

26

Part 2: Android application

Lesson 2.1. My

first

Android

project

This lesson will teach you the following concepts...


Required configuration
Creating an Android project
My first window
My first test
First deployment

Estimated time: 1 h

Part 2: Android application 27

Overview
To start working with WINDEV Mobile, we are going to create a first project. This project will contain
a window used to display a message.
This first example will present the main concepts of development with WINDEV Mobile.
Before creating our first project for Android, a configuration of the development computer is
required.

Necessary configuration for Android


To develop an application for the Android platform, the following elements must be installed on
the development computer:
The JDK: The JDK (Java Development Kit) distributed by Oracle is used to compile the generated
Java files.
The Android SDK of Google: The Android SDK (Software Development Kit) is a set of files and
applications distributed by Google in order to allow the compilation of applications for the
Android operating system.
Caution: The Android SDK includes sections corresponding to the versions of device platforms
(2.2, 2.3, 4, ...).
Gradle tool: This tool is required to compile and to generate Android applications. Gradle can be
downloaded and installed if necessary when generating the Android application from WINDEV
Mobile.
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
Creating the project

Answer

We are now going to create our first project for Android.


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)".

To create a project:

1.Start WINDEV Mobile 21 (if not already done). Close (if necessary) the current project in order
to display the home window.

28

Part 2: Android application

2.In the home window, click "Create a project" then "Android application".

Notes

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.
Tip: Other method for creating a project:
1.Click
among the quick access buttons of the WINDEV Mobile menu.
2.The window for creating a new element is displayed: click "Project".

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.

Part 2: Android application 29

Note

7.The wizard proposes to choose the type of Android devices affected by the project:
Generate an application for phones and tablets.
Generate an application for phones only.
Generate an application for tablets only.
Generate an application for a specific device.
If the application is intended to operate on several Android devices (phones
with different sizes or resolutions for example), we advise you to use one of the
following options: "Generate an application for phones and tablets", "Generate
an application for phones only" or "Generate an application for tablets only".
In this case, WINDEV Mobile proposes the smallest resolution to create the
application windows. Using anchors (see page 43 and page 125) will allow the
application to operate on all the devices.

Note

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.

30

You own an Android device and you want to run the test of the created application
on this device? Select "Generate an application for a specific device". The wizard
next step is used to select the requested device.

Part 2: Android application

9.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.
10.This step is used to define the style book of the application. We will keep "Material Design
Blue Grey".

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.

Part 2: Android application 31

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 an Android application with WINDEV Mobile.
Creating the window

To create the window:

1.In the window for creating a new element, click "Window" then "Window".

Note

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 the WINDEV Mobile:

Note

2.The wizard for window creation starts.


3.Select "Blank" in the list of windows displayed on the left. In the list of skin templates found
on the right, the "Material Design Blue Grey" skin template that was selected when creating
the project is selected by default.
The skin templates allow you to quickly create outstanding interfaces. A skin
template defines the style of the window but also the style of all the controls that
will be used in this window. No ugly interface anymore.

4.Validate. The window is automatically created in the editor.

32

Part 2: Android application

Save the window by clicking

among the quick access buttons. During the first backup, a


specific window is displayed. This window proposes to enter:

Note

the title of the element: enter "Welcome". In our case, this title will be displayed in the Action
Bar of the window.
the name of the element that corresponds to the name of the window. This name will be
used in programming. By default, this name includes "WIN_" that corresponds to the
programming charter and "Welcome" that corresponds to the title of the window.
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:
a window starts with "WIN_",
a button starts with "BTN_",
etc.
If you do not want to use this charter, all you have to do is disable it: on the
"Project" pane, in the "Other actions" group, expand "Charter" and uncheck "Use
the charter".

the location that corresponds to the file name created for the window. The window is a file
whose extension is "WDW", saved in the project directory.

Click the green button to validate the backup of the window.


Display 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 must 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.

Part 2: Android application 33

Modify the characteristics of the control by entering the following information:

Notes

1.Name of this control: "BTN_Display".


2.Caption of this control: "Display"
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
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).
Notes

To do so, we will be using our first WLanguage function: Info.

The programming language supplied with WINDEV Mobile is named WLanguage.


It is a 5th generation language (5GL) that includes highly sophisticated
commands.

Notes

1.Select the "Display" button with the mouse: all you have to do is click it.
2.Display the popup menu of the control (right mouse click).
3.Select "Code". This option opens the code editor of WINDEV Mobile, where all the
WLanguage statements can be entered.

34

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:
Initialization, run when displaying the window.
Click on the button, run when the user clicks the button.
Note: Additional processes can be added if necessary.

Part 2: Android application

4.Enter the following code in the "Click BTN_Display" process:


Info("Hello")

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,
the character strings (between quotes) are colored in purple,
the names of controls are colored in cyan.
These colors can be modified element by element in the code editor options
(on the "Home" pane, in the "Environment" group, expand "Options" and select
"Options of the code editor").

Info displays the message passed in parameter.

Save the modifications by clicking


[CTRL]+[S].

among the quick access buttons or by pressing

Close the code editor (cross at the top right of the code editor). The window editor is redisplayed.

First test

Notes

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
emulator (AVD) supplied with the SDK.
See the online help for more details.

Let's now run the test of the window in simulation mode.


among the quick access buttons (or press [F9]).
1.Click
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.

Part 2: Android application 35

5.Click the "Display" button.


6.Validate the system window that is displayed.

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.

36

Part 2: Android application

Implementation

To generate the Android application:

1.On the "Project" pane, in the "Generation" group, click "Generate" (you also have the ability to
click
among the quick access buttons).
2.WINDEV Mobile proposes to select the first project window. In our example, select "WIN_
Welcome" and validate (green button at the bottom of the screen).

3.The wizard for generating an Android application starts.


4.The first wizard step consists in checking the tools required to generate the Android
application.

The wizard proposes to:


download and install the Android SDK and Gradle: in this case, you will only have to validate
the license. WINDEV Mobile takes care of everything. If an update is available, the generation
wizard will automatically propose to perform the necessary updates. Only an Internet
connection is required.
Use the tools automatically installed. This option is available if the tools have been
downloaded and installed during a previous generation.
Specify the location of the tools already installed on your computer. In this case, all you
have to do is specify the setup paths of Gradle and Android SDK.
5.Select the option corresponding to your configuration and go to the next step.
Note: If you have chosen to download and install the tools, going to the next step may be quite
long and you may have to validate the license.

Part 2: Android application 37

6.The next wizard step is used to:


define the name of the application (displayed below the icon used to start the application)
and the corresponding package.
select the icon of the application in the image catalog of WINDEV Mobile.

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 tests of the application. 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 libraries used by the project.
Keep the default options.
13.Go to the next step. The wizard is used to define the permissions of the application.
By default, according to the WLanguage functions used in the application, WINDEV Mobile
detects the necessary permissions.
14.Go to the next step. You have the ability to restrict the download of the application on
Google Play store to the devices equipped with the features used. This possibility will not be
used in our example. Keep the default options.
15.Go to the next step. The wizard is used to configure the options of Android SDK. Keep the
default options.

38

Part 2: Android application

Notes

The generation of an Android application requires to install the Gradle


engine. If this engine is not installed on the current computer, this wizard
plane is used to download it and to install it.
See the online help for a manual setup.

16.Go to the next step. The wizard is used to specify whether the application must be copied
and run on the device connected to the computer or on an emulator.
If this option is checked, a new window is displayed at the end of generation. This window
allows you to select the runtime device.
That's it, our first application is generated and run on the Android device.

Part 2: Android application 39

Notes

To run the test of your application on the cell phone, select "GO - Run the project
test (mobile device)": the generation will be performed and the application will be
copied and run on the cell phone connected to the current computer.

40

Caution: The USB debugging must be enabled in order to run the tests on the
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.

Part 2: Android application

Lesson 2.2. Interface (GUI)


This lesson will teach you the following concepts...
Choosing the resolution according to the device
Orientation of the window
Management of touchscreen

Estimated time: 30 min

Part 2: Android application 41

Overview
The Android system is available on the phones and on the tablets. WINDEV Mobile allows you to
easily create interfaces that adapt to the device used.

Choosing the resolution according to the device


When creating a project, you will have to choose the resolution that will be used for the project
windows. Two cases may occur:
You are developing for a single target device: in this case, all you have to do is select this device
in the list proposed by the wizard.
You are developing for several target devices with different screen resolutions: in this case, you
must choose the smallest resolution common to all these devices. Via the anchoring of controls
in the window, the content will be adapted to the resolution.

Orientation of the window


In Android, a window can have one of the following orientations:
Locked in portrait mode,
Locked in landscape mode,
Free: the window follows the orientation of the device.
This orientation is defined in the "IHM" tab of the description window of the window ("Description"
from the popup menu of the window).

42

Part 2: Android application

No specific operation must be performed in the two first cases.


For a free window, the organization of controls and their size must adapt to the orientation. The
anchoring mechanism must be used to get a proper result.
Practical example

Answer

Open (if necessary) the "My_Android_Project" project that was created in the previous lesson.
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 appears. Change the orientation of the window with the Rotation option.

4.The orientation of the window changes on the screen. In our example, the location of the
button does not change: it does not adapt to the orientation of the screen.

Part 2: Android application 43

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).
3.Select "Anchor": the window for defining anchors is displayed:

Notes

4.Select "Horizontally centered" and validate (green button).


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.

Run the project test (

among the quick access buttons):


The button is centered in portrait mode.
Change the orientation of the simulator.
The button remains centered in landscape mode.

44

Part 2: Android application

Management of touchscreen
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 perform a zoom and/or to move in an image.
This allows you to perform a zoom on an image via the contact of 2 fingers moving apart.
To manage the "multi-touch", WINDEV Mobile proposes:
Specific options available in the Image control.
Specific WLanguage functions.
Specific optional processes.
See the online help for more details.
Practical example

Answer

Open (if necessary) the "My_Android_Project" project that was created in the previous lesson.
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 the "WIN_Welcome" window, create an Image control:

1.On the "Creation" pane, in the "Usual controls" group, click "Image".
2.The Image control appears in creation under the mouse.
3.Move the mouse in the window toward the position where the control must be created. To
drop the control in the window, all you have to do is perform a new left mouse click.
4.Double-click the Image control: the description window of the control is displayed.
5.In the "General" tab, select an image found on your disk in the "Image" edit control via the
file picker([...] button).
6.If the image is found in a directory other than the project directory, WINDEV Mobile proposes
to copy the image file into the project directory. Accept by clicking the "Copy the file into the
suggested directory" button.

Part 2: Android application 45

7.Display the "Details" tab: the options for managing the multi-touch are displayed:

Notes

8.Select "Automatic scroll and zoom".


9.Validate the description window of the control.
among the quick access buttons).
10.Save the window (click
11.A GUI error appears in the error pane: the automatic scrollbars of the window are in conflict
with the scroll features of the Image control.
12.To avoid this GUI error, disable the scrollbars of the window:
Display the description window of the window ("Description" from the popup menu).
In the "GUI" tab, uncheck "Automatic scrollbars".
Validate the description window.
among the quick access buttons). The GUI error disappears.
13.Save the window (click
Multi-touch support cannot be tested in the simulator. To check this feature,
you need to deploy the application on the mobile device.

14.Close the project.

46

Part 2: Android application

The different types of controls


WINDEV Mobile proposes several controls. These controls are used to display or enter data. Some
controls are specifically intended for a mobile interface.
To develop your applications, you can use the standard controls (edit controls, images, radio
buttons and check boxes) but also more specific controls such as:
the multiline zones to create GUI similar to the native Android windows,
the Map control to view a position on a map or an itinerary,
the Ad control to display an advertising banner,
the menu in the shape of "Action bar".
Some of these controls will be presented in the "Developing an Android and iOS application"
lesson.

Part 2: Android application 47

Lesson 2.3. Distributing

the

application
This lesson will teach you the following concepts...
Generating the APK
Available distribution modes

Estimated time: 20 min

48

Part 2: Android application

Overview
WINDEV Mobile allows you to develop applications for the Android operating system.
Once the applications are created, developed and checked, all you have to do is deploy them.
Several deployment modes are available:
Deployment via Android Market/Google Play (or another market).
Deployment on a Web server.
Deployment from the PC via ADB.
Deployment by copy.

Deployment via Android Market/Google Play


Google Play (formerly Android Market) is an online service used to download applications (free of
charge or not) on mobiles devices compatible with Android.
Once published, the application can be downloaded by the users all around the world via the
Google Play application installed on their phone.
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.

Deployment via a Web server


You have the ability to propose Android applications for download from a link on a Web page.
To do so, you must:
1.Copy the "apk" file of the application onto the Web server that hosts the page proposing the
download of the application.
Reminder: the "apk" file is created by WINDEV Mobile when generating the Android application.

Part 2: Android application 49

2.Add a link into the Web page for download. This link has the following format:
<a href='Path of apk file on the server'>Link</a>

3.On the server, add the following MIME type: application/vnd.android.package-archive


The user will only have to display the page with the browser of the phone. The application will be
downloaded when the link is clicked. Then, all you have to do is click the downloaded file (in the
download manager) to install the application.
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.

Deployment from the PC via ADB (advanced mode)


ADB (Android Debug Bridge) is a tool supplied with the Android SDK. It is used, among other
things, to install or uninstall from the PC an Android application (APK file) on a mobile device
compatible with Android.
This setup mode is an advanced mode. We recommend that you see in the online help the specific
commands used to install an application (http://developer.android.com/intl/fr/guide/developing/
tools/adb.html)
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.

Copying the application onto the Mobile device


The easiest way to install an Android application on a mobile device is to copy the apk file onto the
device and to run it. The following operations must be performed:
1.Connect the device to the PC by USB.
2.Copy the apk file of the application onto the device (external memory for example).
Reminder: the "apk" file is created by WINDEV Mobile when generating the Android
application.
3.On the device, use a file explorer to go to the directory where the apk file was copied and
click the file to start its setup.
Note: Some devices do not propose a file explorer but several ones are available for free.
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.

50

Part 2: Android application

PART 3
iOS
application

52

Part 3: iOS application

Lesson 3.1. My

first iOS project

This lesson will teach you the following concepts...


Required configuration
Creating an iOS project (iPhone or iPad)
My first window
My first test
First deployment

Estimated time: 40 min

Part 3: iOS application 53

Overview
To start working with WINDEV Mobile, we are going to create a first project. This project will contain
a window used to display a message.
This first example will present the main concepts of development with WINDEV Mobile.
Before creating our first project for iOS, a configuration of the development computer is required.

Required configuration for iOS


To develop a WINDEV Mobile application for iPhone/iPad, you must own:
1 PC,
1 Mac,
1 iPhone and/or iPad (optional).
Why a PC?

WINDEV Mobile 21 is a Windows application that can be used in Windows Vista, 10, ...
The application will be created on the PC before it is compiled on a Mac (project, analysis,
windows, ...).
This PC requires no setup of Mac/Apple tools.
Why a Mac?

A Mac is required because the project generated on the PC must be compiled in a specific compiler
to generate the iOS applications. The minimum version of the operating system must be version
10.8 (Mountain Lion).
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 recommended version of Xcode is version 5.
See the online help for more details (download addresses, ...).

54

Part 3: iOS application

My first project
Create the project

Answer

We are now going to create our first project for iOS.


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)".

To create a project:

1.Start WINDEV Mobile 21 (if not already done). Close (if necessary) the current project in order
to display the home window.
2.In the home window, click the "Create a project" icon then "iOS application".

Notes

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.

Tip: Other method for creating a project:


1.Click
among the quick access buttons of the WINDEV Mobile menu.
2.The window for creating a new element is displayed: click "Project".

Part 3: iOS application 55

4.The wizard proposes to enter the name of the project, its location and its description.

Note

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.
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.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.
If the application is intended to operate on several iOS devices (phones with
different sizes or with different resolutions for example), we advise you to use
one of the following options: "Generate an application for iPhone and iPad",
"Generate an application for iPhone only" or "Generate an application for iPad
only".
In this case, WINDEV Mobile proposes the smallest resolution to create the
application windows. Using anchors (see page 69 and page 125) will allow the
application to operate on all the devices.

8.For this example, select "Generate an application for iPhone only".

56

Part 3: iOS application

9.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 screen via the arrows found at the
bottom.
10.This step is used to define the style book of the application. We will choose "ActivePhone
7".

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.

Part 3: iOS application 57

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 an iOS application with WINDEV Mobile.
Creating the window

To create the window:

1.In the window for creating a new element, click "Window" then "Window".

Note

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 the WINDEV Mobile:

Note

2.The wizard for window creation starts.


3.Select "Blank" in the list of windows displayed on the left. In the list of skin templates found
on the right, the "ActivPhone 7" skin template is selected by default. You can choose another
skin template proposed in the list.
The skin templates allow you to quickly create outstanding interfaces. A skin
template defines the style of the window but also the style of all the controls that
will be used in this window. No ugly interface anymore.

4.Validate. The window is automatically created in the editor.

58

Part 3: iOS application

Save the window by clicking

among the quick access buttons. During the first backup, a


specific window is displayed. This window proposes to enter:

Note

the title of the element: enter "Welcome". In our case, this title will be displayed in the title
bar of the window.
the name of the element that corresponds to the name of the window. This name will be
used in programming. By default, this name includes "WIN_" that corresponds to the
programming charter and "Welcome" that corresponds to the title of the window.
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:
a window starts with "WIN_",
a button starts with "BTN_",
etc.
If you don't want to use this charter, all you have to do is disable it: on the
"Project" pane, in the "Other actions" group, expand "Charter" and uncheck "Use
the charter".

the location that corresponds to the file name created for the window. The window is a file
whose extension is "WDW", saved in the project directory.

Click the green button to validate the backup of the window.


Display 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 must 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.

Part 3: iOS application 59

Modify the characteristics of the control by entering the following information:

Notes

1.Name of this control: "BTN_Display".


2.Caption of this control: "Display".
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
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 control appears in the
window editor.

We are going to display a message in a dialog box (a small window proposed by the system).
Notes

To do so, we will be using our first WLanguage function: Info.

The programming language supplied with WINDEV Mobile is named WLanguage.


It is a 5th generation language (5GL) that includes highly sophisticated
commands.

Notes

1.Select the "Display" button with the mouse: all you have to do is click it.
2.Display the popup menu of the control (right mouse click).
3.Select "Code". This option opens the code editor of WINDEV Mobile, where all the
WLanguage statements can be entered.

60

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:
Initialization, run when displaying the window.
Click the button, run when the user clicks the button.
Note: Additional processes can be added if necessary.

Part 3: iOS application

4.Enter the following code in the "Click BTN_Display" process:


Info("Hello")

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,
the character strings (between quotes) are colored in purple,
the names of controls are colored in cyan.
These colors can be modified element by element in the code editor options
(on the "Home" pane, in the "Environment" group, expand "Options" and select
"Options of the code editor").

Info displays the message passed in parameter.

Save the modifications by clicking


or by pressing [CTRL]+[S].

among the quick access buttons (on the left of ribbon)

Close the code editor (cross at the top right of the code editor). The window re-appears.
First test
For an iOS application, WINDEV Mobile allows you to run the test of the application on the
development computer via the simulation mode. This test simulates an iOS device on the
development computer. This test is useful when the developer has no Mac device to compile the
application. However, this test does not allow you to use the hardware components of the device
(GPS, SMS, camera, ...).

Let's now run the test of the window in simulation mode.

among the quick access buttons (or press [F9]).


1.Click
2.Validate (if necessary) the information message regarding the simulator mode.
3.The created window is started in execution, in a shell corresponding to the selected device
(iPad or iPhone).
4.Click the "Display" button.
5.Validate the system window that is displayed.

Part 3: iOS application 61

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 device, you must:
Generate the iOS application (or Xcode project) in WINDEV Mobile.
Transfer the generated Xcode project onto the Mac in order to compile it.
Connect your device to your Mac and compile the Xcode project in order to generate the program
for the connected device.
Then, the program will be installed on the device. It will run in stand-alone mode.
Let's take a look at these different steps.
Implementation

To generate the iOS application:

1.On the "Project" pane, in the "Generation" group, click "Generate" (you also have the ability to
among the quick access buttons).
click
2.WINDEV Mobile proposes to select the first project window. In our example, select the "WIN_
Welcome" window and validate (green button at the bottom of the screen).

62

Part 3: iOS application

3.The wizard for generating an iPhone/iPad application starts.

Notes

4.The first wizard step is used to:


define the name of the application, the company and the copyright.
enter the bundle identifier.
This identifier is the unique identifier of your application beside Apple. It is
defined and saved on the Apple developer account.
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 standards of Apple. This identifier can be modified.

5.Go to the next step. Specify the path of the different icons found in the application. Several
icons must be supplied:
icons for iPad and iPad Retina,
icons for all the models of iPhone (the iPhone 4 has a different resolution with the Retina
screen).
6.Go to the next step. Specify the path of the different images used when starting the
application for iPad and for iPhone (images in PNG format). Default images are automatically
created for your application.
7.Go to the next step. Specify the version number of the generated application.

Part 3: iOS application 63

8.Go to the next step. This step is used to include specific files (data files, images, ...). This
possibility will not be used in our example. Keep the default options.
9.Go to the next step. This step is used to specify:
the minimum iOS version required to run the application.
whether files can be shared with iTunes. If this option is checked, you will have the ability to
retrieve the application files on Mac during the synchronization. For example, if data files
have been supplied with the application, the iTunes application will allow you to retrieve
these files.
10.Validate the wizard. 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" ("My_iOS_Project.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 the Mac. You must:
Transfer the WINDEV Mobile project onto Mac.
Compile the project in Xcode.
Transfer the WINDEV Mobile project onto Mac

To transfer the WINDEV Mobile project onto MAC:

1.Copy the entire folder generated in the EXE directory onto an external media (USB key, external
hard disk, shared directory with MAC on network). This directory is named <Project Name>.
xcode.gen.
2.Paste this folder onto the MAC where the application will be compiled.
3.Open the folder on MAC and double-click the folder named "Project_name.xcodeproj".
4.The project is opened in Xcode.

Compile the project in Xcode


WINDEV Mobile automatically generates an Xcode project for your iOS compilations. To simplify
the implementation of applications, WINDEV Mobile generates a "Scheme" for Xcode.

To compile the project in Xcode:

1.In the drop-down list found in the top left corner, select the compilation options. Select the
scheme corresponding to your application then the compilation target (device currently
connected or a simulator).
2.To start the compilation, select "Product .. Clean" then "Product .. Build".
3.A status report of compilation is displayed at the top ("Succeeded" or the number of
warnings and errors otherwise). You have the ability to click these symbols to see the list of
errors/warnings.
4.Once the program is compiled without error, you can start the simulation ("Product .. Run").
The simulation window appears with the application.

Then, you have the ability to run the test of your application on your iPhone or iPad.

64

Part 3: iOS application

Lesson 3.2. Interface (GUI)


This lesson will teach you the following concepts...
Choosing the resolution according to the device
Orientation of the window
Management of touchscreen

Estimated time: 20 min

Part 3: iOS application 65

Overview
The iOS system is available on the phones (iPhone), on the tablets (iPad) and on the iPod. WINDEV
Mobile allows you to easily create interfaces that adapt to the device used.

Choosing the resolution according to the device


When creating a project, you must choose the device on which the application will be deployed:
iPhone,
iPad,
iPhone and iPad.
Two cases may occur:
You know the target device: in this case, all you have to do is select it. The wizard for window
creation will allow you to create windows for this target device.
You do not know the target devices: in this case, in the wizard for project creation, select "iPhone
and iPad". When creating the windows, you can:
develop your windows for iPhone. Via the anchoring of controls in the window, the content
will be adapted to the iPad (recommended solution).
use the layouts to create different interfaces according to the runtime platform and to its
resolution.
develop 2 sets of windows, one for iPhone, one for iPad.

Orientation of the window


In iPhone or iPad, a window can have one of the following orientations:
Locked in portrait mode,
Locked in landscape mode,
Free: the window follows the orientation of the device.

66

Part 3: iOS application

This orientation is defined in the "IHM" tab of the description window of the window ("Description"
from the popup menu of the window).

No specific operation must be performed in the two first cases.


For a free window, the organization of controls and their size must adapt to the orientation. The
anchoring mechanism must be used to get a proper result.
Practical example

Answer

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
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.

Part 3: iOS application 67

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 appears. Change the orientation of the window with the Rotation option.

4.The orientation of the window changes on the screen.


5.In our example, the location of the button does not change: it does not adapt to the
orientation of the screen.

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).

68

Part 3: iOS application

3.Select "Anchor": the window for defining anchors is displayed:

Notes

4.Select "Horizontally centered" and validate (green button).


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.

Run the project test (

among the quick access buttons):


The button is centered in portrait mode.
Change the orientation of the simulator.
The button remains centered in landscape mode.

Management of touchscreen
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 perform a zoom and/or to move in an image.
This allows you to perform a zoom on an image via the contact of 2 fingers moving apart.
To manage the "multi-touch", WINDEV Mobile proposes:
Specific options available in the Image control.
Specific WLanguage functions.
Specific optional processes.
See the online help for more details.

Part 3: iOS application 69

Practical example

Answer

Open (if necessary) the "My_iOS_Project" project that was created in the previous lesson.
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)".

In the "WIN_Welcome" window, create an Image control:

1.On the "Creation" pane, in the "Usual controls" group, click "Image".
2.The Image control appears in creation under the mouse.
3.Move the mouse in the window toward the position where the control must be created. To
drop the control in the window, all you have to do is perform a new left mouse click.
4.Double-click the Image control: the description window of the control is displayed.
5.In the "General" tab, select an image found on your disk in the "Image" edit control via the
file picker([...] button).
6.If the image is found in a directory other than the project directory, WINDEV Mobile proposes
to copy the image file into the project directory. Accept by clicking the "Copy the file into the
suggested directory" button.
7.Display the "Details" tab: the options for managing the multi-touch are displayed:

8.Select "Automatic scroll and zoom".


9.Validate the description window of the control.
among the quick access buttons).
10.Save the window (click

70

Part 3: iOS application

Notes

11.A GUI error appears in the error pane: the automatic scrollbars of the window are in conflict
with the scroll features of the Image controls.
12.To avoid this GUI error, disable the scrollbars of the window:
Display the description window of the window ("Description" from the popup menu).
In the "GUI" tab, uncheck "Automatic scrollbars".
Validate the description window.
among the quick access buttons). The GUI error disappears.
13.Save the window (click
Multi-touch support cannot be tested in the simulator. To check this feature,
you need to deploy the application on the mobile device. We'll see how to do
this in Android and iOS: Developing an application, page 95.

14.Close the project.

The different types of controls


WINDEV Mobile proposes several controls. These controls are used to display or enter data. Some
controls are specifically intended for a mobile interface.
To develop your applications, you can use the standard controls (edit controls, images, radio
buttons and check boxes) but also more specific controls such as:
the multiline zones to create GUI similar to the native iOS windows.
the Map control to view a position on a map or an itinerary.
Some of these controls will be presented in the lesson Android and iOS: Developing an
application, page 95.

Part 3: iOS application 71

Lesson 3.3. Distributing

the

application
This lesson will teach you the following concepts...
Available distribution modes

Estimated time: 5 min

72

Part 3: iOS application

Overview
WINDEV Mobile allows you to develop applications for the iOS operating system.
Once the applications are created, developed and checked, all you have to do is deploy them.

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.

Part 3: iOS application 73

74

Part 3: iOS application

PART 4
Programming
concepts

76

Part 4: Programming concepts

Lesson 4.1. Concepts

and terminology

This lesson will teach you the following concepts...


Main concepts of WINDEV Mobile.
Terminology used by WINDEV Mobile.

Estimated time: 10 min

Part 4: Programming concepts 77

Overview
In the previous parts, we have created our first Android application and/or our first iOS application.
After these exercises, let's talk about the main concepts of WINDEV Mobile and about the
terminology specific to WINDEV Mobile.

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.

Notes

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.
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

Classes

Style
sheet

Windows
and controls

Analysis

Project 2

Classes

78

Style
sheet

Project N

Windows
and controls

Part 4: Programming concepts

Classes

Style
sheet

Windows
and controls

Terminology
As already seen, a WINDEV Mobile project (linked to an analysis if necessary) is used to create an
application. Before we actually start working with WINDEV Mobile, let's go back to the vocabulary
used in WINDEV Mobile. Indeed, several terms are specific to WINDEV Mobile and they may differ
from the ones used in other tools.
In the analysis, the terms used are as follows:
File: The analysis is used to describe the structure of the database files. A "File" may
correspond to a "table" in other databases.
In WINDEV Mobile, "Table" is a term that defines a graphic object used to view the content of
a data file in table format and/or to enter rows. A table can be used to enter the details of an
order for example.
Record: A record is sometimes called row. A file record corresponds to all the items defined for
the file.
Item: In the analysis, an item represents a section of a data file. All the items found in a data
file are used to define the structure of a record.
Key/Index: With WINDEV Mobile and its HFSQL database, the concept of index is linked to the
concept of key. The concept of key is part of the characteristics of an item. The keys are used to
improve the speed for accessing the data and to simplify the browse operations performed on
the data files. In WINDEV Mobile, if a HFSQL data file includes several key items, a single index
file will be created at run time.
In the windows and reports, the terms used are as follows:
Window: The windows are used to display or enter information. The windows are also called
"Screens" or "Dialog boxes". The user can directly act on the windows via controls, buttons, ...
Report: The reports are used to get a custom view of information. This information can come
from the database, from text files, from controls found in the windows, ... The reports can be
generated in PDF in the mobile applications.
Control: "Control" is the term used to identify the different graphic objects displayed in a window
or in a report.
Skin template: The skin template is used to define the "appearance" of the application: visual
appearance of windows, buttons, controls, ...
Style: The style groups the graphic characteristics of an element: background image, border,
font, .... The styles of the different elements found in the interface of a WINDEV Mobile
application are grouped in a style sheet.

Part 4: Programming concepts 79

Lesson 4.2. Programming

concepts

This lesson will teach you the following concepts...


The different types of variables
Main statements of WLanguage
The main operators of WLanguage
Procedures and functions
Processing the strings, numeric values and currencies

Estimated time: 1 hour

80

Part 4: Programming concepts

Introduction
In the previous lesson, we have worked with the code editor of WINDEV Mobile and its language
named WLanguage. This lesson allows you to discover the programming concepts of WLanguage
by presenting the following topics:
Declaring the different types of variables,
Main statements of WLanguage,
Procedures and functions,
Processing strings,
Processing numeric values.

Declaring the different types of variables


The different types of variables
WINDEV Mobile proposes several types of variables (boolean, integer, real, currency, string, date,
time, duration, datetime, variant, array, structure, ...).
The syntax for declaring a variable is very simple: all you have to do is specify the name of the
variable and its type:
VariableName IS VariableType

Some examples:

Notes

Subscript is int
SupplierName is string
PriceTable is array of 10 currencies
I, J, K are ints
Counter is int = 120
B1 is boolean = False

Format of character strings


In a WINDEV Mobile application, the character strings are character strings in
Unicode format. No specific declaration is required. The code:
SupplierName is string

automatically creates a Unicode string.


See the online help (keyword: "Data types") for more details.

Part 4: Programming concepts 81

Declaring the variables and their scope


Two types of variables can be handled in WLanguage:
The global variables.
The local variables.

Caution!

The global variables can be global to the project, to a window or to a report. All you have to do is
declare these variables:
in the initialization code of the project, to declare the global variables of the project. These
variables can be used in all the processes of the project and project elements (windows,
reports,...)
in the declaration code of the global variables of the window, to declare the global variables
of the window. These variables can be used in all the processes of the window and window
elements.
in the declaration code of the global variables of the report, to declare the global variables of
the report. These variables can be used in all the processes of the report and report elements.
All the variables declared elsewhere are local variables.
Most developers are tempted to declare all their variables as "global variables" in
a project. This type of programming is quite "easy". All the variables being global
variables, they can be handled from any process.
But this type of programming often causes overwritten variables and exception
problems.
Therefore, we advise you to declare a limited number of global variables and to
declare local variables when necessary.
If you want to share values between 2 windows, we highly recommend that you
use the method for "passing parameters" that will be presented later in this
tutorial.

Main statements of WLanguage


WLanguage is a 5GL made of:
WLanguage functions.
WLanguage properties.
WLanguage keywords.
WLanguage statements.
You will discover all these statements as you progress through this tutorial.
The main statements (used to create conditions and loops or to enter comments) will be presented
in this lesson.

82

Part 4: Programming concepts

Conditional statements
WLanguage allows you to manage the conditional statements such as:
IF, THEN, ELSE, END to run a test on a condition.
SWITCH, CASE, END to perform one or more actions according to the result of a test on a
condition.
Some examples
IF EDT_Maximum > Random(1, 999) THEN
Info("Congratulations, you won!")
ELSE
Info("Bad luck, you've lost!")
END
SWITCH day
CASE "Monday"
// First day of the week
CASE "Wednesday"
// Third day of the week
CASE "Friday"
// Fifth day of the week
CASE "Saturday", "Sunday"
// It's the weekend
OTHER CASE

// It's another day
END

Loop statements

Notes

WLanguage proposes several methods for managing the loops:


FOR, END for a given number of iterations.
WHILE, END for an undefined number of iterations whose exit condition is checked at the
beginning of the loop.
LOOP, END for an undefined number of iterations whose exit condition is checked inside the
loop. The BREAK statement is used to exit from this loop.
WLanguage also proposes FOR EACH and END loops used to browse the control
elements, the character strings, the records of a data file...

Some examples
FOR i = 1 TO 100
// There is no need to declare i
Ctr ++ // Equivalent to Ctr=Ctr+1
END
i is int = 0
WHILE i < EDT_Maximum
i ++ // Equivalent to i=i+1
END

Part 4: Programming concepts 83

i is int = 0
LOOP
i ++ // Equivalent to i=i+1
IF i > EDT_Maximum THEN BREAK
END

Comments
To enter comments in the code, the code line must start with // (two "/" characters).
Example:

Tip

// This is a comment line

Several code lines can be set in comment ; to do so, select the code lines with
the keyboard (or with the mouse) and press the [CTRL] / keys (on the numeric
keypad).
To perform the reverse operation (to remove the comments), select the code
lines with the keyboard (or with the mouse) and press the [CTRL] [SHIFT] / keys
(on the numeric keypad).

Main WLanguage operators


WLanguage includes several types of operators:
the logical operators (AND, OR, NOT, ...),
the arithmetic operators that are used to add, subtract, ...
the comparison operators that are used to compare values. Some of them have been used in
the previous paragraph (>, <, =, ...),
the binary operators that are used to perform operations on the binary values,
the assignment and exchange operators (=, <=>),
the indirection operators that are used to build the name of a control from an expression.
the operators on the character strings.
...
We are going to present the logical operators and the comparison operators. See the online help
(keyword: "Operators") for more details.
The logical operators
WLanguage includes 5 logical operators that are used to perform logical operations and to build
conditions:
AND and _AND_ that correspond to the logical multiplication.
OR and _OR_ that correspond to the logical addition.
NOT that corresponds to the logical negation.

84

Part 4: Programming concepts

The comparison operators


WLanguage includes several comparison operators that are used to perform several processes:
equality operators: equality (=), flexible equality (~=) or very flexible equality (~~).
comparison operators: different (<>), less and greater than (<, <=, >, >=) or starts with ([=, [=~,
[=~~).

Procedures and functions


Definition
When a process is called several times in a project or in a window, it may be interesting to create
a procedure containing this process. Then, all you have to do is call the procedure whenever
required.
The procedures and the functions are available in programming:
The functions return a result.
The procedures are used to run a specific process.
WINDEV Mobile allows you to easily manage the two types of processes: there is no difference
between a procedure and a function. This is the reason why we shall talk about "procedure" in the
rest of this lesson.
You have the ability to create "local" procedures and "global" procedures.
Local procedure
A "local" procedure is linked to a single window.
A local procedure can only be used in the processes of the window in which it was declared (and in
the processes of the controls found in this window). It is part of the window.
Global procedure and set of procedures
The "global" procedures are stored in "sets of procedures". Each "set of procedures" is a file
that contains all the global procedures that are associated with it. The extension of this file is
".WDG". For example, a set is used to group the procedures according to a topic: CalcVAT,
CalcShippingCost,...
You can create as many sets of procedures as necessary in a project.
A set of procedures is used to:
share the global procedures between several developers, for the same project.
share the global procedures between several projects. Indeed, the same set of procedures
can be used in several projects.

To create a set of procedures:

1.Select the "Project explorer" pane.


2.Select "Procedures".
3.In the popup menu (right mouse click), select "New set of procedures".

Part 4: Programming concepts 85

4.In the window that is displayed, specify the name of the set of procedures and validate.
5.The processes associated with the set of procedures are displayed in the code editor.
Then, you will have the ability to create global procedures (this creation is presented in details in
the rest of this lesson).
How to decide whether a procedure is global or local?
To decide" whether a procedure must be global or local, ask yourself the following question: "Will
the procedure be used in this window only or can it be called from another window?"
If the procedure is called "from this window only", the procedure can be "local".
If the procedure can be called "from other windows", the procedure must be "global".
About passing parameters
A procedure can manage parameters. The parameters can be mandatory or optional parameters.
The "mandatory" parameters are always defined before the "optional" parameters. The declaration
of an "optional" parameter is performed by assigning a default value when declaring the
parameter. For example:
PROCEDURE MyProcedure (Param1, OptionParam = "Default value")

A window can also return a value to the process that called it (value by address by default). See
the online help about ..ReturnedValue for more details.
Calling a procedure
To call a procedure in a process, all you have to do is write its name in the code editor and specify
parameters if necessary.
WINDEV Mobile manages the calls to nested procedures.

86

Part 4: Programming concepts

Tip

In the code editor, when you are positioned on a procedure name, press the [F2]
key if you want to view the code of this procedure. Press [CTRL]+[F2] to go back
to the name of the procedure in the previous code.

Creating a procedure
A procedure can be created from the main editor of WINDEV Mobile. All you have to do is use the
"Project explorer" pane.

To create a local procedure:

1.In the "Project explorer" pane, select the name of the window associated with the local
procedure.
2.Click the arrow on the left to display the different elements.
3.Select "Local procedures".
4.Select "New local procedure" from the popup menu of "Local procedures".
5.In the window that is displayed, specify the name of the procedure and validate.
6.The procedure appears in the code editor. Enter the code of the procedure.

To create a global procedure:

1.Select the "Project explorer" pane.


2.Select "Procedures".
3.Create (if necessary) the set of procedures where the global procedure must be created. If
this set exists, select it.
4.Select "New global procedure" from the popup menu.
5.In the window that is displayed, specify the name of the procedure and validate.
6.The procedure appears in the code editor. Enter the code of the procedure.

Tip

Reminder: A procedure can also be created from the code selected in the code editor ("New ..
Create a procedure containing the selected code" from the popup menu). That's what we've done
in the previous lesson.

When should the procedures be used?


When a process is used several times in the same window, we recommend that
you use a procedure local to the window that will contain this process.
When a process is used several times in a set of windows, we recommend that
you use a procedure global to the project that will contain this process.

Part 4: Programming concepts 87

Processing strings
The ability to handle character strings is one of the most important features of a programming
language.
Several WLanguage features can be used to handle the character strings: WLanguage functions,
extraction operators, concatenation operators, ...
The most common functions for handling the character strings will be presented in this tutorial.
See the online help (keyword: "Character string") for more details.
Main operations performed on a character string
Initialization

A text control (a Static control or an edit control for example) can be initialized by one of the
following methods:
in the "Content" tab of the description window of the control:

by programming, by assigning the string to the name of the control:


EDT_Text = "WinDev Mobile is a great tool"

by programmation, by using a string variable:


str is string
str = "WinDev Mobile is a great tool"
EDT_Text = str
Concatenation

A string can be built from several other strings. We talk of string concatenation. To concatenate
two strings, all you have to do is use the "+" operator.
// Info is used to display the result on the screen
Info(EDT_Text1 + EDT_Text2)
Extracting sections from a string

A section can be extracted from a string by:


the [[ and ]] operators (caution, no space character must be found between the two opening
square brackets "[[" and between the two closing square brackets "]]").
Info(EDT_Text[[1 A 6]])
88

Part 4: Programming concepts

// Displays "WinDev"

ExtractString, that extracts a sub-string from a string:


Info(ExtractString(EDT_Text,1," "))

// Displays "WinDev"

Middle, that extracts a section of string from a string:


Info(Middle(EDT_Text,4,2)) // Displays "De"

Left, that returns the left section of a string:


Info(Left(EDT_Text,6)) // Displays "WinDev"

Right, that returns the right section of a string:


Info(Right(EDT_Text,3)) // Displays "ool"
Various operations

The size of a string is returned by Length:


Info(Length(EDT_Text))

// Displays the size of the string

A string can be changed into uppercase characters with Upper or to lowercase characters with
Lower:
Info(Upper(EDT_Text))
Info(Lower(EDT_Text))

A string can be sought in another string by Position:


StringToFind is string = "WinDev"
Pos is int
Pos = Position(EDT_Text, StringToFind)
IF Pos = 0 THEN
InfoBuild("%1 not found in the text", StringToFind)
ELSE
InfoBuild("%1 found in the text", StringToFind)
END

You can also find the position of a character string inside another one while ignoring the case. To
do so, Position must be associated with the IgnoreCase constant:
Pos = Position(EDT_Text, StringToFind, 1, IgnoreCase)

To find out the number of occurrences of a given character string inside another character string,
use StringCount:
NbOccurrences is int
NbOccurrences = StringCount("anastasia", "a")

// Returns 4

You also have the ability to find a string and to replace it in a single operation via Replace:
Replace(EDT_Text, "WinDev", "WinDev Mobile")

Part 4: Programming concepts 89

To build a string from a string and from the result of a function, we recommend
that you use InfoBuild. This function is used to build the text displayed according
to parameters (%1, %2, ...):
InfoBuild("%1 not found in the text", ...

StringToFind)

Tip

You also have the ability to use the simple concatenation:

Info(StringToFind + " not found in the text")

Using InfoBuild presents the following benefits:


the readability of the code: the string is easier to read
the translation: a string can be entirely translated. The words and the
parameters can be reversed. The translator has a single obligation: include %1,
%2, %3.
According to the same principle, WLanguage also proposes StringBuild,
ErrorBuild, ...

Processing numeric values


The calculations on numeric values can be performed from numeric edit controls or by using the
typed variables (integer, real, numeric, currency, ...).
Main operations performed on the numeric values
Initialization

A numeric edit control can be initialized by one of the following methods:


the "Content" tab in the description window of the control.
by programming, by assigning the numeric value to the name of the control:
EDT_InitialValue = 3.14

by programmation, by using a numeric variable:


int1 is int
int1 = 1234
EDT_InitialValue = int1

The "+" operator is used to concatenate a string and a numeric value:


Info("The EDT_InitialValue control contains the value: " + ...

EDT_InitialValue)

90

Part 4: Programming concepts

If you run the following code:

Tip

Info("A calculation: " + 1 + 2)

The dialog box will display "A calculation: 12".


To display the result of the calculation, you must use the following code:
Info("A calculation: " + (1 + 2))

The dialog box will display "A calculation: 3".


Various operations

Some examples of numeric operations performed in WLanguage:


The integer part of a number is returned by IntegerPart and the decimal part of a number is
returned by DecimalPart:
InfoBuild("Integer part of %1: %2" + CR + ...
"Decimal part of %1: %3", EDT_SignedReal, ...
IntegerPart(EDT_SignedReal), ...
DecimalPart(EDT_SignedReal))

The absolute value of a number is returned by Abs:


InfoBuild("Absolute value of %1: %2", ...
EDT_SignedReal, Abs(EDT_SignedReal))

The rounded value of a number is returned by Round:


InfoBuild("Rounded value of %1: %2", ...
EDT_SignedReal, Round(EDT_SignedReal, 1))

Root is used to calculate the Nth root of a number:


InfoBuild("Square root of %1: %2", ...
EDT_Reference_Root, Root(EDT_Reference_Root, 2))

Power is used to raise a number to the power of N:


InfoBuild("Power 2 of %1: %2", ...
EDT_Reference_Power, Power(EDT_Reference_Power, 2))

Note: the type of the numeric edit controls


When a control is defined as a numeric control, its type may be undefined (integer, real, double
real, ...). Its type is automatically defined according to the mask selected for the control.
To force the type of a control, all you have to do is use a typed variable. For example:
Val1 is int
Val1 = 123456789
EDT_NUM = Val1
Val1 = EDT_NUM

// Assign the control


// Retrieve the control

Part 4: Programming concepts 91

Processing currencies
Details
The reals are used to handle the decimal numbers by programming.
The currencies can also be used to manage these decimal numbers but with a better precision.
When using reals, the rounding is performed by the operating system and these rounding
operations may induce calculation errors.
For example:
// The calculation is false with a Double Real variable
MyReal is real
MyReal = 18.6 - 8.6 - 10
Error("18.6 - 8.6 - 10 = " + MyReal)

With currency variables, the calculation is performed by WLanguage.


WLanguage guarantees 23 significant digits which allows for more precise calculations.
With the following code, the calculation is correct:
// The calculation is correct with a Currency variable
myCurrency is currency
myCurrency = 18.6 - 8.6 - 10
Info ("18.6 - 8.6-10 = " + myCurrency)

To perform divisions on currencies, we recommend that you use intermediate variables of


"Currency" type.

Note

Currency1, Currency2, Result are currencies


// Assigns a number to the two currency variables
Currency1 = "12 345 678 901 234 567,123456"
Currency2 = "12 345 678 901 234 567,123456"
// Divide Currency1 by Currency2
Result = Currency1/Currency2
// Displays the result of the division
Info("12 345 678 901 234 567,123456", " divided by ",...
"12 345 678 901 234 567,123456", " = "+Result)

92

To perform advanced calculations, WLanguage proposes the Numeric type. By


default, the Numeric type corresponds to 32 digits for the integer part and to 6
digits for the decimal part (like the currency type). The numeric type allows you
to configure the number of digits that will be used for the integer part and the
number of digits that will be used for the decimal part.
See the online help (keyword: "Numeric") for more details.

Part 4: Programming concepts

Mixing strings and numeric values

WINDEV Mobile is very flexible when assigning variables. For example, a string of digits can be
assigned in a numeric variable (and conversely). For example:
i
c
i
c
c
i

is int
is string
= 123
= i
// the variable c contains the string "123"
= "456"
= c
// the variable i contains the value 456

To transform a number into a character string while respecting a specific format, all you have to do
is use NumToString. For example:
NumToString(1234.567,"012,3f") // returns "00001234,567"
The code wizard proposed by WINDEV Mobile can be used whenever you want to call NumToString
without exactly knowing which parameters to use: this wizard will inform you of the syntax to use
according to the requested result.

Notes

In the code editor, various information can be displayed when typing the name of
a function followed by the opening bracket:

the name of the wizard corresponding to the function. A wizard starts if this
option is selected. Via simple questions, this wizard automatically writes
the requested syntax.
the name of an example that is using this function. The example is
automatically opened in the editor if this option is selected.

The "reverse" function of NumToString is Val. This function is used to convert a string into a
numeric value.

Part 4: Programming concepts 93

94

Part 4: Programming concepts

PART 5
Android and iOS:
Developing an
application

96

Part 5: Android and iOS: Developing an application

Lesson 5.1. Overview


This lesson will teach you the following concepts...
What is a multi-platform project?
Which project is used for this part?
How to enable a platform?

Part 5: Android and iOS: Developing an application 97

Overview

Note

Two distinct projects have been created in the previous parts: an iOS project and an Android
project.
This new part will allow you to develop an Android and/or iOS application that is using a HFSQL
Classic database.
This part can be followed both by the developers of Android applications and by
the developers of iOS applications. The operations performed are identical, no
matter whether the project is developed for Android only or for iOS only.

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.

98

Part 5: Android and iOS: Developing an application

The sample project used


In this lesson, we are going to develop an Android and iOS application that is using a HFSQL Classic
database. The creation of projects was already presented in the previous part therefore we will be
working on an existing project, containing the database and the data used by the application.

In iOS and Android, only the HFSQL database is accessible in native mode. Both
the Classic mode and the Client/Server mode are available.

Note

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 memory of the device. The maximum storage size
depends on the amount of memory on the device.
If the data entered 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).
Windows or Linux
HFSQL server

Mobile device

Manta server

Database

Hxxx
functions
,
(read,
write...)

Replication

HFSQL
Client/Server
databases

In this part, we will develop an application that is using a HFSQL Classic


database.

Part 5: Android and iOS: Developing an application 99

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.

Mobile Device 1

Windows or Linux
HFSQL server
Mobile Device 2

Note

Manta server

Mobile Device N

HFSQL
Client/Server
databases

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.

100

Part 5: Android and iOS: Developing an application

Opening the project

Start WINDEV Mobile 21 (if not already done). Close (if necessary) the current project in order
to display the home window.

Open the "WM Managing Products" project.

Answer

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)".
A corrected project is available. This project contains the different windows
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)".

Choosing the platform

Note

If you want to develop the application for the Android platform, go to Part 5.2 - Developing the
application.
If you want to follow this part for iOS only, you must add the iOS platform (see the next paragraph,
"Enabling the iOS platform").
All the operations performed in this part can be performed on a project
associated with an Android platform, on a project associated with an iOS platform
or on a multi-platform project.

Enabling the iOS platform

To enable the iOS platform, all you have to do is create a project configuration:

Note

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
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.

Part 5: Android and iOS: Developing an application 101

Note

2.The wizard for creating a project configuration starts. The wizard proposes to create an iOS
platform. Go to the next step.
3.You can enter information regarding the platform. Keep the default options and go to the
next step.
4.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.
If the application is intended to operate on several iOS devices (phones with
different sizes or with different resolutions for example), we advise you to use
one of the following options: "Generate an application for iPhone and iPad",
"Generate an application for iPhone only" or "Generate an application for iPad
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 the devices.

5.For this example, select "Generate an application for iPhone only".


6.Go to the next step and validate the wizard. The iOS configuration is automatically created.

102

Part 5: Android and iOS: Developing an application

The presence of the new project configuration can be checked in the project explorer:
1.Expand "Configuration (iOS application)" at the top of the project explorer
2.The two configurations are displayed:

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.
Let's now start developing the application.

Part 5: Android and iOS: Developing an application 103

Lesson 5.2. Developing

the application

This lesson will teach you the following concepts...


Creating a window containing a looper via RAD.
Specific controls: Looper control, Multiline Zone control, Map control, ...
Handling the database
Features specific to the device used (GPS, Photo, ...)

104

Part 5: Android and iOS: Developing an application

Project analysis
Let's take a look at our initial project. This project contains no window. It only contains the analysis
describing the HFSQL Classic data files that will be used. The corresponding data files are supplied
with data in order to run the different tests.

To view the analysis associated with the project:


1.Click
among the quick access buttons of the WINDEV Mobile menu.
2.The data model editor is displayed.

3.This analysis includes 3 data files:


A "Product" file, that contains the description of the product: name, price, quantity, ...
A "Characteristic" file, that contains the different characteristics of the product. For example,
if the product is a tee-shirt, its characteristics will correspond to the size, the color, ...
Therefore, the "Characteristic" file is linked to the "Product" file.
A "Store" file, that contains the GPS coordinates of each store.
4.Close the data model editor (click the cross at the top right of the editor).

Display the list of products

Notes

We are going to create a window used to list the different products. These products will be
displayed in a "Looper" control.
This window will be created via the wizard for creating RAD windows (Rapid Application
Development).

The wizard for window creation proposes several windows generated by RAD.
These windows, generated from your data, propose modern interfaces for your
applications and they can be immediately used.

Part 5: Android and iOS: Developing an application 105

Creating the window

To create the window used to list the products:

Notes

1.Click
among the quick access buttons. The window for creating a new element is
displayed: click "Window" then "Window".
2.In the wizard, select the "Standard" tab. In the "Window RAD for phones" area, choose
"Looper" and validate.

If you are using an iOS configuration, the window for creating a new window
contains additional options, specific to iOS.
You have the ability to create a RAD window whose type is "Looper" on an iOS
platform and on an Android platform.

3.The wizard for creating a RAD window starts.


4.If the iOS platform was added, choose the platform with the smallest resolution. Go to the
next wizard step by clicking the arrow buttons at the bottom of the window.

106

Part 5: Android and iOS: Developing an application

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.

6.Go to the next step.


7.Select the style of the looper: "Image + Title + Caption below". This template is used to get
an interface containing the image of the product, its name and its description.

8.Go to the next step.

Part 5: Android and iOS: Developing an application 107

9.The wizard automatically proposes the items of the data file corresponding to the generated
looper.

10.Keep the proposed items and go to the next step.


11.Keep the suggested sort on the "ProductID" item. Go to the next step.
12.The wizard proposes several options for generating the Looper window:

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 the opening code of the form in XXX: If this option is selected, the wizard proposes
to generate a form window in edit or in read-only.

108

Part 5: Android and iOS: Developing an application

13.In our example, keep the default options. Go to the next step.
14.Give a title and a name to the generated window. Enter the title of the window: "List of
products". The name of the window is automatically filled.

Notes

15.Validate the wizard. The window is automatically created, displayed in the editor and
saved.

The data automatically appears in the window displayed in the editor. This
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.

Save the window by clicking

among the quick access buttons.

Part 5: Android and iOS: Developing an application 109

We are going to run a first test in the simulator to view the result. Click
access buttons (or press [F9]).

among the quick

Notes

Close the simulator to go back to the window editor.


When a project is associated with several platforms, the test of the current
window is run with the current platform. The shell used for the simulator is also
adapted to the current platform.
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 the form window


We are now going to create a new window used to display the product form. Then, this window will
be started from the list of products to display the details of the selected product.
Creating the window

To create the form window:

1.Create a new blank window.


Click
among the quick access buttons.
The window for creating a new element is displayed: click "Window" then "Window".
In the wizard, select the "Standard" tab, choose "Blank" and validate.

110

Part 5: Android and iOS: Developing an application

2.Save the window. Specify the title of the window: "Product form". Its name is automatically
proposed: "WIN_Product_form". Validate.

3.The window is added to the project, for all the configurations.

Note

If several platforms are defined in the project, the widow for element backup
proposes to associate the new element to all the platforms.
To associate the element to a single platform, all you have to do is expand
"Configurations" in the backup window and choose the requested platform:

Creating the 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).

Part 5: Android and iOS: Developing an application 111

3.Drag and Drop these items to the window that was just created.

4.Resize the controls ("Name", "Bar code", "Reorder date" and "Description") so that they are
visible in the window.
5.Reorganize the controls in the window. Respect the following order: "Photo", "Name", "Price",
"Quantity", "Bar code", "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 to make the numbers disappear.
The navigation order is automatically adapted to the order of the controls in the window.
7.Save the window.

112

Part 5: Android and iOS: Developing an application

Run the test of the "WIN_Product_form" (


is displayed with empty controls.

among the quick access buttons). The window

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.
The code editor appears.
2.Enter 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
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.
Displaying the form from the list of products
Let's see how to display the form of the selected product in the list of products.

Perform the following operations:

1.Position on the "List of products" window: click the "WIN_List_of_products" button in the bar
of opened elements:

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:

Notes

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
the mouse.
If the name of the window is not displayed in the list, it means that this window
was not saved beforehand.

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).

Part 5: Android and iOS: Developing an application 113

Re-run the test of the "WIN_List_of_products" window in the simulator (


access buttons).
In the list of products, click one of the products with the mouse.
The detailed window of the product is displayed.

among the quick

Close the simulator.


Managing the creation and the modification of a product
We are now going to modify our two windows in order to manage the addition and the modification
of a product.
Modifying the product form
When creating the form window, an Action Bar was automatically created. This Action Bar contains
a left button used to cancel the current input and to go back to the previous screen. In our case,
this button will be used to go back to the list of products.

There is no modification to perform.


We are going to add a validation button into the Action Bar of the "WIN_Product_form" window in
order to manage the validation of modifications.

First of all, display (if necessary) the "WIN_Product_form" window in the editor: click the
corresponding button in the bar of opened elements.

To add a validation option into the Action Bar of the window:

1.Select the Action Bar (at the top of the window).


2.Display the description window of the Action Bar: right-click and select "Description" from
the popup menu.

114

Part 5: Android and iOS: Developing an application

Notes

The description window of the Action Bar is adapted to the platforms used in the
project. Indeed, the Action Bar used in an Android application differs from the
Action Bar used in an iOS application.
If your project is using an Android configuration, only the options corresponding
to the Action Bar for Android are displayed.
Similarly, for an iOS configuration, only the options corresponding to the Action
Bar for iOS are displayed.
If your project is using both an Android configuration and an iOS configuration,
the window displays a preview of the Action Bar for the two platforms.
Numbers allow you to access the options to configure.
We are going to present the options required by our example. See the online help
for more details.

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.

Part 5: Android and iOS: Developing an application 115

Notes

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:
If no image is associated with the option.
If the option is transferred into menu at the bottom.

In the "Preset image" area, expand the list and select "Validate".

116

Part 5: Android and iOS: Developing an application

Notes

Validate the description window.


To go back to the interface for describing the Action Bar, all you have to do is click
the button
.

Notes

6.The code of this option will be used to save the modifications performed in the "WIN_
Product_form" window. To enter this code:
Select (if necessary) the Action Bar control of the window.
Click "OK".
A drop-down menu with the "Validate" option is displayed.

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.

Right-click the option.


Select "Code" from the popup menu.

Part 5: Android and iOS: Developing an application 117

In the "Selecting the menu" process, enter the following code:


ScreenToFile()
HSave(Product)
Close()

Let's study this code:


ScreenToFile is used to initialize the items with the values of linked controls, for the current
record.
HSave is used to update the file data for the current record.
among the quick access buttons.
7.Save the modifications by clicking
8.Close the code window (click the cross in the top right corner of the code editor).

When closing the product form, the content of the product list found in the "WIN_List_of_

products" window must be refreshed to take into account the modifications performed in the
form. To do so, use the "Closing a child window" process of the "WIN_List_of_products"
window.
1.Click the "WIN_List_of_products" button in the bar of opened elements:

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)

Let's study this code:


The "Closing a child window" process is run whenever a child window of the current window
is closed. In our case, it is run when the "WIN_Product_form" window is closed.
LooperDisplay is used to update the data found in the Looper control of the "WIN_List_of_
products" window. The taCurrentSelection constant is used to update the data from the
selection bar.
This code was automatically generated when creating the window by RAD.
3.Close the code window (click the cross in the top right corner of the code editor).

Run the test of the "WIN_List_of_products" window in the simulator (

among the quick


access buttons).
In the list of products, click one of the products with the mouse: for example, the "Polo
Hibiscus Blue" product.
The detailed window of the product is displayed. Modify the name of the product and
type"Polo Hibicus Light blue" then click the "OK" button.
When going back to the list of products, you will notice that the name of this article was
updated.

Close the simulator. The editor of WINDEV Mobile is displayed.

118

Part 5: Android and iOS: Developing an application

Creating a new product


The principle for creating a product is as follows:
In the window for the list of products, we are going to add option into the Action Bar of the
window in order to open the "Product form" window.
Then, we will modify the code of the "Product form" window to manage the addition into the
Product data file.

To add an option into the Action Bar of the window:

1.Display (if necessary) the "WIN_List_of_products" window in the editor: click the corresponding
button in the bar of opened elements.
2.Select the Action Bar (at the top of the window).
3.Display the description window of the Action Bar: right-click and select "Description" from
the popup menu.

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".

Part 5: Android and iOS: Developing an application 119

In the "Preset image" area, expand the list and select "Add".

Validate the description window.


6.The code of this option is used to open the "Product form" window and to reset its controls.
To enter this code:
Select (if necessary) the Action Bar control of the window.
Click the "+" button.
A drop-down menu with the "New product" option is displayed.

120

Part 5: Android and iOS: Developing an application

Right-click the option.


Select "Code" from the popup menu.
In the "Selecting the menu" process, enter the following code:
HReset(Product)
OpenMobileWindow(WIN_Product_form)

HReset initializes the variables of the items found in the "Product" data file with the default
values to manage a new record.
among the quick access buttons.
7.Save the modifications by clicking
8.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 "OK".
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()

Let's study this code:


By default, HSave is equivalent to HModify (current record modified in the data file).
If HReset was called beforehand, HSave adds a record into the data file (equivalent to
HAdd).
3.Close the code window (click the cross in the top right corner of the code editor).

Display the "WIN_List_of_products" window in the window editor and run its test in the

Notes

simulator ( among the quick access buttons).


Click the "+" button found in the Action Bar.
Enter a new product.
Validate. The new product is displayed in the list of products.
Close the simulator.

If your project is using several platforms, run a GO for each one of the platforms.
The differences regarding the display and the operating modes will appear in the
simulator.

Part 5: Android and iOS: Developing an application 121

Caution!

Using the camera and displaying an image


This paragraph requires a device equipped with a camera. If this is not the case,
go to the next paragraph directly.
Furthermore, this paragraph requires the setup of the application on the device
because it is using hardware resources that are not accessible in Simulation
mode.

Overview
We are going to manage the photo of the product by using the camera of the device.
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.
Creating the button for taking photos

To create the button for taking photos:

1.Display the "WIN_Product_form" window in the editor.


2.Add a button into the window:
On the "Creation" pane, in the "Usual controls" group, click
: the shape of the button
appears under the mouse.
Then, click at the top right of the product image to create the button.

We are going to modify the button in order to associate it with an image representing a

camera:
1.Select the button and display its popup menu (right mouse click).
2.Select "Description". The description window of the control is displayed.
3.In the "General" tab, position on the "Image" edit zone and click the "Catalog" button.
4.The image catalog of WINDEV Mobile is opened. This catalog contains hundreds of images
in different fields, formats and sizes.
5.In the "Find" area at the top, type the word "photo" then select the "Android Holo" theme and
validate. Several images are displayed:

6.Select the second image for example by double-clicking it.

122

Part 5: Android and iOS: Developing an application

7.In the next screen, you have the ability to choose the size of the image, the color, the
orientation, its format and its name.
8.Keep all the default options and specify the name of the image ("Camera").
9.Validate the window.
10.The path of the image is displayed in the button description.
11.Give a name to the button: "BTN_Camera".
12.Clear the caption of the button.
13.Validate the description window.
14.In the editor, reduce the size of the button.
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 manage the taking of photos:

1.Select "Code" from the popup menu of the button (right mouse click).
2.Enter 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.
among the quick access buttons.
3.Save the modifications by clicking
4.Close the code window (click the cross in the top right corner of the code editor).
Selecting a photo in the photo album
We are going to add a button used to select a photo in the album of the device and to associate it
with the product.

To create the button for selecting the photo, we are going to "Copy - Paste" the button for

taking photos that was just created:


1.Select the "BTN_Camera" button that was juste created.
2.Press [CTRL] + [C]: the button is copied into the clipboard.
3.Press [CTRL] + [V]: the mouse cursor changes and the button shadow appears under the
cursor.
4.Click in the window beside the "BTN_Camera" button: the new button is automatically
created.
5.Display the description window of the button (double-click the control):
Give a name to the button: "BTN_Photo_Album".
Select an image in the image catalog.
6.Validate the description window.

Part 5: Android and iOS: Developing an application 123

The code of this button is used to open the photo album of the device and to select an image
in order to display it in the Image control of the product form.
1.Select "Code" from the popup menu of the button (right mouse click).
2.Replace the code of the "Click" process by the following code:
// Local variable
sPhoto is string
// Start the selection
sPhoto = AlbumPicker(albumImage)
IF sPhoto <> "" THEN
IMG_Photo = sPhoto
END

In this code, AlbumPicker is used to retrieve the photo selected in the photo album.
3.Save the modifications by clicking
among the quick access buttons.
4.Close the code window (click the cross in the top right corner of the code editor).

Caution!

Managing the bar code of the product


This paragraph requires a device equipped with a camera.
Otherwise, you willl not be able to test its use.
Furthermore, this paragraph requires the setup of the application on the device
because it is using hardware resources that are not accessible in Simulation
mode.

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

To create the button for managing the bar codes:

1.Display (if necessary) the "WIN_Product_form" window in the editor.


2.Add a button into the window:
On the "Creation" pane, in the "Usual controls" group, click
.
The shape of the button appears under the mouse.
Create the button beside the "Bar Code" control (resize the edit control if necessary).

124

Part 5: Android and iOS: Developing an application

3.Display the description window of the button (double-click the control):


Give a name to the button: "BTN_Bar_Code".
Clear the caption of the button.
Select an image of bar code in the image catalog (type the "Code" keyword for example).
4.Validate the description window.
5.In the editor, reduce the size of the button.

The code of this button is used to scan the bar code.

1.Select "Code" from the popup menu of the button (right mouse click).
2.Enter the following code in the "Click" process:
// Local variable
bc is BarCodes
// Start the scan
bc = BCCapture()
IF bc..Content <> "" THEN
EDT_Bar_Code = bc..Content
END

In this code, BCCapture is used to decode the information stored in a bar code by using the
camera of the device.
among the quick access buttons.
3.Save the modifications by clicking
4.Close the code window (click the cross in the top right corner of the code editor).

Managing anchors in the Product form


All the controls have been positioned in the Product form. The vertical and horizontal resolution
may differ according to the devices.
The anchoring is used to adapt the size of controls to the resolution and to avoid displaying "empty"
areas in the window (especially at the bottom right).
If the target device of the application is known as soon as the project creation, the widows have
the size of the target device. No anchoring is required.
If the target device of the application is not known or if several devices are used, the smallest
common resolution must be chosen as soon as the project creation. The anchoring is required in
this case.

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.

Part 5: Android and iOS: Developing an application 125

2.Display the popup menu of the selection (right mouse click) and select "Anchor".
3.Select "Centered horizontally" (
).

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):
Name
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 the bar codes. In this case, select
"Right" (

126

).

Part 5: Android and iOS: Developing an application

All the anchors have been defined in the window. The red arrows indicating the orientation of
anchors are displayed:

Using the Map control


We will now present the Map control and the GPS functions of WLanguage.
Our database contains a "Store" data file. This data file contains the addresses of the stores that
will be localized on a map via the mapping functions.
Creating the window
We are going to create a new window and add a Map control into it.

To create the window:


1.Create a new blank window. Click
among the quick access buttons. The window for
creating an element is displayed: click "Window" then "Window". In the wizard, choose "Blank"
and validate.
2.Save the window. Specify the title of the window: "Map of stores". Its name is automatically
proposed: "WIN_Map_of_stores". Validate.

Part 5: Android and iOS: Developing an application 127

Creating the Map control

To create the Map control:

1.On the "Creation" pane, in the "Graphic controls" group, click "Map". The shape of the control
appears under the mouse.
2.Click in the window to create the control.
3.A message regarding the management of scrollbars in the window is displayed. Indeed,
both the window and the Map control include their own scrollbar. Therefore, a conflict occurs.
A single scrollbar must be enabled. We advise you to:
disable the scrollbar in the window because the window has a fixed size,
keep the scrollbar enabled in the Map control.
4.Click "Disable the automatic scrollbar". The Map control appears in the window editor.
5.Display the description window of the "Map" control (double-click the control for example).
6.In the description window of the control, specify the name of the control ("MAP_Store") and
validate.
among the quick access buttons.
7.Save the modifications by clicking

Displaying the stores on the map


Principle
We are now going to add the code used to display on a map all the stores found in the "Store" file.
To do so, the "Store" file will be browsed by a FOR EACH loop. Then, the Marker variables will be
used. A Marker variable is used to define a marker that will be displayed on a map.
A marker contains different information. We will be using the following information:
Name,
Latitude,
Longitude.
MapAddMarker is used to add a marker onto the map. Then, all you have to do is define a sufficient
zoom level to see all the markers on the map. If the zoom is not set properly, some markers may
not be visible or they may overlap on the map.

128

Part 5: Android and iOS: Developing an application

Implementation

To enter the code used to display the stores:

1.Right-click outside the window. Select "Code" from the popup menu. The processes associated
with the window are displayed.
2.Enter the following code in the "Global declarations of..." process.
// Global variables
gMarker
is Marker
// Load the stores
FOR EACH Store
// Coordinates of marker
gMarker.Position.Latitude = Store.Latitude
gMarker.Position.Longitude = Store.Longitude
// Name of marker
gMarker.Name = Store.Name
// Add the marker
MapAddMarker(MAP_STORE,gMarker)
END
// Best zoom to view all the markers of the map
MAP_Store..Zoom = zoomAdaptSize

3.Save the modifications by clicking


among the quick access buttons.
4.Close the code window (click the cross in the top right corner of the code editor).

Re-run the test of the "WIN_Map_of_stores" window in the simulator (


access buttons). Then, close the simulator.

among the quick

Using a Multiline Zone control


The "Multiline zone" control is often used on the mobile platforms.
This control is used to group several controls:
options on a category,
group of information about a contact, ...
This control can contain at the same time:
lines defined in edit (static lines),
lines defined at run time, by programming (dynamic lines).
A Multiline Zone control will be used to create the main menu of our application. We are going to
create a new window and insert a Multiline Zone control into it.

Part 5: Android and iOS: Developing an application 129

The window that will be created is as follows:

Creating the window


We are going to create a window and add a Multiline Zone control into it.

To create the window:

1.Create a new blank window:


Click
among the quick access buttons.
The window for creating a new element is displayed: click "Window" then "Window". In the
wizard, choose "Blank" and validate.
2.Save the window. Specify the title of the window: "Menu". Its name is automatically
proposed: "WIN_Menu". Validate.

Creating the Multiline Zone control

To create the Multiline Zone control:

1.On the "Creation" pane, in the "Data" group, click "Multiline Zone". The shape of the control
appears under the mouse.
2.Click in the window to create the control.
3.Display the description window of the control (double-click the control for example).
4.In the description window, specify the name of the control ("MZ_Menu") and validate.

The Multiline Zone control contains an empty line. We are going to add as many lines as the
number of options found in our menu.
Our menu will include 3 options:
List of products.
Map of stores.
Exit from the application.

130

Part 5: Android and iOS: Developing an application

Modifying the Multiline Zone control

To modify the Multiline Zone control:

1.Display the description window of the control (double-click the control for example).
2.Click the "New line" button. A window is opened: this window contains all the preset line
templates.
3.Select the "Simple line with picto" template and validate. Repeat this operation twice. Now,
the multiline zone contains:
a "blank" line,
3 "simple lines with picto".

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.
5.Validate the description window. Your menu is created.
Each line includes an Image control, a Static control and an arrow image. We are now going to
modify the Image control and the Static control of each line in order to represent the action of the
menu.
Modifying the 1st line: access to the list of products

To modify the image of the first line found in the Multiline Zone control:

1.Click the first line and select the Image control.


2.Display the description window of the image (double-click the control).
3.In the description window:
Give a name to the image ("IMG_ListOfProducts" for example).
Click the "Catalog" button in order to choose an image representing the action.

Part 5: Android and iOS: Developing an application 131

Notes

In the window of the image catalog, type "List" in the search control and press [ENTER].
Select an image via a double click.
In the window for configuring the generated image, select a size (80 for example), give a
name to the image ("ListOfProducts" for example) and validate.
The image used in a Multiline Zone control is in "Homothetic extended
centered" mode by default. The image will be automatically "resized" to the
proper dimensions.

4.Validate the description window.

To modify the Static control of the first line found in the Multiline Zone control:
1.Click the first line and select the Static control.
2.Display the description window (double-click the control).
3.In the "General" tab of the description window:
Give a name to the control ("STC_ListOfProducts" for example).
Change the caption ("List of products" for example).
4.Validate the description window.

Modifying the 2nd line: access to the map of stores

To modify the image of the second line found in the Multiline Zone control:

1.Click the second line and select the Image control.


2.Display the description window of the image (double-click the control).
3.In the description window:
Give a name to the image ("IMG_MapOfStores" for example).
Click the "Catalog" button in order to choose an image representing the action.
In the window of the image catalog, type "Map" in the search control and press [ENTER].
Select an image via a double click.
In the window for configuring the generated image, select a size (80 for example), give a
name to the image ("MapOfStores" for example) and validate.
4.Validate the description window.

132

Part 5: Android and iOS: Developing an application

To modify the Static control of the second line found in the Multiline Zone control:
1.Click the second line and select the Static control.
2.Display the description window (double-click the control).
3.In the "General" tab of the description window:
Give a name to the control ("STC_MapOfStores" for example).
Change the caption ("Map of stores" for example).
4.Validate the description window.

Modifying the 3rd line: exit from the application

To modify the image of the third line found in the Multiline Zone control:

1.Click the third line and select the Image control.


2.Display the description window of the image (double-click the control).
3.In the description window:
Give a name to the image ("IMG_Exit" for example).
Click the "Catalog" button in order to choose an image representing the action.
In the window of the image catalog, type "Close" in the search control and press [ENTER].
Select an image via a double click.
In the window for configuring the generated image, select a size (80 for example), give a
name to the image ("Close" for example) and validate.
4.Validate the description window.

To modify the Static control of the third line found in the Multiline Zone control:
1.Click the third line and select the Static control.
2.Display the description window (double-click the control).
3.In the "General" tab of the description window:
Give a name to the control ("STC_Exit" for example).
Change the caption ("Exit from the application" for example).
4.Validate the description window.

Programming the menu

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

EndProgram()
END

Part 5: Android and iOS: Developing an application 133

2.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).

Test of the application


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 test of the project:


among the quick access buttons.
1.Click
2.Your project starts with the menu window. Click an option of your menu to check whether
the different links are correct.

134

Part 5: Android and iOS: Developing an application

Lesson 5.3. Managing

the orientation

of windows with the layouts


This lesson will teach you the following concepts...
The benefit of anchors
Creating a layout
Using a layout

Part 5: Android and iOS: Developing an application 135

Overview
In most cases, an application for mobile can be used in portrait mode and in landscape mode.
The interface of a window used in portrait mode can be changed to be used in landscape mode.
WINDEV Mobile manages the change of device orientation via the anchors.
Most of the time, the anchors are sufficient to adapt the display to the different orientations.
However, if the interface must change according to the orientation (different positioning of controls
in portrait mode and in landscape mode for example), the anchors are not sufficient.
To manage a different interface in portrait mode and in landscape mode, WINDEV Mobile gives
you the ability to use the layouts.

To follow this lesson, open (if necessary) the "WM Managing Products" project that was

Answer

created in the previous lesson.

136

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"
group, expand "Tutorial" and select "iOS/Android application (with windows)".
A corrected project is also available. This project groups all the window
developed in this lesson.
To open this corrected project, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "iOS/Android application (Answer)".

Part 5: Android and iOS: Developing an application

Using anchors

The anchors have already been used in the "WIN_Product_form" window. In test mode, we get
the following interfaces:

Notes

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 the 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,
a specific view for the landscape mode,
a view specific to the phone,
a view specific to the tablet,
...

Part 5: Android and iOS: Developing an application 137

To create a new layout:

1.Open the "WIN_Product_form" window if necessary.


2.On the "Window" pane, in the "Layouts" group, expand "Layouts" and select "Add layouts".

3.The wizard for creating a layout starts.


4.The wizard proposes to manage the differences between the phone and the tablet. The
tablets are not used in our example. Keep "This window will be displayed on phone only".

5.Go to the next wizard step.


6.The wizard proposes to manage the Portrait/Landscape orientation of the application.
That's what we are going to do in this example: check "Create layouts, I need to modify the
layout of controls according to the orientation".

7.Go to the next wizard step.


8.The wizard proposes to use a different presentation for each platform used. In this example,
the same presentation will be used for the Android platform and for the iOS platform. Select
"No specific layout for each OS".
138

Part 5: Android and iOS: Developing an application

9.Validate the wizard.

Two layouts are created in our example. These layouts are displayed in thumbnail format, on
the right of the "WIN_Product_form" window.

We are going to modify the layout of the landscape mode:

1.Double-click the thumbnail of the "Landscape - MultiOS Phone" layout: the window
corresponding to this layout is displayed in the middle of the editor.
(top right corner of the main window, in the title bar) to enable the "automatic
2.Click
dissociation" mode. Via this option, any modification performed on one of the specific windows
of the layout will not be applied to the other ones.

Part 5: Android and iOS: Developing an application 139

3.We are going to modify the position of the controls in the layout:
Select the control corresponding to the photo of the product as well as the two buttons and
move them to the left of the window.

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.

140

Part 5: Android and iOS: Developing an application

Select the "Bar code" control as well as its button and position them on the right of the price.

Select the "Description" control and position it on the right of the quantity. Reduce the height
of the control 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.

Part 5: Android and iOS: Developing an application 141

Therefore, we are going to modify the anchor of these controls:

1.Select the Image control and the two buttons.


2.Display the popup menu and select "Layouts .. Dissociate the anchor".

3.Define the new anchor that will be applied to the controls:


Display the popup menu of the controls and select "Anchor".
In the window that is displayed, select
.

You get the following interface:

142

Part 5: Android and iOS: Developing an application

Running the test of the application

To run the test of the project:

among the quick access buttons.


1.Click
2.Your project starts with the menu window.
3.Click the list of products.
4.Double-click a product. The product form appears in portrait mode.
and select Rotation.
5.Change the orientation of the window in the simulator by clicking
6.The layout that was defined for the landscape mode is automatically displayed:

7.Close the test window of the application.

Part 5: Android and iOS: Developing an application 143

Lesson 5.4. Window

with search

This lesson will teach you the following concepts...


Creating a query with parameters.
Creating a window via RAD.
Implementing the search
Managing the "Pull to refresh" feature
Adding a sliding menu

Estimated time: 30 min

144

Part 5: Android and iOS: Developing an application

Overview
In the lesson 5.2, we have explained how to create a window used to list the products in a looper.
We are going to create a window based on the same principle but proposing a search on the
product name:
the window displays the list of products in a looper.
when the user types the name of a product in the search area, the corresponding products are
displayed in the looper.
In our example, this search will be performed on the "Product" file.
The interface of the "WIN_Menu" window is as follows:

Notes

To create this window, we are going to:


Create the query for selecting records in the Product file.
Create and configure the search window.

What is a select query?


A select query is a query that will only "choose" the records that match the
criteria.
This type of query is called a select query because the SELECT command is used
in SQL language.

Part 5: Android and iOS: Developing an application 145

Answer

If the "WM Managing Products" application was not created in the previous part:
an intermediate project is available. This project contains the windows created
in the previous parts. This project allows you to follow this lesson and to create
the new windows.
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)".

Creating the query used to find the products


Creating the query

The query editor will be used to create the query.

1.Click
among the quick access buttons. The window for creating a new element is
displayed: click "Query". The wizard for query creation starts.
2.Select "Select".
Indeed, the query that will be created will allow us to select records. Go to the next step.
3.The description window of the query is displayed.
4.Give a name and caption to your query: enter "QRY_Products" instead of "QRY_NoName1" in
the "Query name" area and "Finding products on the name" in the "Caption" area:

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.

146

Part 5: Android and iOS: Developing an application

2.The description window of the query is as follows:

3.Validate the description window of the query (green button at the bottom of the screen).
4.The graphic representation of the query is displayed.
5.Save the query by clicking
among the quick access buttons.
6.Validate (if necessary) the backup window of the query.

Part 5: Android and iOS: Developing an application 147

Test of the query


Like all the elements found in a WINDEV Mobile project, you have the ability to run the test of the
query that was just created:
1.Click
.
2.The result is displayed in a window:

The result lists ALL the products.


In our case, we want to display the products corresponding to the search criteria, the name of
the product. To do so, we must use a query with parameters.
3.Close the window.
Adding a selection condition
In our example, the user will be able to select a value for the product name. We must modify the
query in order for this search criterion to correspond to a query parameter.

To define a query parameter, display the description window of the query: double-click the

background of the graphic representation of the query (or select "Query description" from the
popup menu).

148

Part 5: Android and iOS: Developing an application

To manage the "Product name" parameter:

1.Select the Product.Name item (in the middle of the screen).


2.Display the popup menu and select "Selection condition .. New condition".

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.

5.Validate the description window of the query.

Part 5: Android and iOS: Developing an application 149

6.The query graph is modified to take into account the selection condition that was defined.

7.Save the query by clicking

among the quick access buttons.

Test of the query with parameters

To run the test of the query with parameters:


1.Click
.
2.A window is displayed, allowing you to enter the different parameters of the query.
3.Select the ParamName parameter. In the bottom section of the screen, type "Polo".

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.

150

Part 5: Android and iOS: Developing an application

Creating the interface

Notes

The search window will be created via the wizard for creating RAD windows (Rapid Application
Development).
The wizard for window creation proposes several windows generated by RAD.
These windows, generated from your data, propose modern interfaces for your
applications and they can be immediately used.

Creating the window

To create the search window:


1.Click
among the quick access buttons. The window for creating a new element is
displayed: click "Window" then "Window".
2.In the wizard, select the "Standard" tab, choose "Looper" and validate.
3.The wizard for creating a RAD window starts.
4.Choose the platform to use: "Generic Android phone". Go to the next wizard step.
5.The wizard proposes to choose the data source associated with the window. In our case, it
is a query:
Click "Queries".
Select the query that was just created: "QRY_Products".

6.Go to the next step.


7.Select the style of the looper: "Image + Title + Caption below". Go to the next step.
8.The wizard automatically proposes the query items corresponding to the generated looper.
Keep the proposed options and go to the next step.
9.Change the suggested sort and choose the "Name" item. Go to the next step.
10.The wizard proposes several options for generating the Looper window. In our example,
keep the default options. Go to the next step.
11.Give a title and a name to the generated window. In our case:
For the title, type "Products".
For the name, type "WIN_List_of_products_Advanced".

Part 5: Android and iOS: Developing an application 151

12.Validate the wizard. The window is automatically created, displayed in the editor and
saved.

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, enter 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, enter the following code in the "Selecting a row..." section:
HReadSeek(Product,ProductID,QRY_Products.ProductID)
OpenMobileWindow(WIN_Product_form)

Let's study this code:


The Looper control is based on the QRY_Product query. When selecting the product in the
looper, the selected record is the one found in the query.
During a click on the control row, we want to open the form window that was created
beforehand. This window is based on the Product file.
The record selected by the query must be found in the "Product" file in order to load the
buffer of selected data in memory. The operation is performed by HReadSeek.
Then, the form window named "WIN_Product_form" is opened by OpenMobileWindow.

152

Part 5: Android and iOS: Developing an application

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).
6.Run the test of the window that was just created in the simulator (
among the quick
access buttons).

7.Click one of the products: the form window is displayed.


8.End the test.
Managing the search
We are now going to manage the search. To do so, we are going to:
Allow the search in the Action Bar.
Create a search button in the Action Bar.

To allow the search in the Action Bar:

1.Display (if necessary) the "WIN_List_of_products_Advanced" window in the editor.


2.Display the description window of the Action Bar (double-click the Action Bar).
3.In the "Details" tab, check "Allow the search in the Action Bar".

Part 5: Android and iOS: Developing an application 153

To create a search button in the Action Bar:

1.In the "General" tab of the description window of the Action Bar:
2.Click number 2. The interface for entering an option in the toolbar is displayed.
3.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 "Find".
In the "Preset image" area, expand the list and select "Find".
Validate the description window.
4.The code of this option is used to make the search area visible. To enter this code:
Select (if necessary) the Action Bar of the window.
Click the search button.
A drop-down menu with the "Find" option is displayed.
Right-click the option.
Select "Code" from the popup menu.
In the "Selecting the menu" process, enter the following code:
ActionBarSearchVisible(True)

5.Save the modifications by clicking


among the quick access buttons.
6.Close the code window (click the cross in the top right corner of the code editor).
7.Select the Action Bar and display the associated code (press F2 or select "Code" from the
popup menu).
8.In the code editor, enter the following code in the "Validating the search..." section:
QRY_Products.ParamName = ACTB_ActionBar..SearchValue
LooperDisplay(LOOP_QRY_Products,taReExecuteQuery)

9.Let's study this code:


The query parameter is initialized with the search value entered in the Action Bar.
Then, the Looper control is redisplayed by LooperDisplay. The taReExecuteQuery constant
is used to re-run the base query of the Looper control and therefore to take the new
parameter into account.
among the quick access buttons.
10.Save the modifications by clicking
11.Close the code window (click the cross in the top right corner of the code editor).
12.Run the test of the window that was just created in the simulator (
among the quick
access buttons).
Click the magnifier.
Type "Polo" in the search area.
Validate (ENTER key).
The list of products containing "Polo" is displayed.

154

Part 5: Android and iOS: Developing an application

13.Close the simulator.

Improving the window


Managing the "Pull to refresh" feature
A new feature will be added to our window: the management of the "Pull to refresh" feature. This
feature allows the user to "pull" a Table or Looper control in order to refresh its content.
During this action, a refresh bar automatically appears in the exposed area:
The bar indicates that you must pull to refresh.
Then, the bar indicates that you must release to refresh.
The bar indicates that the refresh operation is in progress. A progress bar is displayed during the
refresh duration.
The control is updated.

To use the "Pull to Refresh" feature:

Notes

1.Display (if necessary) the "WIN_List_of_products_Advanced" window in the editor.


2.Select the Looper control and display the description window of the control.
3.In the "Details" tab of the description window of the control, in the "Moves and gestures"
area, check "Refreshing by pull/release".

A specific internal window can be used to manage the "Pull to refresh" feature. In
this example, we will be using the default window. See the online help for more
details.

4.Validate the description window of the control.

Part 5: Android and iOS: Developing an application 155

The setting of "Pull to refresh" has added:

the refresh bar that will be displayed to the user during the operation.
the "Refreshing by pull/release" process among the processes of the Looper control. This
process is automatically called during the refresh gesture. We are now going modify this
process in order to manage the control update.

To modify the "Refreshing by pull/release" process:

1.Select the Looper control and display the associated process (press F2 for example).
2.In the code editor, enter the following code in the "Refreshing by pull/release..." section:
LooperDisplay(LOOP_QRY_Products,taReExecuteQuery)

3.As already seen for the management of the search, 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.
among the quick access buttons.
4.Save the modifications by clicking
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.

6.Close the simulator.


This example allows you to understand the implementation of the "Pull to refresh" feature.
This feature can be used for example in the same application in HFSQL Client/Server where
other users would update or add products. These modifications could be displayed by the "Pull to
refresh" feature.

156

Part 5: Android and iOS: Developing an application

Using a sliding menu


In several mobile applications, the menu does not correspond to a "static" window. It corresponds
to a sliding window displayed via an option of the Action Bar and/or via a swipe of the window.
We are going to modify the "WIN_List_of_products_Avanced" window in order to add a "sliding
menu". This menu will be using the Multiline Zone control of the "WIN_Menu" window that was
created beforehand.

To create a sliding menu, we are going to:

Notes

Create an internal window. This internal window will contain the menu options.
Modify the "WIN_List_of_products_Advanced" window to display the menu.
An internal window is a simple window with no Action Bar and no toolbar. An
internal window is used to easily include a set of controls in another window.

To create the internal window containing the menu:


1.Click
among the quick access buttons. The window for creating a new element is
displayed: click "Window" then "Internal window".
2.The internal window is automatically opened in the editor.
3.Display the description window of the internal window ("Description" from the popup menu).
4.In the "GUI" tab, specify the dimensions of this internal window:
Width: the one that suits you. It must be sufficient to entirely see the controls of the dropdown menu. Practically, the width of the sliding menu must be smaller than the width of the
window above which it is displayed (260 for example).
Height: This height must correspond to the height of the window above which the sliding
menu is displayed. In our case, this height is set to 248.

5.Validate.
6.Save the window by clicking

among the quick access buttons.

Part 5: Android and iOS: Developing an application 157

7.In the window that is displayed, enter the name of the internal window: "IW_MLZ_Options".

8.Validate.

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:

158

Part 5: Android and iOS: Developing an application

We are now going to modify the WLanguage code used to open the list of products. Indeed:

we work with the "WIN_List_of_products_Advanced" window and not with the "WIN_List_of_
products" window anymore.
the "WIN_List_of_products_Advanced" window contains the sliding menu. Therefore, the
"List of products" option must not re-open this window.

We are going to change the selection code of the Multiline Zone control.
1.Select the Multiline Zone control.
2.Display the associated processes ([F2] key).
3.Replace the line:

CASE 1 // List of products



OpenMobileWindow(WIN_List_of_products)

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.
among the quick access buttons.
4.Save the modifications by clicking
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.

Part 5: Android and iOS: Developing an application 159

5.The window being associated with an Action Bar, the editor proposes to enable the option
used to open the sliding window.

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.

among the quick access buttons.


2.Click
3.When clicking the menu of the Action Bar, the sliding window of the menu appears.

160

Part 5: Android and iOS: Developing an application

Lesson 5.5. Window

with scroll

This lesson will teach you the following concepts...


Creating an internal window by refactoring.
Changing the content of a window by swipe

Estimated time: 20 min

Part 5: Android and iOS: Developing an application 161

Overview

Answer

In the Windows applications, all the operations are performed via the mouse or the keyboard.
In mobile, the interfaces must be configured differently. With the touchdown screens, all the
operations are performed with the fingers.
In the applications for mobile devices, WINDEV Mobile proposes several features to manages the
specific moves of fingers (pull to refresh, double touch, sliding, ...).
In this lesson, we are going to create a new form window, used to view the products.
In this window, you will have the ability to go from a product form to another one by swipe.
If the "WM Managing Products" application was not created in the
previous part, 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)".

Creating the Form window with swipe


Creating the Form window

To create the form window:

1.Create a new blank window.


Click
among the quick access buttons.
The window for creating a new element is displayed: click "Window" then "Window".
In the wizard, select the "Standard" tab, choose "Blank" and validate.
2.Save the window. Specify:
the title of the window: "Product form".
the name of the window: "WIN_Product_form_Advanced".
3.Validate.
We are now going to create an Internal Window control in the "WIN_Product_form_Advanced"
window. This control will host an internal window that will display the data to scroll.

To create the Internal Window control:

1.On the "Creation" pane, in the "Containers" group, expand "Internal window" and select "Swipe
area (Internal window)".
2.Click the position where the control must be created in the window (top left corner).
3.Resize the Internal Window control so that it occupies the entire available space in the
window.

162

Part 5: Android and iOS: Developing an application

4.Modify the anchor of the Internal Window control ("Anchoring" option from the popup menu):
anchor the control in height and in width (
).
5.Validate.
Creating the internal window

To simplify the creation of the internal window, we are going to create it from the "WIN_Prod-

uct_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.

Managing the swipe in the form window

To associate the internal window with the Form window:

1.Display the "WIN_Product_form_Advanced" window in the editor (click its name in the bar of
opened elements).
2.Select the Internal Window control and display its description ("Description" from the popup
menu).
3.In the "General" tab, select the internal window that was just created ("IW_Product").

Part 5: Android and iOS: Developing an application 163

4.In the "GUI" tab, in the "Changing content by swipe" area:


The option "Allow the change of content by swipe" is already checked because the Internal
Window control was chosen for swipe.
Check "Position on the current record when opening the internal window".

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.

6.Validate the description window.


The swipe is implemented.

164

Part 5: Android and iOS: Developing an application

In order not to be bothered by the keyboard appearance during the swipe, we are going to use

SIPVisible:
1.In the "WIN_Product_form_Advanced" window, display the processes of the Internal Window
control.
2.In the "Selection by swipe..." process, enter the following code:
SIPVisible(False)

3.Close the code editor.

To end this window, we are going to add the validation option into the Action Bar of the

window (this operation was already performed before page 114, we will present the
important points only):
1.Select the Action Bar (at the top of the window).
2.Display the description window of the Action Bar.
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".
In the "Preset image" area, expand the list and select "Validate".
Validate the description window.
6.To enter the code used to save the modifications performed in the "WIN_Product_form_
Advanced" window:
Select (if necessary) the Action Bar control of the window.
Click "OK".
A drop-down menu with the "Validate" option is displayed.
Right-click the option.
Select "Code" from the popup menu.
In the "Selecting the menu" process, enter the following code:
ScreenToFile()
HSave(Product)
Close()

7.Save the modifications by clicking


among the quick access buttons.
8.Close the code window (click the cross in the top right corner of the code editor).

Part 5: Android and iOS: Developing an application 165

Test of the window


Before running the test of the window, we are going to modify the "WIN_List_of_products_
Advanced" window to directly open the from window that was just created.

To open the window with swipe from the list of products:

1.Display the window "WIN_List_of_products_Advanced" in the editor (click its name in the bar
of opened elements).
2.Display the processes linked to the Looper control.
3.In the process "Selecting a row... ", replace the code:
HReadSeek(Product,ProductID,QRY_Products.ProductID)
OpenMobileWindow(WIN_Product_form)

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:
among the quick access buttons.
1.Click
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.

166

Part 5: Android and iOS: Developing an application

Conclusion
This part explained the main concepts for developing Android or iOS applications.
Several themes have not been presented in this part:
managing the emails,
managing the notifications,
using visualization panel,
using the debugger,
...
Don't hesitate to see the online help to discover and check new features.

Part 5: Android and iOS: Developing an application 167

Lesson 5.6. Deploy

the application

This lesson will teach you the following concepts...


Generating the Android application.
Generating the iOS application.

Estimated time: 20 min

168

Part 5: Android and iOS: Developing an application

Overview
That's it, our application is created, we must now compile it and install it on the device in order to
run its test.
If you have chosen to develop the application for Android only, you can follow the generation of the
Android application.
If you have chosen to develop the application for iOS, follow the generation of the iOS application,
page 173.
If you want to develop the application for the two platforms, follow the generation for Android then
the generation for iOS.

Generating the Android application

To generate the Android application:

1.Select (if necessary) the Android platform in the project explorer.


2.On the "Project" pane, in the "Generation" group, click "Generate" (you also have the ability
to click
among the quick access buttons).
3.The wizard for generating an Android application starts.
4.The first wizard step consists in checking the tools required to generate the Android
application.

The wizard proposes to:


download and install the Android SDK and Gradle: in this case, you will only have to validate
the license. WINDEV Mobile takes care of everything. If an update is available, the generation
wizard will automatically propose to perform the necessary updates. Only an Internet
connection is required.
Use the tools automatically installed. This option is available if the tools have been
downloaded and installed during a previous generation.
Specify the location of the tools already installed on your computer. In this case, all you
have to do is specify the setup paths of Gradle and Android SDK.
5.Select the option corresponding to your configuration and go to the next step.
Note: If you have chosen to download and install the tools, going to the next step may be quite

Part 5: Android and iOS: Developing an application 169

long and you may have to validate the license.


6.Go to the next step by clicking the arrow keys at the bottom of the window. The next wizard
step is used to:
define the name of the application (displayed below the icon used to start the application)
and the corresponding package.
select the icon of the application in the image catalog of WINDEV Mobile ("stock" in the "Flat
Soft" theme for example).

Notes

7.Go to the next step. 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 tests of the application. A specific signature is required to
distribute the application. See the online help for more details.
10.The next step is used to include the data files in the application. For our example, pre-filled
HFSQL data files are available. They will be supplied with the application. In this case, they
must be specified in the "Integrating files" screen.
Click the "Add" button.
Select the data files (.fic, .ndx and .mmo) found in the "EXE\Android application" directory of
the project. The list of files is displayed.

170

If your project is using the Android platform only, the files must be selected in the
EXE directory of the project.

Part 5: Android and iOS: Developing an application

11.Check the "Write" box for each file (required to be able to modify the data from the
application).

12.Go to the next step.


13.The "Including libraries" screen is used to include specific libraries (HFSQL and Java).

Check "Include the HFSQL libraries in the application".


14.Validate the other steps until you reach the "Configuration" screen. This screen is used to
configure the options of Android SDK and the setup location.

15.Go to the next step.


16.This screen is specific to the use of the Map control. This screen allows you to enter the
key required to use the Map control. If you own a Google Maps API key, enter it. Otherwise,
click "Get a key".

Part 5: Android and iOS: Developing an application 171

17.The last wizard screen is used to specify whether the application must be copied and run
on the device connected to the computer or on an emulator. If you own an Android device
connected to the development computer, check this option.

172

Part 5: Android and iOS: Developing an application

Notes

18.A new screen allows you to select the runtime device. If you own an Android device
connected to the development computer, select the device connected to the PC.
19.The generation of the Android application is performed.

If the device is not connected to the development computer, you must:


1.Connect the device to the development computer.
2.In the explorer, open the generation directory of the apk file corresponding
to the Android application.
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 the "Download" directory and run the apk file. The application is
automatically installed.

Generating the iOS application

To generate the iOS application:

Notes

1.Select (if necessary) the iOS platform via the project explorer.
2.On the "Project" pane, in the "Generation" group, click "Generate" (you also have the ability
among the quick access buttons).
to click
3.The wizard for generating an iOS application starts.
4.The wizard is used to:
define the name of the application, the company and the copyright.
enter the bundle identifier.

This identifier is the unique identifier of your application beside Apple. It is


defined and saved on the Apple developer account.
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 standards of Apple. This identifier can be modified.

Part 5: Android and iOS: Developing an application 173

5.Go to the next step. Specify the path of the different icons found in the application for each
type of device.
6.Go to the next step. Specify the path of the different images used when starting the
application for iPad and for iPhone (images in PNG format). Default images are automatically
created for your application.
7.Go to the next step. Specify the version number of the generated application.
8.Go to the next step. This step is used to include specific files (data files, images, ...).
Click the "Add" button.
Select the data files (.fic, .ndx and .mmo) found in the "EXE\iOS application" directory of the
project. The list of files is displayed.

9.Indicate that these data files must be in write mode: check the "Write" box.
10.Go to the next step.

174

Part 5: Android and iOS: Developing an application

11.The wizard allows you to specify:


the minimum iOS version required to run the application.
whether files can be shared with iTunes. If this option is checked, you will have the ability to
retrieve the application files on Mac during the synchronization. For example, if data files
have been supplied with the application, the iTunes application will allow you to retrieve
these files.

12.Validate the wizard.


13.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
Transfer the WINDEV Mobile project onto Mac

To transfer the WINDEV Mobile project onto MAC:

1.Copy the entire folder generated in the EXE directory onto an external media (USB key, external
hard disk, shared directory with MAC on network). This directory is named <Project Name>.
xcode.gen.
2.Paste this folder onto the MAC where the application will be compiled.
3.Open the folder on MAC and double-click the folder named "Project_name.xcodeproj".
4.The project is opened in Xcode.

Part 5: Android and iOS: Developing an application 175

Compile the project in Xcode


WINDEV Mobile automatically generates an Xcode project for your iOS compilations. To simplify
the implementation of applications, WINDEV Mobile generates a "Scheme" for Xcode.

To compile the project in Xcode:

1.In the drop-down list found in the top left corner, select the compilation options. Select the
scheme corresponding to your application then the compilation target (device currently
connected or a simulator).
2.To start the compilation, select "Product .. Clean" then "Product .. Build".
3.A status report of compilation is displayed at the top ("Succeeded" or the number of
warnings and errors otherwise). You have the ability to click these symbols to see the list of
errors/warnings.
4.Once the program is compiled without error, you can start the simulation ("Product .. Run").
The simulation window appears with the application.
Then, you have the ability to run the test of your application on your iPhone or iPad.

176

Part 5: Android and iOS: Developing an application

PART 6
Windows
Mobile
application

178

Part 6: Windows Mobile application

Lesson 6.1. My
Mobile project

first

Windows

This lesson will teach you the following concepts...


Creating Windows Mobile project
My first window
My first test
First deployment

Estimated time: 1 h

Part 6: Windows Mobile application 179

Overview
To start working with WINDEV Mobile, we are going to create a first project. This project will contain
a window used to display a message.
This first example will present the main concepts of development with WINDEV Mobile.

My first project
Create the project

Answer

We are going to create our first project for Windows Mobile. If you own the mobile device
(Smartphone or Pocket PC) on which the application must be run, we advise you to connect
this device to the development computer. Therefore, the characteristics of the device will be
automatically detected and proposed when creating the Windows Mobile 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)".

To create a project:

1.Start WINDEV Mobile 21 (if not already done). Close (if necessary) the current project in order
to display the home window.
2.In the home window, click the "Create a project" icon then "Windows Mobile application".

Notes

The wizard for project creation starts. The different wizard screens help you create your
project. The information specified in this wizard can be modified later.

180

Tip: Other method for creating a project:


among the quick access buttons of the WINDEV Mobile menu.
1.Click
2.The window for creating a new element is displayed: click "Project".

Part 6: Windows Mobile application

3.The first wizard screen is used to enter the name of the project, its location and its
description. In our case, this project will be named "My_Pocket_Project". WINDEV Mobile
proposes to create this project in the "\My Mobile Projects\My_Pocket_Project" directory. You
can keep this location or modify it via the [...] button.

4.Go to the next screen via the arrows found at the bottom.
5.The wizard proposes to add documents. Keep the default options and go to the next screen.
6.The next screen 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 screen to manually define the characteristics of the
device used.
7.If you have no device, the next screen allows you to choose the device that will be used to
develop your application.
Caution: this screen 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 screen.

Part 6: Windows Mobile application 181

8.The description window of your device is displayed.

Go to the next screen.


9.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 screen via the
arrows found at the bottom.
10.This step is used to define the style book. Select "Elegant".
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.

182

Part 6: Windows Mobile application

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 Windows Mobile application with WINDEV Mobile.
Creating the window

To create the window:

1.In the window for creating a new element, click "Window" then "Window".

Note

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 the WINDEV Mobile:

Note

2.The wizard for window creation starts.


3.Select "Blank" in the list of windows displayed on the left. In the list of skin templates found
on the right, the "Elegant" skin template is selected by default. You can choose another skin
template proposed in the list.
The skin templates allow you to quickly create outstanding interfaces. A skin
template defines the style of the window but also the style of all the controls that
will be used in this window. No ugly interface anymore.

4.Validate. The window is automatically created in the editor.

Save the window by clicking

among the quick access buttons. During the first backup, a


specific window is displayed. This window proposes to enter:
the title of the element: enter "Welcome". In our case, this title will be displayed in the title
bar of the window.
the name of the element that corresponds to the name of the window. This name will be
used in programming. By default, this name includes "WIN_" that corresponds to the
programming charter and "Welcome" that corresponds to the title of the window.

Part 6: Windows Mobile application 183

Note

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:
a window starts with "WIN_",
a button starts with "BTN_",
etc.
If you don't want to use this charter, all you have to do is disable it: on the
"Project" pane, in the "Other actions" group, expand "Charter" and uncheck "Use
the charter".

the location that corresponds to the file name created for the window. The window is a file
whose extension is "WDW", saved in the project directory.

Click the green button to validate.


Display 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 must 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.

184

Part 6: Windows Mobile application

Modify the characteristics of the control by entering the following information:

1.Name of this control: "BTN_Display".


2.Caption of this control: "Display"

Validate the description window of the control (green button). The control appears in the
window editor.

We are going to display a message in a dialog box (a small window proposed by the system).
Notes

To do so, we will be using our first WLanguage function: Info.

The programming language supplied with WINDEV Mobile is named WLanguage.


It is a 5th generation language (5GL) that includes highly sophisticated
commands.

1.Select the "Display" button with the mouse: all you have to do is click it.
2.Display the popup menu of the control (right mouse click).
3.Select "Code". This option opens the code editor of WINDEV Mobile, where all the
WLanguage statements can be entered.
4.Enter the following code in the "Click BTN_Display" process:
Info("Hello")

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 press the
[ENTER] key to validate. 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,
the character strings (between quotes) are colored in purple,
the names of controls are colored in cyan.
These colors can be modified element by element in the code editor options
(on the "Home" pane, in the "Environment" group, expand "Options" and select
"Options of the code editor").

Info displays the message passed in parameter.

Part 6: Windows Mobile application 185

To save the modifications, click


by pressing [CTRL] + [S].

among the quick access buttons (on the left of ribbon) or

Close the code window (cross at the top right of the code editor). The window re-appears.
First test
For a Windows Mobile application, WINDEV Mobile allows you to run the application test on the
development computer via the simulation mode. This test simulates a Windows Mobile device on
the development computer. This test is useful when the developer is not equipped with a Windows
Mobile device. However, this test does not allow you to use the hardware components of the
device (SMS, ...).

Let's now run the test of the window 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.The created window is started in execution. The simulator shell corresponds to:
the device connected to the development computer,
the device chosen in the wizard for project creation.
4.Click the "Display" button.
5.Validate the system window that is displayed.

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.
186

Part 6: Windows Mobile application

First deployment on the device


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

To generate the Windows Mobile application:

1.On the "Project" pane, in the "Generation" group, click "Generate" (you also have the ability to
among the quick access buttons).
click
2.WINDEV Mobile proposes to select the first project window. In our example, select "WIN_
Welcome" and validate (green button at the bottom of the screen).
3.The wizard for creating a mobile executable starts.
4.The first wizard screen is used to define the name and icon of the application.

Notes

The icon of the executable 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.
To perform a search in the image catalog:
specify the keyword corresponding to the search,
validate. The images found are automatically displayed.
By double-clicking the requested image, this one is generated and included in
your project.

5.The other screens are not required by our application. Click the "2- Copy onto the mobile"
link found on the left of the wizard.

Part 6: Windows Mobile application 187

6.This screen is used to define the options for copying files onto the mobile:

7.The options depend on your configuration:


If a mobile is connected, select "Yes: Copy the executable to the Pocket PC" as well as "Run
the application on Pocket PC at the end of copy". In this case, once the executable is
generated, the application will be automatically copied and started on the mobile.
If no mobile is connected, select "No: Don't copy the executable to the Pocket PC". In this
case, the application can be deployed on the mobile devices via a setup procedure.
8.Validate.
That's it, our first application is generated and run on the Windows Mobile device.

188

Part 6: Windows Mobile application

Lesson 6.2. Databases


This lesson will teach you the following concepts...
Available databases
Synchronization

Estimated time: 30 min

Part 6: Windows Mobile application 189

Format of the databases


A Windows Mobile application can handle data. The format of these databases can be:
HFSQL (in Classic or Client/Server mode), database system supplied with WINDEV Mobile.
CEDB, database system that can be used on mobile device (Pocket PC).
AS/400, AS/400 database that can be used on mobile device (Pocket PC).
...
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 memory of the device. The maximum storage size depends on the
amount of memory on the device.
In the "Advanced programming" lesson, we will develop an application that uses a HFSQL Classic
database.
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.

190

Example

The "Pocket Notes" and "Pocket Telephony" examples (supplied with WINDEV
Mobile) are using HFSQL data files.
These examples are accessible from the home windows.

Notes

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.

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.

Part 6: Windows Mobile application

CEDB
The CEDB format is a database format that can be used on the mobile devices (Pocket PC).
A CEDB database corresponds to a ".CDB" file. A CEDB database can contain several data files
(also called "tables").
Two types of CEDB databases are available:
the standard CEDB databases, that correspond to the databases found by default on the
mobile device. These databases contain the following data files: "Tasks", "Contacts",
"Appointments", ...
the other CEDB databases (called custom databases), that correspond to Access databases
(".MDB" files) previously exported from a PC.
Note: When an Access database (".MDB" file) is copied onto a mobile device (via the file explorer),
this database is automatically transformed into a CEDB database (".CDB" file).

Notes

Caution: From Windows Mobile 5, the access to a standard database (tasks,


contacts, appointments, ...) is no longer possible from a Windows application
(and therefore from a WINDEV application).
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.

Notes

Caution: The structure of the CEDB databases is not intended to process a large
amount of data. Therefore, we recommend that you use HFSQL databases.
Furthermore, HFSQL allows you to benefit from all the features available in
WINDEV Mobile (RAD, file link, ...).

Notes

A CEDB database can be handled:


from a WINDEV Mobile application.
from a WINDEV application.
These operations are performed by the cdbXXX functions of WLanguage.

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.

Part 6: Windows Mobile application 191

Sharing data between two applications


A WINDEV Mobile application for Windows Mobile can share data with a WINDEV application.
You have the ability to use:
a WINDEV application used to handle the entire database.
a WINDEV Mobile application used to handle the entire database or part of this database.
When two applications share the same data, the data files can be managed according to two
different methods:
Handling the same data files:
The two applications handle the same data files. These data files are found on the PC. The
WINDEV Mobile application accesses the data files by Wi-Fi, by infrared, by GPRS, ...
HSubstDir allows you to specify the data directory to use.

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

Connection: USB, Wi-Fi, Bluetooth...


ActiveSync

Synchronization via ActiveSync

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.

192

Part 6: Windows Mobile application

Handling the same data files

Example

To allow the WINDEV Mobile application to access the data files found on the PC:
the mobile devices must have network access (Ethernet card, Wi-Fi, etc.)
the data found on the PC must be accessible in read/write via a UNC path (the directory
used must be a shared directory).
Then, the data can be handled (addition, modification and deletion) by the HFSQL functions.
Databases in HFSQL format (on the Pocket PC and on the PC)
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.

Example

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)
The "Sending SMS", "Managing lists of purchases" and "Stocks" examples
(supplied with WINDEV Mobile) include a project that can be used on mobile
device (Pocket PC for example) and a project that can be used on PC. These
examples present the synchronization of data entered in the two projects.

Part 6: Windows Mobile application 193

Lesson 6.3. Advanced

programming

This lesson will teach you the following concepts...


Creating a management application
Handling the database

Estimated time: 1 h

194

Part 6: Windows Mobile application

Overview
In this lesson, we are going to develop a Windows Mobile application that is using a HFSQL Classic
database.
This application will allow us to present some specific features of the programming for Windows
Mobile.
Opening the project

Start WINDEV Mobile 21 (if not already done). Close (if necessary) the current project in order
to display the home window.

Open the "Pocket Managing Products" project.

Answer

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
created in this lesson. To open the corrected project, on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Pocket Managing Products
(Answer)".

Project description
Let's take a look at our initial project. This project is an existing project. It contains no window. It
only contains the analysis describing the HFSQL Classic data files that will be used. In the EXE
directory, the corresponding data files are supplied with data in order to run the different tests.

To view the analysis associated with the project:


1.Click
among the quick access buttons of the WINDEV Mobile menu.
2.The data model editor is displayed.

Part 6: Windows Mobile application 195

3.This analysis includes 3 data files:


A "Product" file, that contains the description of the product: name, price, quantity, ...
A "Characteristic" file, that contains the different characteristics of the product. For example,
if the product is a tee-shirt, its characteristics will correspond to the size, the color, ...
Therefore, the "Characteristic" file is linked to the "Product" file.
A "Store" file, that contains the GPS coordinates of each store.
4.Close the data model editor (click the cross at the top right of the editor).
We are now going to develop our application.

Display the list of products


We are going to create a window used to list the different products. These products will be
displayed in a "Table" control.
Creating the window

To create a new window:


1.Click among the quick access buttons. The window for creating a new element is displayed:
click "Window" then "Window".
2.In the wizard, display the "Standard" tab, choose "Blank" and validate.
among the quick access buttons.
3.Save the window by clicking
4.In the window that is displayed, enter the title of the window: "List of products". The name
and location of the window are automatically filled. Keep the default values and validate
(green button at the bottom of the dialog window).
5.The window is added to the project.
Creating the Table control
To display the list of products, we are going to use a "Table" control. The main information about
the products will be displayed in this control.

To create the "Table" control:

1.On the "Creation" pane, in the "Data" group, expand "Table" and select "Table (Vertical)".

2.The control appears under the mouse.


3.Click the position where the control must be created in the window (at the top for example).
The wizard for creating a Table control starts.

196

Part 6: Windows Mobile application

4.In the wizard, select "Display the data found in a file or in an existing query". Go to the next
screen.
5.Select the "Product" file. Go to the next screen.
6.Select the items to display:

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.

Part 6: Windows Mobile application 197

Notes

The data automatically appears in the window displayed in the editor. This
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.

Save the window by clicking among the quick access buttons.


We are going to run a first test in the simulator to view the result. Click
access buttons (or press [F9]).

among the quick

Close the simulator to go back to the window editor.


Creating the form window
We are now going to create a new window used to display the product form. Then, this window will
be started from the list of products to display the details of the selected product.
Creating the window

To create the form window:

1.Create a new blank window. Click


among the quick access buttons. The window for
creating a new element is displayed: click "Window" then "Window".
2.In the wizard that starts:
Select the "Standard" tab.
Choose "Blank".
3.Validate the wizard.
4.Save the window. Specify the title of the window: "Product form". Its name is automatically
proposed: "WIN_Product_form". Validate.

198

Part 6: Windows Mobile application

Creating the controls

To create an edit control:

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 "Pocket
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", "Bar Code", "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.

Part 6: Windows Mobile application 199

5.Reorganize the controls in the window.

Respect the following order: "Photo", "Name", "Price", "Quantity", "Bar Code", "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 test of the window (


with empty controls.

among the quick access buttons). The window is displayed

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.
The code editor appears.
2.Enter 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
record.
3.Close the code window (click the cross in the top right corner of the code editor).
4.Save the window.

200

Part 6: Windows Mobile application

Displaying the form from the list of products


Let's see how to display the form of the selected product in the list of products.

Perform the following operations:

1.Position on the "List of products" window: click the "WIN_List_of_products" button found in
the button bar:

: the shape of the button


2.On the "Creation" pane, in the "Usual controls" group, click
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 button caption 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
displayed in the button.
5.Right-click the button and select "Code" from the popup menu.
6.In the code window that is displayed, enter the following code in the "Click" process:

Notes

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
the mouse.
If the name of the window is not displayed in the list, it means that this window
was not saved beforehand.

7.Save the modifications by clicking


among the quick access buttons.
8.Close the code window (click the cross in the top right corner of the code editor).

Re-run the test of the window in the simulator (

among the quick access buttons).


In the list of products, click one of the products with the mouse.
Click the "Modify the element" button.
The detailed window of the product is displayed.

Close the simulator.

Part 6: Windows Mobile application 201

Managing the creation and the modification of a product


We are now going to modify our two windows in order to manage the addition and the modification
of a product.
Modifying the product form

Notes

We are going to add a button into the "WIN_Product_form" window: a "Validate" button to manage
the validation of modifications.
In the applications for Windows Mobile, the use of a "Cancel" button is not
required. Indeed, the user can just click the cross (top right of the window) to
cancel the input performed.

To create the "Validate" button in the "WIN_Product_form" window:

1.Display (if necessary) the "WIN_Product_form" window in the editor: click the corresponding
button in the button bar.
2.On the "Creation" pane, in the "Usual controls" group, click
: the shape of the button
appears under the mouse. Then, click inside the window to create the button (beside the
image for example).
3.Select the control and press the [ENTER] key on the keyboard. The button caption becomes
editable. Type "Validate" and press the [ENTER] key on the keyboard.

4.Resize the button if necessary (with the handles) in order for the caption to be entirely
displayed in the button.

We are now going to enter 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()

202

Part 6: Windows Mobile application

Let's study this code:


ScreenToFile is used to initialize the items with the values of linked controls, for the current
record.
HModify is used to update the file data for the current record.
Close is used to close the form and to go back to the "WIN_List_of_products" window.
among the quick access buttons.
3.Save the modifications by clicking
4.Close the code window (click the cross in the top right corner of the code editor).

Display the "WIN_List_of_products" window in the window editor and run its test in the

simulator ( among the quick access buttons).


In the list of products, click one of the products with the mouse: for example, the "Polo
Hibiscus Blue" product whose price is 25.90 Dollars.
Click "Modify the element".
The detailed window of the product is displayed. Modify the price of 25.90 Dollars and enter
19.90 Dollars, then click the "Validate" button.
When going back to the list of products, you will notice that the price was updated for this
article.

Close the simulator. The editor of WINDEV Mobile is displayed.


Creating a new product
The principle for creating a product is as follows:
In the window for the list of products, we are going to add a "New product" button that will be
used to open the "Product form" window.
Then, we will modify the code of the "Product form" window to manage the addition into the
Product data file.

Display (if necessary) the "WIN_List_of_products" window in the editor: click the corresponding button in the button bar.

To create a new button:

1.On the "Creation" pane, in the "Usual controls" group, click


: the shape of the button
appears under the mouse. Then, click inside the window to create the button (beside the "Modify
the element" button for example).
2.Select the control and press the [ENTER] key on the keyboard. The button caption becomes
editable. Type "New product" and press the [ENTER] key.

Part 6: Windows Mobile application 203

3.Resize the button if necessary (with the handles) in order for the caption to be entirely
displayed in the button.
4.The code of this option is used to open the "Product form" window and to reset its controls.
To enter this code:
Right-click the "New product" button.
Select "Code" from the popup menu.
In the "Click" process, enter the following code:
HReset(Product)
Open(WIN_Product_form)
TableDisplay(TABLE_Product)

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.
among the quick access buttons.
5.Save the modifications by clicking
6.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.

204

Part 6: Windows Mobile application

In the "Click" process, replace the existing code by the following code:
ScreenToFile()
IF Product..NewRecord THEN
HAdd(Product)
ELSE
HModify(Product)
END
Close()

Notes

Let's study this code:


..NewRecord is used to find out whether the current record must be created.
If HReset was called beforehand, the property returns True (case of the click on "New
product") and the record must be created by HAdd.
Otherwise, the current record already exists and it must be modified by HModify.
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
add it or to modify it. The code becomes:
ScreenToFile()
HSave(Product)
Close()

3.Save the modifications by clicking


among the quick access buttons.
4.Close the code window (click the cross in the top right corner of the code editor).

Display the "WIN_List_of_products" window in the window editor and run its test in the
simulator ( among the quick access buttons).
In the list of products, click the "New product" button.
Enter a new product.
Validate. The new product is displayed in the list of products.
Close the simulator.

Creating a menu window


We are now going to create a window for implementing the menu of the application.
Creating the window
First, we are going to create a blank window with a menu.

To create the window:

among the quick access buttons. The window for


1.Create a new blank window. Click
creating a new element is displayed: click "Window" then "Window".
2.In the wizard for window creation, click the "Standard" tab.
3.Choose "Wizard" and validate.

Part 6: Windows Mobile application 205

4.The wizard for creating a Windows Mobile window starts.


5.Select "Maximized" and go to the next screen.
6.In the screen of advanced parameters, select "With menu and toolbar".

Go to the next screen.


7.Specify the title of the window: "Menu".
8.Validate the wizard. The window is displayed in the editor.
9.Save the window. The name entered in the wizard is automatically proposed in the backup
window. Validate.
Customizing the menu
We are going to modify the menu in order to call the window of list of products and to exit from the
application.

To modify the menu option:

1.Right-click the "Menu" option to display the popup menu.


Note: This "Menu" option is found at the bottom left of the window.
2.Select "Option description". The description window is displayed.
3.Modify the caption of the option that becomes "Product". Validate the description window.
4.Select the menu option again.

206

Part 6: Windows Mobile application

5.Display the popup menu (right mouse click):

6.Select "Transform to expand a sub-menu".


7.In the input area that is displayed, type "List of products" and validate.

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.
Programming the menu
We are now going to enter the code of these two menu options.

To define the WLanguage code of the "Exit" option:

1.In the window editor, display the "Exit" option. All you have to do is expand the menu, just like
you did at run time.
2.Display the popup menu of the "Exit" option (right mouse click) and select "Code".
3.Enter the following code:

Close()

Close is used to close the current window. The "Menu" window being the only window, the
application 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".

Part 6: Windows Mobile application 207

3.Enter the following code:


Open(WIN_List_of_products)

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).

Running the test of the application


The last step consists in specifying that the menu window is the first application window. To do so,
we are going to define the first project window and run a full test of the project.

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 test of the project:


among the quick access buttons.
1.Click
2.Your project starts with the menu window. Click an option of your menu to check whether
the different links are correct.
That's it, our application is created, we must now compile it and install it on the device in order to
run its test.

Creating the executable

To generate the Windows Mobile application:

1.On the "Project" pane, in the "Generation" group, click "Generate" (you also have the ability to
among the quick access buttons).
click
2.The wizard for creating a mobile executable starts.
3.The first wizard screen is used to define the name and icon of the application. The icon of
the executable can be chosen in the image catalog of WINDEV Mobile ("Catalog" button).
4.The other screens are not required by our application. Click the "2- Copy onto the mobile"
link found on the left of the wizard.

208

Part 6: Windows Mobile application

5.This screen is used to define the options for copying files onto the mobile:

6.The options depend on your configuration:


If a mobile is connected, select "Yes: Copy the executable to the Pocket PC" as well as "Run
the application on Pocket PC at the end of copy". In this case, once the executable is
generated, the application will be automatically copied and started on the mobile.
If no mobile is connected, select "No: Don't copy the executable to the Pocket PC". In this
case, the application can be deployed on the mobile devices via a setup procedure.
7.Go to the next screen.
8.If "Yes: Copy the executable to the Pocket PC" was selected, the wizard proposes the files
that must be copied onto the Pocket PC:

9.Validate the selection of suggested files.


That's it, your application is generated and run on the Windows Mobile device.

Part 6: Windows Mobile application 209

Lesson 6.4. Distributing

the

application
This lesson will teach you the following concepts...
Available distribution modes

Estimated time: 20 min

210

Part 6: Windows Mobile application

Overview
WINDEV Mobile allows you to develop applications for Windows Mobile.
Several methods can be used to install a WINDEV Mobile application on a device running Windows
Mobile (Pocket PC for example):
setup in CAB format. This setup program is run on the mobile device directly.
setup in MSI format. This setup program is run on a PC running Windows connected to a mobile
device (Pocket PC for example).
setup by direct copy of the executable from the PC to the Pocket PC (as already seen in the
previous lessons).
These different setup modes are available via the wizard for setup creation.
Caution: The setup program of a Windows Mobile application can be created with a 32-bit editor
only.

To start the setup wizard:

1.On the "Project" pane, in the "Generation" group, click "Setup procedure". The wizard for
creating the executable and the setup starts.
2.The executable being already created, click "2-Setup" on the left of the wizard.
3.In the message box that is displayed, click "Access the setup options".
4.The description screen of the application is displayed. Go to the next screen via the arrow
buttons.
5.You can choose the setup mode of your mobile application:

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.

Part 6: Windows Mobile application 211

9.Go to the next screen.


10.Uncheck the options for configuring the databases. Go to the next screen.
11.The wizard proposes to install additional modules. We won't select any. Go to the next
screen.
12.The generation directory of the setup is proposed.
13.Validate. The setup is generated.
14.WINDEV Mobile proposes to start the setup or to open the generation directory.

Setup in MSI format


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
Mobile. 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 synchronization
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).

212

Part 6: Windows Mobile application

Update in MSI format


The MSI format proposes two types of updates:
update by entirely re-installing the application . In this case, the update is identical to an initial
setup.
update by Internet (HTTP protocol) in CAB format. This update 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
Mobile. This setup program corresponds to a ".CAB" file.
copying this setup program onto a Web directory by FTP.
retrieving and installing the update on the mobile device.

Setup in CAB format


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
Mobile. 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.

Part 6: Windows Mobile application 213

To use this application, start the application on the mobile device (double-click the ".EXE" file for
example).
Update in CAB format
The CAB format proposes two types of updates:
update by entirely re-installing the application. In this case, the update is identical to the initial
setup. See the previous paragraph.
update by Internet (HTTP protocol). This update 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
Mobile. This setup program corresponds to a ".CAB" file.
copying this setup program onto a Web directory by FTP.
retrieving and installing the update on the mobile device.

214

Part 6: Windows Mobile application

Conclusion
The tutorial is over now!
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
thousands!). WINDEV Mobile proposes several features that were not presented in this tutorial:
sockets and HTTP functions...
queries, queries with parameters, ...
printing, ...

See the online help for more details.

We wish you great development experiences with WINDEV Mobile 21!

Conclusion 215

216

Conclusion

You might also like