Tutorial WinDev
Tutorial WinDev
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 2014: This publication may not be reproduced in part or in whole in any form without the express permission of PC SOFT.
Table of Contents
License
Introduction
Preliminary points.................................................................................................................................................. 19
Overview of the tutorial.......................................................................................................................................... 19
How do I access the online help?.......................................................................................................................... 20
Legend of symbols................................................................................................................................................. 22
If you are familiar with WinDev 18........................................................................................................................ 23
What is WinDev used for?...................................................................................................................................... 23
Summary 3
Summary
The times................................................................................................................................................................. 88
Practical example..................................................................................................................................... 88
What time is it?......................................................................................................................................... 88
How much time has passed between two given times?......................................................................... 89
A practical exercise? It's your turn!.......................................................................................................... 90
Calculations with dates and times........................................................................................................................ 90
Summary 5
Summary
Summary 7
Summary
Summary 9
10
Summary
Summary 11
12
Summary
Conclusion
Summary 13
14
Summary
License
Caution: By installing and using WinDev Express Version, you are agreeing with the terms of the
following license agreement:
SOFTWARE shall mean the right to use WinDev Express Version (also called Trial Version,
Evaluation Version or Limited Version).
TRIAL USER shall mean the original customer (either individual or company) who installs and/or
uses the software.
APPLICATION shall mean a program or a set of programs developed with the SOFTWARE.
1. Express Version
The SOFTWARE is proposed in an "evaluation" version.
This trial version is intended for evaluation purpose only. It can also be used by the students of
any educational establishment recognized by the relevant authorities during the duration of their
studies. Any commercial use, in part or in full, is strictly forbidden.
Several features are crippled, limited or different than the ones in the "commercial" version.
This version cannot be used to create commercial applications. To do so, a "Commercial" version
must be purchased.
Creating applications, in part or in full, is strictly prohibited except for evaluation purpose or for
practical work in the course of studies.
Applications can be created for evaluation purpose during the authorized period of time.
Unauthorized use of this software and/or use beyond the authorized period of time will be
prosecuted to the maximum extend possible under the law.
The software (even in this evaluation version) shall not be duplicated or released without PC SOFT
written agreement.
2. License
This SOFTWARE shall be used on a single computer by a single person at a time. The SOFTWARE
is considered used as soon as it is loaded in the "computer memory" (also called RAM).
This software can be used during the authorized period of time only.
3. SOFTWARE ownership
This software is the sole and exclusive property of PC SOFT. The TRIAL USER has only purchased
the rights to use the SOFTWARE according to these conditions.
4. Documentation
Reproducing the documentation, in part or in full, is strictly forbidden.
License 15
5. Use
The TRIAL USER agrees to use the SOFTWARE only for the purpose for which it is intended.
The CUSTOMER shall not modify, or try to modify, nor disassemble, or try to disassemble this
SOFTWARE. The CUSTOMER shall not remove (or try to remove) the copyright mentions that may
be displayed and/or included in the SOFTWARE.
The SOFTWARE shall not be rented, leased or shared.
WinDev "Express" shall not be used to create and distribute all or part of a development tool,
SOFTWARE for application creation and program generator, or any other SOFTWARE of a type
similar to WinDev. Contact us if you have any questions.The functions for generating JAVA code
can only be used to create a stand-alone APPLICATION.
The code generated by WinDev "Express" shall not be re-used in other software or tools for
software creation. The code generated by this feature shall not be included in a software (freeware
or shareware) that could be a competitor of WINDEV, WINDEV MOBILE or WEBDEV, in part or in
full.
The photographs, illustrations and images contained in the examples, templates, skins and skin
templates can only be used in their initial implantation. Any use, reproduction, representation,
adaptation or copy, in full or in part, in any format, by any existing or forthcoming process, is
forbidden.
The images and the animations available from the image catalog must be exclusively used in the
APPLICATIONS developed with the SOFTWARE. These images shall not be sold or distributed. The
use in products or sites other than the APPLICATION is forbidden.
The images cannot be separated from the APPLICATION that uses them.
6. Absence of liability
SOFTWARE and documentation are sold WITHOUT ANY WARRANTY as to performance,
merchantability or fitness for any particular purpose. PC SOFT shall not be liable for damages
of any nature whatsoever, including data loss or deterioration, financial or operational loss,
discrepancies between information supplied in the documentation and SOFTWARE behavior,
in case the SOFTWARE behaves differently than expected. The entire risk as to results and
performance of programs created with the SOFTWARE is assumed by the TRIAL USER.
7. Special cases
Features linked to services
Warning: before using a feature linked to services or applications (including Google), we strongly
recommend that you check the license for using this service or this application. Some restrictions
may apply. The content of licenses may change over time.
PC SOFT is in no case responsible for the way the native access functions are used. Make sure
that you comply with the license of the service provider.
16
License
8. Third-party software
Fonts installed
The "Open Sans" font installed and used by the SOFTWARE is subject to the "Apache License"
license. The text of this license is found in the "Help" sub-directory of the SOFTWARE.
Acceptance of the license:
By installing and using this software, you have agreed with the terms of license agreement.
This license shall not be modified by the representations of anyone unless a written amendment
has been signed by a corporate officer of PC SOFT.
This license agreement is governed by French Laws; any disputes that may arise are to be settled
within the jurisdiction of the courts where PC SOFT has its headquarters.
PC SOFT,
3, rue de Puech Villa
BP 44 408
34197 Montpellier Cedex 5
France
License 17
18
Introduction
Introduction
Preliminary points
Caution: This manual is a tutorial. We advise you to refer to the online help when you are using
WinDev.
The aim of the tutorial is to help you discover WinDev, become familiar with the editors and teach
you the WinDev concepts.
This manual does not cover all the features of WinDev.
You should plan on spending a few hours to follow this course and to learn WinDev: you'll find it
was well worth it!
If you try to develop an application before practicing, you will lose time, and a lot more than a
couple of days.
This tutorial was designed so you can approach it in two different ways:
either you follow all the detailed exercises in each lesson (recommended method).
or, if you are in a hurry and already experienced, you can read through it without doing the
exercises, as all the exercises have screen shots. However, in order to quickly assimilate the
main concepts, we recommend that you follow the tutorial step by step.
WinDev evolves all the time, so the screen shots found in this guide may differ from the ones
found in your product.
Notes
Don't forget to also take a look at the dozens of examples supplied with WinDev: they are very
instructive!
The tutorial may have evolved since this document was published. Do not
hesitate to consult the electronic version of the tutorial (PDF file accessible
from the WinDev menu: on the "Home" pane, in the "Online help" group, expand
"Tutorial" and select "Tutorial (PDF)".
Introduction 19
20
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, etc.
Introduction 21
the content of the help: help common to WinDev, WebDev and WinDev Mobile or help for the
product currently used.
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
"Wizards, Examples and Components" pane of WinDev.
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 to read the associated text.
This symbol gives the result of a "Test": we advise you to read the associated text.
22
Introduction
Introduction 23
24
Introduction
PART 1
Discovering
WinDev
26
Overview
WinDev is an IDE (Integrated Development Environment) allowing you to develop Windows
applications in several fields: management, industry, health care, ... The developed applications
can give access to the information stored in databases.
As you go through this tutorial, you will learn to create your own applications (with or without
database) and to improve them by using the features proposed by WinDev.
Starting WinDev
If you worked with an earlier WinDev version, this wizard allows you to retrieve the existing
configurations.
If you are a new user, this wizard allows you to configure your environment. This allows you to
choose the screen configuration used and to configure the Control Centers. See the online
help for more details.
If WinDev 19 was already started, identify yourself if necessary. The development
environment starts. The home window is displayed.
28
Development environment
The editor
The development environment of WinDev 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 use the same environment:
1. Menu of editors, displayed in the format 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 WinDev interface includes several horizontal and vertical 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 "Wizards, Examples and Components" pane (displayed at the bottom) is used to quickly
access the full examples, sample windows and controls that can easily be included in your
applications.
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 is presented like 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.
30
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".
Lesson 1.2. My
first window
32
Overview
Note
These examples will allow you to get familiar with the programming concepts used in WinDev.
The lessons found in this first part will allow you to:
create simple windows,
handle strings, numeric values, currencies,
handle dates and times.
Opening the project
Start WinDev 19 (if not already done). Close (if necessary) the current project to display the
home window.
Important
In this part, we will focus on creating simple windows. The "WD My First Windows"
project is an empty project that was already created. The creation of a project will
be presented in another lesson.
Answer
To do so, in the home window, click "Tutorial" and select the first project "My first windows
(Exercise)".
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "My first windows (Exercise)".
This window allows the user to enter his first name and to display a welcome message with the
"Display" button.
You may think this is too basic, too simple, but we recommend that you create this window. You
may well be surprised by how intuitive and easy it is to use the WinDev editor. Furthermore, this
window will teach you principles that are fundamental for the rest of this tutorial.
Creating the window
Note
2.A window shaped like a wheel is displayed. This window is used to create all the elements
that can be associated with a project.
3.Click "Window". The wizard for window creation starts.
4.Select "Blank" in the list of "standard" 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.
34
We are going to define the main characteristics of the window: its name and the title that will
Note
Study the window name proposed by WinDev: this name starts with the
letters "WIN_". This prefix is automatically added because the project uses 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".
Validate (green button). This title is displayed in the title bar of the window.
Save the window by clicking among the quick access buttons. By default:
the title of the element corresponds to the title that was entered.
the name of the element corresponds to the logical name of the window.
the proposed location corresponds to the project directory that groups all the project
elements.
35
1.On the "Creation" pane, in the "Usual controls" group, expand "Edit" (click the arrow):
36
4. Perform a right mouse click on the control that was just created. The popup menu of the
control is displayed. Select "Description" from the popup menu. The description window of the
edit control is displayed.
5. Modify the characteristics of the control by entering the following information:
The caption of the control is truncated in the editor. To display the control properly:
1. Select the control (all you have to do is click it with the mouse).
2. In the popup menu (right mouse click), select "Resize".
3. The control is immediately enlarged and the caption is entirely displayed.
Note: You also have the ability to enlarge the input area of the control:
1. Select the control.
2. Position the mouse cursor above one of the handles found on the right of the control (small
square). The mouse cursor turns into arrow.
3. Click with the left mouse button and keep the button down during the move used to enlarge
the control.
4. Release the mouse button once the control was resized.
37
We are going to display the text in a dialog box (a mini-window proposed by the system). To do
Notes
Notes
Note about the assisted input: As soon as the first three characters are typed, WinDev proposes all
the words of the WLanguage vocabulary containing these characters. The assisted development is
very a 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 [Enter] to validate. You can
focus on the algorithm.
38
This is the reason why the programming charter is so important. All the elements
handled in the code of the application use the same standard so they can be
easily found when typing the code.
Notes
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.
Notes
Info displays the message passed in parameter. Our message is built from the text "Hello " and
from the value of the "EDT_FirstName" control. The "+" sign indicates a "concatenation" operation
between two strings.
In this example, the text is displayed in a system window but it can also be
displayed it in a window created with WinDev.
Any developer knows that running a program test can be a long and tiresome job. In WinDev, 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!
Close the test window: click the system closing button of the window ("x" button found in the
title bar).
The WinDev editor is redisplayed. Close the code editor: on the "Home" pane, in the "General"
group, click "Close".
39
1.Click the window: handles appear around the window (the color of these handles may differ
according to the skin template used).
2.Click the handle found at the bottom right and reduce the size of the window by keeping the
left mouse button down.
Notes
Run the test of this window to view the result at run time.
Go back to the editor by closing the test window.
We are now going to force the use of an uppercase letter when typing and displaying the first
Notes
name.
1.Double-click the "First Name" control. The description window of the control is displayed.
2.In the "General" tab, expand the "Input mask" list and choose "1st letter in caps".
Run the test of this window to view the result at run time
40
You have quickly and successfully created your first window. In the rest of this lesson, we are going
to discover new WinDev concepts.
Validate the message and close the test window (click the cross in the top right corner of the
window). The WinDev editor is redisplayed.
Close the "WIN_Edit" window displayed in the editor: on the "Home" pane, in the "General"
group, click "Close".
Close the project: on the "Home" pane, in the "General" group, expand "Close" and select
"Close the project".
evolved windows
42
Overview
In the previous lesson, we have explained how to type and display a text.
In this lesson, we are going to create the following windows:
A calculation window,
A window displaying the date and time in real time,
A menu to group the created windows.
These windows will be created in the "WD My First Windows" project that was used in the previous
lesson.
Answer
To do so, in the home window, click "Tutorial" and select the first project "My first windows
(Exercise)".
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "My first windows (Exercise)".
A corrected project is available. This project contains the different windows
created in this lesson. To open the corrected project:
in the home window, click "Tutorial" and select the project named "My first
windows (Answer)".
on the "Home" pane, in the "Online help" group, expand "Tutorial" and select
"My first windows (Answer)".
Implementation
Notes
among the quick access buttons. Click "Window" in the wheel that is displayed. The
1.Click
wizard for window creation starts.
2.Select "Blank" and the "Elegant" skin template.
3.Validate. The window is automatically created in the editor.
4.Right-click the window and select "Description".
5.Give a name ("WIN_Calculation") and a title ("Example of calculation") to the window.
Validate the description window.
among the quick access buttons.
6.Save the window: click
7.Click the green button to validate the information displayed in the backup window.
It is very important to save the window as soon as it is created.
Saving the window allows WinDev to:
automatically propose the name of controls in the code.
propose the automatic renaming of controls in the code.
1.On the "Creation" pane, in the "Usual controls" group, expand "Edit" (click the arrow). The list
of available edit controls is displayed. Select the "Currency" control and position the control in
the window.
2.Right-click the control and select "Description".
3.In the description window:
Enter the name of the control: "EDT_PriceBT".
Enter the caption: "Price BT".
4.Validate.
1.On the "Creation" pane, in the "Usual controls" group, expand "Edit" (click the arrow). The list
of available edit controls is displayed. Select the "Currency" control and position the control in
the window (below the edit control displaying the price BT for example).
2.Enter the control information: right-click the control and select "Description".
Specify the name of the control: "EDT_PriceIOT".
Modify the caption to "Price IOT".
3.The result displayed in this control must not be modifiable. Click the "GUI" tab and choose
"Read-only" for the initial status.
4.Validate.
5.Save the window.
44
The IOT amount will be calculated whenever the control containing the amount before tax is
modified.
1. Display the code of the "EDT_PriceBT" control ("Code" from the popup menu of the control).
2. Enter the following code in the "Whenever modifying" process:
1. On the "Creation" pane, in the "Usual controls" group, click "Combo box" then click the position
where the control must be created in the window (next to the "Price BT" control).
2. The wizard for creating a Combo Box control is displayed. This wizard is used to define the
main characteristics of the control.
45
7.Display the next screen: give a name (COMBO_VAT) and a caption (VAT) to the control.
46
8.Validate.
9.Resize the window if necessary in order for the Combo Box control to be displayed beside
the edit control displaying the price BT.
We are now going to modify the code of the "Price BT" control in order to take into account the VAT
rate selected in the Combo Box control.
Notes
This code calculates the IOT amount by using the value selected in the Combo Box control
(returned by ..DisplayedValue). The content of the Combo Box control being a character
string, Val is used to get a numeric value in order to calculate the IOT amount.
WLanguage includes several functions and properties. The functions can accept
parameters and they return results. The properties are directly applied to the
controls via the following syntax:
<Control name>..<Property name>.
In our example, ..DisplayedValue is used on the COMBO_VAT control.
The online help of a function can be displayed at any time by pressing the F1 key.
See "How do I access the online help?", page 20 for more details.
To take the VAT rate into account whenever it is modified in the combo box, the "Whenever
modifying" process of the "Price BT" button must be copied into the "Selecting a row" process
of the "COMBO_VAT" combo box:
1. Display the code of the "Price BT" control ("Code" from the popup menu).
2. Select the code found in the "Whenever modifying EDT_PriceBT" process.
3. Press "CTRL" + "C".
4. Display the code of the "VAT" Combo Box control.
5. Position in the "Selecting a row" process and press "CTRL" + "V".
among the quick access buttons) and select the different
6. Run the test of your window (
values in the Combo Box control.
Our window operates properly now. However, the same code is used at 2 different locations! How
do I manage the modifications and apply them? The easiest method is to use a procedure. That's
what we are going to do now.
1. Select the code found in the "Selecting a row" process of the "VAT" combo box.
2. Display the popup menu of the selected control (right mouse click).
3. Select "New .. Create a local procedure containing the selected code".
4. Enter the name of the procedure to create: CalcVAT. Validate.
5. The local procedure named "CalcVAT" is automatically created from the selected code. Your
code was replaced by the call to the "CalcVAT()" procedure.
6. Then, all you have to do is replace the second code for VAT calculation (found in the
"Whenever modifying" process of "Price BT" control) by the call to the "CalcVAT()" procedure.
7. That's it, it's done. You can save your window and run its test to check that everything is
operating properly.
48
This window displays the date and the time. Easy! However, the time is refreshed in real time. To
do so, WinDev proposes the "Timers".
A timer is used to run in parallel a task that must be started periodically (get data in background
task, refresh data automatically, trigger a program at a given time, ...).
But let's create our window first!
Creating the window
Validate (green button). The window is saved. The title is displayed in the title bar.
We are now going to add a Date control into our window to display today's date.
1. On the "Creation" pane, in the "Usual controls" group, expand "Edit" (click the arrow). The list
of available edit controls is displayed.
2. Select the "Date" control (without the small calendar) and position the control in the window.
3. Right-click the control and select "Description" from the popup menu.
4. In the "General" tab of the description window:
Notes
We are going to define the different masks associated with this control (4).
50
Notes
2.Select the display mask "Dddd DD Mmmm YYYY". This display mask is used to display the
date in clear, "Tuesday 16 July 2013" for example.
3.This control can only be used to display the date. No input must be performed. To do so,
specify that this control is "Read-only" in the "GUI" tab of the description window of the control.
4.Validate.
The selected mask is used to display the date in plain letters. To avoid displaying a truncated
date, we are going to increase the control width:
1.Select the edit control.
2.Enlarge the control in width via the sizing handles.
To display today's date in the Date control, all you have to do is initialize it with this date. This
operation is performed by programming.
Display the code associated with the control that was just created:
1.Select the edit control: all you have to do is click it with the mouse.
2.Display the popup menu (right mouse click) and select "Code".. The code editor appears.
3.Enter the following code in the "Initializing EDT_Day" process:
MySelf = Today()
Save the window and run its test (to do so, click
buttons).
then
1. On the "Creation" pane, in the "Usual controls" group, expand "Edit" (click the arrow). The list
of available edit controls is displayed.
Select the "Time" control and position the control in the window.
2. Right-click the control and select "Description".
3. In the "General" tab of the description window:
Enter the name of the control: "EDT_Time".
Enter the caption: "It is: ".
The display mask selected by default displays the hours, the minutes and the seconds. Don't
change anything.
4. As for the Date control, this control can only be used to display the time. Select "Read-only"
in the "GUI" tab of the description window of the control.
5. Validate.
As for the Date control, we are going to initialize the Time control with the current time.
Notes
1. Display the code associated with the control that was just created:
Display the popup menu of the control (right mouse click).
Select "Code".
To display the processes associated with a control, you also have the ability
to:
1. Select the control.
2. Press F2.
Save the window and run its test (to do so, click
then
). The date and the time are
displayed. We are now going to refresh the time as time goes by.
52
1.In the "Project explorer" pane, select the name of the window ("WIN_Timer").
2.Click the arrow on the left to display the different elements.
3.Click "Local procedures". The folder is selected.
4.Select "New local procedure" from the popup menu of "Local procedures" (right mouse
click).
5.In the window that is displayed, specify the name of the procedure ("RefreshTime") and click
the "Add" button.
6.The procedure appears in the code editor. Enter the following code:
EDT_Time = Now()
7.This code is used to refresh the control displaying the time. We are now going to call it every
second via the timer.
1. Go back to the "WIN_Timer" window. You can for example click the "WIN_Timer" button at the
bottom.
2. Click in the home window of the window (gray background). Display the popup menu (right
mouse click) and select "Code".
3. The processes associated with the window are displayed.
4. Enter the following code in the "End of initialization of WIN_Timer" process:
TimerSys(RefreshTime, 100,1)
5. This code is used to specify that the "RefreshTime" procedure will be called every second
(100 represents the hundredths of a second).
Save the window and run its test (to do so, click
Notes
buttons).
then
We have seen how to create a timer by programming. You also have the ability to
automatically create a timer from the code editor. See the online help (keyword:
Automatic procedures) for more details.
1. On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow). The
list of preset buttons is displayed.
2. Click the "Close" button.
3. Click the position where the control must be created in the window (bottom right for
example).
1. Display the control description (select "Description" from the popup menu or double-click the
button).
2. In the "General" tab:
The name of the button complies with the programming charter.
An action is associated with the button: this action is used to close the window.
The images corresponding to the skin template used are automatically associated with the
button.
3. In the "GUI" tab, the button is a "Cancel" button. The code of the button will be run when the
ESC key is pressed.
54
Notes
A VALIDATION button
A CANCELATION button
A HELP button (if the controls have
associated help windows)
Any other INTERRUPTION button
Run the test of this window to view the result at run time.
56
To create a menu option and to modify it, use the popup menu of the menu or the popup
menu of the menu option. To display the popup menu of a menu option:
1.Select the menu.
2.Click with the right mouse button.
3.The following popup menu is displayed:
Several choices are available. The main options for menu management are:
"Option description" to modify the caption and shortcut of the option.
"Code" to enter the source code corresponding to the process that will be run during a click
on this option.
"Add after" to add a menu option after the current option.
"Add before" to add an option before the current option.
"Transform to expand a sub-menu" to add a sub-menu into the current option (tree structure).
1.Display the description of the "Menu" option inserted by default and change the caption to
"Fi&le". Validate the description window.
Reminder: The "&" character is used to define the shortcut for the menu option.
2.In the popup menu of the "File" option, select "Transform to expand a sub-menu" and type
"Exit".
We are now going to create the [ALT + F4] shortcut for the "Exit" option.
Tip
58
In your applications, we advise you to follow the Windows standard for the menus.
Pay special attention to the following points:
Each option of the main menu must propose at least one sub-option.
The first letter of each option must be written in uppercase character, even
if this is not the shortcut. The shortcut is underlined (use the "&" character).
If a menu choice calls a setting window before running the selected option,
the caption must end with three dots (...).
The "Exit" option must be the last sub-option of the first option in the menu
bar (example: "File.. Exit").
If there is a help option, it must be found at the end of the first line of the
menu (the right-most option).
We are going to enter the code for the different options:
1.Select the "Exit" option. This option will be used to exit from the application. Select "Code"
from the popup menu. Enter the following code in the code window that is opened:
2.Then, close the code window. The window currently edited is displayed.
3.In the window, select the "Enter a text" option. This option will be used to open the
"WIN_Edit" window. Select "Code" from the popup menu. Enter the following code in the code
window that is opened:
6.Repeat this operation for the "Calculate VAT" option and enter the following code:
You've guessed it: Open is used to display a window allowing you to perform an input. Close is
used to close the current window.
If the window containing the menu is the first window displayed by the application, closing the
window containing the menu (via "File .. Exit" in our example) is equivalent to exiting from the
application.
Notes
The WLanguage functions used in this code are in English. If you are a French
speaker, you can view and enter the code in French: on the "Code" pane, in the
"Languages" group, expand "Convert the code" and select "Translate into French".
Only the English terms will be used in this documentation. For each term, the
online help indicates its translation in French.
Save the window and run its test. During the test:
Notes
Select one of the menu options. Close the window that is opened.
Click "File .. Exit" to exit from the program.
60
Notes
If your application handles data, WinDev allows you to define the structure of the database via the
analysis. The WinDev analysis contains the description of the files (also called "Tables" in several
databases). These files will contain the data of the application.
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 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
executable modules. Each module uses the same analysis (the executables can also use the
same data files at run time).
Terminology
As already seen, a WinDev project (linked to an analysis if necessary) is used to create an
application. Before we actually start working with WinDev, let's go back to the vocabulary used in
WinDev. Indeed, several terms are specific to WinDev 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, "Table" is a term reserved for defining a graphical 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 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, if a HFSQL data file includes several key items, a single index file will be
created at run time.
Important
62
concepts
Introduction
In the previous lesson, we have worked with the code editor of WinDev and its language,
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,
Processing dates and times.
Some examples:
Subscript is int
SupplierName is string
ArrayPrice is array of 10 currencies
I, J, K are int
Counter is int = 120
B1 is boolean = False
See the online help (keyword: "Data types") for more details.
Declaring the variables and their scope
Two types of variables can be handled in WLanguage:
The global variables
The local variables
The global variables can be global to a project or to a window. These variables must be declared:
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.
64
Caution !
Let's perform a simple operation to understand the operating mode. The "WD Programming
Conditional statements
WLanguage allows you to manage the conditional statements such as:
IF, ELSE, END to run a test on a condition.
SWITCH, CASE, END to perform one or more actions depending on the result of a test on a
condition.
Some examples
IF Maximum > Random(1, 999) THEN
Info("Well done, you won !")
ELSE
Info("Sorry, you 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
CASE ELSE
// It's another day
END
Practical example
Now that you are familiar with the main conditional statements, let's try to run a test!
Open the "WIN_Code.wdw" window: in the "Project explorer" pane, in the "Windows" folder,
Tip
double-click the name of the window. This window presents several examples.
To quickly find a window in the current project, press [CTRL] + [E]. A window is
displayed, allowing you to perform a search on all the windows containing the
letters typed in the search area. Then, select the requested window and validate
in order for this window to be opened in the editor.
66
2.Check the different examples. The code run is displayed in the window.
3.Close the window and go back to the editor.
Loop statements
Notes
Some examples
i is int = 0
WHILE i < Maximum
i ++ // Equivalent to i=i+1
END
i is int = 0
LOOP
i ++ // Equivalent to i=i+1
IF i > Maximum THEN BREAK
END
FOR i = 1 TO 100
// There is no need to declare i
Cnt ++ // Equivalent to Cnt=Cnt+1
END
Practical example
Now that you are familiar with the main loop statements, let's see the operating mode at run time.
Open the "WIN_Code.wdw" window: in the "Project explorer" pane, in the "Windows" folder,
double-click the name of the window. This window presents several examples.
2. Check the different examples. The code run is displayed in the window.
3. Close the window and go back to the editor.
Comments
To enter comments in the code, the code line must start with // (two "/" characters).
Example:
Tip
68
Several code lines can be set in comment ; to do so, select the code lines with
the mouse or with the keyboard and press [Ctrl] / (on the numeric keypad).
To perform the reverse operation (to remove the comments), select the code lines
with the mouse or with the keyboard and press [Ctrl] [Shift] / (on the numeric
keypad).
In the "WD Programming Concepts" project, open the "WIN_Operator" window.
Run the test of this window ( among the quick access buttons) and check the logical
operators.
69
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 ([=, [=~
[=~~).
Practical example
An example page is available for checking the different use cases of the comparison operators.
In the "WD Programming Concepts" project, open the "WIN_Operator" window.
Run the test of this window ( among the quick access buttons) and check the
comparison operators.
Indirection operators
The "indirection" mechanism is used to build the name of a control, the name of a file item or the
name of a variable from a string expression.
This enables you to create generic processes independent of the names of controls, variables, file
items...
The indirection is performed by the operators { }.
To optimize the speed of your applications, the type of the element handled should be specified
when using the indirection syntax.
Therefore, if you are using a control, the corresponding type will be IndControl (see the example
below).
Some indirection examples:
Example of simple indirections:
{"NAME",indControl} = CustName
// is equivalent to NAME=CustName
{"NAME",indControl} = {"CU.CUSTNAME"}
// is equivalent to NAME=CU.CUSTNAME
{"WINCUST.NAME",indControl} = CustName
// is equivalent to WINCUST.NAME=CustName
{"WINCUST"+".NAME",indControl} = CustName
// is equivalent to WINCUST.NAME=CustName
70
Example
See the example named "Handling the indirections" (supplied with WinDev)
for more details. This example is accessible from the "Wizards, Examples and
Components" pane.
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 do I decide whether a procedure must be 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
In the "WD My First windows" project, you saw that a procedure could 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. See the online help about
..ReturnedValue for more details.
72
Calling a procedure
Tip
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 knows how to manage the calls to nested procedures.
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. All you have to do is use the "Project
explorer" pane.
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.
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.
Practical example
Enough theory, let's get down to work!
In the "WD Programming Concepts" project, open the "WIN_Code" window (double-click its
name in the project explorer). This window presents several examples.
Display the list of local procedures (accessible from the "Project explorer" pane). When you
double-click the name of the procedure, the code of this procedure is displayed in the code
editor.
In the "WD Programming Concepts" project, open the "WIN_Code" window: double-click its
name in the project explorer.
In the "Your code" button, write a procedure used to display all the even number from 10 to
1 (reverse order) in the edit control named EDT_YourResult.
Run the window test to check your code.
Correction: The "Corrected code" button contains the solution.
Open the "WIN_String.WDW" window: double-click its name in the project explorer. This
window presents the different operations that will be explained in this lesson.
74
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:
str is string
str = "WinDev 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_TEXT2 + EDT_TEXT1)
Extracting sections from a string
// Displays "WinDev"
// Displays "WinDev"
// Displays 35
A string can be transformed into uppercase characters with Upper or to lowercase characters with
Lower:
Info(Upper(EDT_TEXT2))
Info(Lower(EDT_TEXT2))
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_TEXT2, 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")
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
In the "WD Programming Concepts" project, open the "WIN_String" window if necessary:
double-click its name in the project explorer.
In the "Your code" button, write the code used to display the 5th word of the text in uppercase
characters as well as the size of this word.
Run the window test to check your code.
Correction: The "Corrected code" button contains the solution.
Open the "WIN_Numeric.WDW" window: double-click the name of the window in the "Project
explorer" pane.
Run the test of the window. This window presents the operations that can be performed on
the "numeric" values.
Tip
78
Various operations
In the "WD Programming Concepts" project, open the "WIN_Numeric" window if necessary:
double-click its name in the project explorer.
In the "Your code" button, write the code used to display the result of the subtraction
performed between the "Amount 1" and "Amount 2" controls, rounded to 1 decimal.
Run the window test to check your code.
Correction: The "Corrected code" button contains the solution.
Open the "WIN_RealCurrency.wdw" window (double-click its name in the "Project explorer"
pane).
Run the test of the window. This window is used to run the test of the different code sections
presented in this paragraph.
Details
The "Currency" type is a real coded on 10 bytes. It is used to give the solution to the two problems
not solved by the reals:
more than 15 significant digits (the double reals support up to 15 significant digits), the
"Currency" type supports 23 significant digits.
avoid an error resulting from the binary coding of reals:
A real supports up to 15 significant digits. In fact, the binary coding of the reals does not
allow to code all reals with 15 significant digits.
The "Currency" type uses a different system for coding reals that causes no rounding error.
Indeed, the following code returns a false result:
// The calculation is false with a Real variable
Real is Real
Real = 18.6 - 8.6 - 10
Error("18.6-8.6-10=" + Real)
To check this code, click the "Subtracting reals" button in the test window.
On the contrary, the result is correct with the following code:
Currency is Currency
Currency = 18.6 - 8.6 - 10
Info("18.6-8.6-10=" + currency)
To check this code, click the "Subtracting currencies" button in the test window.
80
Note
To check this code, click the "Dividing a currency" button in the test window.
The numeric values and the strings can be mixed together. WinDev is very flexible in 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 "123" string
= "456"
= c
// the I variable 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 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.
The dates
Practical example
Open the "WIN_Date.WDW" window. This window illustrates the explanations given in the rest
of this lesson.
82
In the "WIN_Date" window, display the description window of the "Enter a date" control
("Description" from the popup menu of the control). Display the "General" tab of this window.
The following information is displayed:
Note
Let's take a look at the following examples to understand the relationships between the input
mask and the returned value:
If the input and display mask of a date control is "DD/MM/YY" and if the returned value is
"YYYYMMDD":
DDATE = "20131225" // Displays the date in "25/12/13" format
DDATE = "131225" // Displays the date in an incorrect format
Therefore, pay great attention to the format of the returned value in a date or time control.
83
Notes
84
To check this feature in our example, click the "Today" button.
To display the date in a more explicit format, all you have to do is use DateToString:
Info("Today is " + DateToString(Today(),...
maskSystemDate))
DateToString transforms a string in "YYYYMMDD" format into a string in the selected format. The
maskSystemDate constant allows you to use the date format defined in the "Languages" tab of
the project characteristics.
Reminder: To display the project characteristics, on the "Project" pane, in the "Project" group, click
"Description".
To check this feature in our example, click the "DateToString" button.
What is today's date, with the day and the month in letters?
To display the date in letters, you must use DateToString with a specific date format:
Info("Today is " + DateToString(Today(),...
"DDDD DD MMMM YYYY")
In this code:
the "DDDD DD" string is used to get the day in letters. For example: Tuesday 17.
the "MMMM" string is used to get the month in letters. For example: September.
the "YYYY" string is used to get the year. For example: 2013.
To check this feature in our example, click the "In letters" button.
How many days between 2 dates?
You want to find out how many days have passed between two dates? It's quite simple: all you
have to do is use DateDifference:
NumberDays is int
NumberDays = DateDifference("20100101", Today())
InfoBuild(...
"The number of days between %1 and %2 is: %3", ...
DateToString("20100101", maskSystemDate),...
DateToString(Today(), maskSystemDate), NumberDays)
To check this feature in our example, click the "DateDifference" button.
Note
You also have the ability to get the duration between today's date and a specific
date in plain text (two days ago, in 3 weeks, ...). All you have to do is use:
the "Relative duration" display mask,
DateToString associated with the maskDateRelativeDuration constant. For
example:
// The date is 01/22/2013
Res = DateToString("20130101", ...
maskDateRelativeDuration) // Returns: 3 weeks ago
To check this feature in our example, click the "DateToStringInAlpha" button.
Practical exercise
Now that you are a bit more familiar with the dates: what is the purpose of the following code?
DateToString(Today(),"DDDD DD MMM YYYY")
Answer: Displays the literal date (the day and the date in everyday's language).
Handling Date variables
Specific types of variables are available for the Date, DateTime and Duration values.
These variables can be handled like "strings". Each one contains a value according to the following
table:
Type
Default format
Date
YYYYMMDD
DateTime
YYYYMMDDHHMMSSCC
Duration
YYYYMMDDHHMMSSCC
The "Date" type supports the dates from 01/01/0001 to 12/31/9999 (that should keep us going
for a while!).
86
More seriously, to handle the value of these variables, you have the ability to use the following
syntaxes:
MyDate is Date = "20121021"
Info(DateToString(MyDate)) //Displays "21/10/2012"
MyDate..Year = MyDate..Year + 1
MyDate..Month = MyDate..Month + 1
MyDate..Day = MyDate..Day + 1
Info(DateToString(MyDate)) //Displays "22/11/2013"
In the "WIN_Date" window, the "Code example" button is used to calculate the date of the
next January 1st by using a Date variable.
The following code is used:
MyDate is Date
// MyDate is automatically initialized to today's date
// Calculate the date of the next January 1st
NewYear is Date
NewDate..Year++
NewYear..Day = 1
NewYear..Month = 1
MyDuration is Duration = NewYear - MyDate
Info(StringBuild(...
"There are %1 days left before the next New Year's Eve",...
" on %2.", MyDuration..InDayss, DateToString(NewYear))
In the "WD Programming Concepts" project, open the "WIN_Date" window if necessary
(double-click its name in the project explorer).
In the "Your code" button, write the code used to calculate the date in 180 days and used to
display this date in letters.
Run the window test to check your code.
Correction: The "Corrected code" button contains the solution.
The times
Practical example
Open the "WIN_Time.WDW" window. This window illustrates the explanations given in the rest
of this lesson.
To check this feature in our example, click the "Now" button.
You want to display the time in "HH:MM:SS:CC" format ? The code becomes:
Info("It is " + TimeToString(Now()))
To check this feature in our example, click the "TimeToString" button.
88
If you do not want to display the hundredths of a second, the code is:
Info("It is " + TimeToString(Now(), "HH:MM:SS"))
All you have to do is specify the display format of the time with TimeToString.
To check this feature in our example, click the "Without the hundredths" button.
How much time has passed between two given times?
It is 17:25. How much time has passed since 12:15? The code is as follows:
// Displays the time passed since 12:15
Diff is int = TimeDifference("1215", Now())
Result_Time is string = IntegerToTime(Abs(Diff))
IF Diff < 0 THEN
InfoBuild(...
"Time passed before 12:15 -> %1 h %2 min %3 s ", ...
Result_Time..Hour, Result_Time..Minute, ...
Result_Time..Second)
ELSE
"Time passed since 12:15 -> %1 h %2 min %3 s ", ...
Result_Time..Hour, Result_Time..Minute, ...
Result_Time..Second)
END
Caution!
To check this feature in our example, click the "1st example" button.
The same calculation can be performed by using the Time and Duration variables.
Specific types of variables are available for the Date, Time, DateTime and Duration values. These
variables can be handled like "strings". Each one contains a value according to the following table:
Type
Default format
Time
HHMMSSCC
Duration
YYYYMMDDHHMMSSCC
nd
example" button.
In the "WD Programming Concepts" project, open the "WIN_Time" window if necessary
(double-click its name in the project explorer).
In the "Your code" button, write the code used to display the time left before 23:59 in HH:MM
format.
Run the window test to check your code.
Correction: The "Corrected code" button contains the solution.
90
Questions/Answers
Question
To view the element corresponding to the current process, on the "Code" pane, in the "Navigation"
group, click "Go to the object" (CTRL + ALT + F2). The window containing the requested element is
displayed.
Question
Question
The functions for performing searches or replacements (in the code, in the interface, ...) can be
accessed from the "Home" pane, in the "Find" group or in the "Find - Replace" pane (CTRL + F):
Then, you have the ability to define the different characteristics of the search to perform.
92
Question
What is the meaning of the "+" and "-" signs found in the code
editor?
The code editor allows you to expand or collapse the WLanguage code. This feature is very useful
if your processes use a lot of structured statements (loops, conditions, browses, ...).
To collapse a section of code, on the "Display" pane, expand "Collapse" and select "Collapse all" (or
press [CTRL] + [SHIFT] + * (on the numeric keypad)).
Only the comments remain visible. The associated code is displayed in a tooltip when the comment
line is hovered by the mouse cursor:
Press [CTRL] + * (on the numeric keypad) to expand the entire code. A click performed on the "-" or
"+" symbol allows you to collapse or expand the corresponding code section.
Question
Press [F6] to display the information (name and creation/modification date) about each code line.
Question
In the code editor, to enable (or not) the numbering of code lines, on the "Display" pane, in the
"Help for edit" group, click "Display the line numbers".
Question
Question
94
Question
All you have to do is use an advanced dialog box. These dialog boxes are used to manage:
the directive questioning (Dialog): the user answers a question via buttons containing the
text of the action to perform.
the immediate input (Input), by allowing the user to enter the requested value in the dialog
box.
See the online help (keywords: "Dialog" and "Input") for more details.
To check the different modes for communicating with the user:
1.Open (if necessary) the "WD Programming Concepts.WDP" project: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Programming concepts".
2.Open the "WIN_Dialog.WDW" window. This window presents the different dialog modes.
3.Run the test of this window ("GO" button).
4.Click the different buttons to check the different dialog modes.
5.Stop the test of this window and go back to the code editor to study the code of each button.
A small exercise will be used to implement the different operations that can be performed on
96
PART 2
My first database
98
100
and the
databases
This lesson will teach you the following concepts...
Vocabulary used.
The different modes for accessing the databases.
Overview
You may have to handle data when creating an application. To store the data, you must create a
"database".
In WinDev, when creating a project that is using data, an "analysis" must be created beforehand.
An analysis contains the description of the data files (or tables) containing the application data.
Notes
When the application is run, these descriptions will be used to create the database and/or the
data files. The information will be stored in this database or in these data files.
Several tools for performing maintenance operations on the HFSQL databases
are supplied with WinDev. They can be accessed from the HFSQL Control Center.
WinDev can handle most of the database formats (nearly all of them). The most common formats
are:
HFSQL, the database system supplied with WinDev. The HFSQL database is available in
Classic or Client/Server mode.
AS/400, Access, Sybase, Informix, ...
Oracle, SQL Server, MySQL, xBase, ...
Any database accessible in SQL language in Windows.
Text (ASCII files).
Several methods (also called "access modes") can be used to access the data:
Native access,
OLE DB access,
Direct ODBC access,
ODBC access via OLE DB.
102
OLE DB access
Caution!
An access via OLE DB uses a multi-database access standard. This type of access is based on
MDAC (Microsoft Data Access Component).
If you are using an OLE DB access, MDAC must necessarily be installed on the
user computers (version 2.6 or later).
Some databases may not be accessible via this method. Check whether an OLE DB driver exists
before you use this type of access.
The SQL* and HRead* functions of WLanguage can be used with this type of access.
ODBC access via OLE DB
In summary, it is a "mix" of OLE DB and ODBC. This is the "heaviest" method and the least efficient
one in term of performance. It should not be used on small databases.
The SQL* and HRead* functions of WLanguage can be used with this type of access.
HFSQL
HFSQL is a database that is very powerful, very fast and very reliable.
HFSQL operates in Windows and Linux, on mobile devices (iOS, Android, Windows), on networks of
any size and type, and it automatically manages hundreds of concurrent accesses.
HFSQL can be freely distributed with your WINDEV applications.
HFSQL proposes all the features of a database, especially:
the log process,
the transactions,
the replication,
the triggers.
See the online help for more details about implementing these features.
In the different sections of this tutorial, we will be using a HFSQL Classic database then a HFSQL
Client/Server database.
104
and analysis
Overview
To create an application with a database, you must:
Create the project linked to the application. This project will group all the application elements
(windows, codes, queries, reports, ...).
Create the analysis linked to the project. The analysis is used to describe all the data files
handled by the application.
Notes
1.Start WinDev (if not already done). Close the current project if necessary.
2.In the home window, click the "Create a project" button and select "Windows or Linux
application". 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.
Tip: To create a project, you can also:
among the quick access buttons of the WinDev menu.
1.Click
2.Click "Project" in the wheel that is displayed.
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 "WD My First Database". WinDev proposes
to create this project in the "\My projects\WD My First Database" directory. You can keep this
location or modify it via the [...] button. For the project summary, type "The purpose of the
project is to manage the customers and their orders".
106
4.The different wizard steps are specified on the left of the wizard. These steps can be clicked
directly. The other screens of "Description" are not fundamental so click "Charters" directly.
5.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.
6.This step is used to define the style book. Select "Elegant". Go to the next screen via the
arrows found at the bottom.
Notes
7.A size of 800x600 will be chosen for the screens; indeed, our application will contain no
large windows and it will be adapted to most of the resolutions used. The choice would be
different for an application used to manage images for example.
8.Click the step "Did you know it". This screen is used to manage the display of a "Did you
know it" window.
We won't display this window: select "Don't display the 'Did you know it' window when starting
the application". Go to the next screen.
9.We are now going to specify the information regarding the database.
10.Select "Yes, create a new database" and validate. The wizard for analysis creation starts.
To better understand the lessons found in this section and to optimize your
training, we advise you to create the "WD My First Database" project.
A corrected example can be accessed at any time to check the validity of the
operations performed.
To open this corrected project, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "My first database (Answer)".
1.Specify the name and directory of the analysis. By default, the name of the analysis
corresponds to the name of the project and the analysis directory is a ".ana" directory in the
project directory. We will keep these default parameters. Go to the next wizard screen.
2.You now have the ability to choose the types of databases used by the project. Select
HFSQL Classic (the database proposed by default with WinDev).
108
To create the data files of this analysis, we are going to use the different methods proposed by
WinDev.
The steps of the wizard for creating a data file are as follows:
1.In the wizard, select "Select a description among the preset data files". Go to the next wizard
screen (arrow at the bottom of the wizard).
2.The list of preset data files is displayed. We are going to create the "Customer" file. In the
list of data files, select "Customer". Go to the next screen.
3.The wizard proposes the list of items to include in Customer file. This list is very impressive
but it is used to manage the several types of Customer file.
4.Check the following items: CustomerID, Company, LastName, FirstName, Address, ZipCode,
City, StateDep, Country, Phone, Cell, Email.
5.Validate the wizard.
6.Click "WinDev editor".
110
You have the ability to enlarge the file displayed. To do so, click the file, select the black handle at
the bottom of the file and move the mouse toward the bottom.
Creating a data file: creating the file and the items
We are now going to create the data file containing the orders.
1.On the "Analysis" pane, in the "Creation" group, click "New file".
2.The wizard for creating a new data file starts.
3.In the wizard, select "Create a new description of data file". Go to the next wizard screen.
4.We are going to create the "Orders" file. Enter its name ("Orders") in the wizard.
This name will be used:
- to handle the data file in programming. The variable associated with the file will be "Orders".
- to build the name of the associated physical data file ("Orders.fic" file).
The caption and description of the elements represented by the records found in the data file
are automatically displayed.
Notes
In the wizard, the "A record represents" control indicates the information that will
be used to describe the links between the data files. This information must be
specified with great care!
In our case, type "An order".
Notes
5.In the "Automatic identifier" area, keep "Automatic identifier on 8 bytes". If an automatic
identifier is defined on the data file, it means that the data file includes a unique key,
automatically managed by WinDev.
To create the identifier (an identifier is a unique key), you have the ability to create
a numeric item whose type is "Automatic identifier".
This identifier is automatically managed by WinDev. Whenever a record is added
into the data file, WinDev automatically assigns a value to the file identifier. This
value is unique.
6.Go to the next screen and select the type of database associated with the data file. We are
going to work on HFSQL Classic data files. Go to the next screen.
7.Click the green button to validate. The data file is automatically created in the analysis. The
description window of items is opened.
112
We are going to create the items of the "Orders" file. In the description window of the data file,
you will notice that an item was automatically created: "OrdersID". This item corresponds to the
automatic identifier of the data file. This item includes the letters "ID" and the name of the file.
We are going to create the other items of this data file.
First, we are going to create the "Date" item. This item will contain the order date
1. In the description window of items, click twice in the "Name" column of the first empty line.
This column automatically becomes editable. Type "Date".
2. Click the "Caption" column. The name of the item is automatically displayed. We are going to
modify the caption of the item by clicking it: type "Order date". In the "Type" column, the "Text"
type is automatically selected. Expand the list and select the "Date" type.
Notes
3. This item will be a key item in our data file: the keys are used to improve the speed for
accessing the data and to simplify the browse operations performed on the data files. You will
have the ability to perform searches or browses on this item.
The concept of key is part of the characteristics of an item. When creating an
item, you have the ability to specify whether it is:
not key,
unique key: the value of this key will be unique in the entire data file (which
means in all the records found in the data file)
key with duplicates: the value of this key can be found several times in the data
file.
4. The definition of the key is performed as follows: re-select the line of the "Date" item to
enable the description controls found on the right of the screen. Then, all you have to do is
specify the type of key used. In our case, the date is a key with duplicates.
113
We are now going to create the "Status" item that is used to find out the status of the order.
The information entered here will be automatically used when creating the windows linked to
the data file. You will find here the control type and the caption.
We are going to enter the following options in the "Content" tab:
Click the "Content" tab.
Click the "+" button to add the first option.
The option 1 corresponds to Pending. Type "Pending" in the edit control found on the right.
Click the "+" button to add the second option.
Type "Validated" instead of "Option 2".
Click the "+" button again.
Type "Canceled" instead of "Option 3".
114
1.In the file explorer of Windows, open the following WinDev sub-directory: "\Tutorial\Exercises\
WD My First Database".
2.Select the "PaymentMode.csv" file.
3.Drag and Drop the "PaymentMode.csv" file to the data model editor of WinDev. The wizard
for importing files starts.
4.Go to the next screen.
5.Select the format of the files to import. In this case, select "Text file". Go to the next wizard
screen.
6.WinDev indicates the path of the file to import. Go to the next wizard screen.
7.Specify the following import parameters:
Don't forget to check "The first row contains the names of the columns".
8.Go to the next screen.
116
9.The structure of the data file that will be created is displayed. Keep the default options. Go
to the next screen.
10.The content of the CSV file will be automatically converted to HFSQL format. The wizard
proposes to create the HFSQL file in the project directory. Keep the proposed options and go to
the next screen.
1. Select the "PaymentMode" file then "Description of data file" from the popup menu.
2. In the window that is displayed, modify the caption of the file: delete "(Imported)".
3. Click the "Validate" button.
to display the description of the items found in the data file.
4. Click
5. This data file contains no automatic identifier and no unique key. We are going to switch the
"Code" item to unique key:
Position the selection bar on the "Code" item if necessary.
In the right section of the screen, click "Unique key".
7. Validate the description window of items then the description window of the file.
Direct import of existing data files
The last method for creating data files consists in importing the existing HFSQL data files. This
method will be used to create the "Product" file.
Notes
118
To open the file explorer on the directory of your project, on the "Home" pane, in
the "General" group, click .
We are now going to create the links between the data files.
Let's create the link between the "Customer" file and the "Orders" file.
1.On the "Analysis" pane, in the "Creation" group, click "New link". The mouse cursor turns into a
pen.
2.Click the "Customer" file then the "Orders" file.
3.The wizard for link creation starts.
4.Answer the questions asked by the wizard:
Notes
5.Go to the next screen. The wizard automatically proposes the key used by the link
(CustomerID).
6.Display the next wizard screen. The wizard proposes to create a new key in the Orders file.
120
Create a link between the Payment Mode file and the Orders file according to the same
method.
The cardinalities are as follows: PaymentMode (0,n), Orders (0,1)
The link key corresponds to the "Code" item.
We are now going to create a link between the "Product" file and the "Orders" file. This link will
5.Go to the next screen. The wizard proposes to create a relation file. Keep "Create the relation
file automatically" and go to the next screen.
6.The wizard proposes the unique key of the Orders file: "OrderID". Go to the next screen.
7.Validate the creation of the key by going to the next screen.
8.Keep the default options regarding the integrity rules and go to the next screen.
9.The wizard proposes the unique key of the Product file. Select "Reference". Go to the next
screen.
10.Validate the creation of the key by going to the next screen.
11.Keep the default options regarding the integrity rules and go to the next screen.
12.Click the green arrow. The relation file is automatically created in the data model editor.
We are now going to modify the relation file that was created by WinDev. Indeed, this file will
contain the order lines. We are going to:
Modify the name of the file.
Modify the name of its items.
Add items to find out the quantity of products ordered and the total of the order line.
First, we are going to rename the file. A similar operation was already performed when the
caption of the imported file was modified. However, it is a little bit more complex in this case:
we are also going to rename the physical file linked to the file description.
1.Select the "Orders_Product" file then "Description of data file" from the popup menu.
2.In the window that is displayed, modify:
the name of the file: "OrderLine".
the name on disk: "OrderLine".
122
We are now going to modify the items of this relation file.
1. Click
Notes
2. This file includes 3 items. Position the selection bar on the "OrderID_Reference" item. This
item is a composite key.
A composite key is a key that includes several items found in the same data
file.
This type of key is used to browse the data file according to complex criteria
or to perform specific searches.
123
We are now going to add 3 new items into this relation file: Quantity, TotalBT and TotalIOT.
1.Position on a new row and create the "Quantity" item. This item is a "Numeric" item.
2.Position on a new table row and create the "TotalIOT" item. This item is a "Currency" item.
3.A window is displayed, indicating that the item already exists in the analysis and proposing
to re-use its characteristics:
7.Validate the description of items (green button at the bottom of the screen) and the
description of the file.
124
Caution!
Generating the analysis is used to make the information about data files available to the other
modules of the project. These data files can be handled in the programs.
Without generation, even though the description of the data file exists, you would not be able to
use the data file in your programs.
When generating the analysis, all the modifications performed in the analysis and in the data files
will be automatically applied to the entire project (windows, linked controls, reports, ...).
The generation must be performed whenever you want the modifications
performed in the analysis to be taken into account in the programs that use this
analysis.
If the analysis is modified several times without any programming between each
modification, there is no need to generate the analysis at each modification.
Generate the analysis when all the modifications have been made and when you
start programming.
1.In the data model editor, on the "Analysis" pane, in the "Analysis" group, click "Generation".
2.The analysis generation is automatically started.
The descriptions of the data files found in the analysis have been modified.
To update the data files of the application, WinDev automatically starts the procedure for
modifying the data files. This operation is used to update the data files (".fic" files) according to
their description in the analysis.
The wizard for automatic modification starts. Validate the different screens until the screen
The wizard proposes to save the existing data files, don't change anything and go to the next
screen.
The wizard proposes to enter the passwords for protecting the data files modified by the
automatic modification. Keep the default options and go to the next screen.
The list of data files to modify is displayed. Validate the wizard.
The data files are updated.
126
full
RAD
Note
The RAD module of WinDev is based on this analysis. The RAD module includes a wizard allowing
you to choose the application template to generate (the RAD pattern) and the main options
regarding the operating mode of your application.
WinDev is supplied with several "RAD patterns" allowing you to generate several
application templates. You also have the ability to create your own RAD patterns.
See the online help (keyword: "RAD pattern") for more details.
Note
The windows, the reports, the queries and the code generated by RAD can be customized. You
also have the ability to modify the types of controls, the default values, ...
The RAD can also be used to generate several types of windows, it is the window RAD. The Window
RAD is available when a new window is created in your application.
Let's see how to use the Project RAD module.
128
Generating RAD
1.On the "Project" pane, in the "Generation" group, click "Full Application RAD". The wizard for
generating the RAD application starts.
2.Select the pattern that will be used for the RAD generation: "Simple RAD" for example. Go to
the next wizard screen.
3.All the data files found in the analysis will be taken into account:
5.The entry points of the application correspond to the entries available in the menu.
Keep the Customer, Orders, PaymentMode and Product files only. Display the next screen.
6.Specify whether the Table controls generated in the application windows must be allow the
input or not. In our example, the Table controls will allow the user to enter new information.
Select "Yes: Allow the input in the table controls". Display the next screen.
7.Specify whether the user groupware must be used in the application. It will be presented
later in this tutorial. Select "No: Don't include the management of user groupware". Go to the
next screen.
130
8.Specify whether the automatic menu must be included in the application. Answer "Yes:
Include the menu '?'".
Note
9.Go to the next screen. The wizard for RAD generation is ended and the wizard for generating
the automatic menu starts.
The automatic menu is a help menu suited for your applications. This menu
allows the users of your applications to easily access several features.
The different wizard steps for generating the automatic menu are as follows:
Notes
Notes
132
GUI errors may appear in the Compilation Errors pane. These errors signal
interface problems, especially in the reports (captions too long for example). To
correct these errors, the reports must be modified.
1.Display the project description: on the "Project" pane, in the "Project" group, click "Description".
2.Display the "Advanced" tab.
3.Specify the lock options (2 minutes for example).
The following window will be displayed if the application is not used during 2 minutes:
Notes
The user will have to enter his Windows password to continue to use the application.
If the User Groupware is used by the application (see "Identifying the user: the
user groupware", page 264), the password to use is the one defined for the
User Groupware.
To check the lock of the application, run the test of the application and wait for 2 minutes.
The window asking for the password is displayed. Enter your Windows password and validate.
In order for our next tests no to be too long, we are going to delete this option.
Display the project description again:
1.On the "Project" pane, in the "Project" group, click "Description".
2.In the "Advanced" tab, uncheck "Lock the application...". Validate.
134
PART 3
Full application
with data
136
Projects supplied
Example project
The project and analysis creation was already presented in the previous part. We won't go back to
it. We are going to work with a project that already contains an analysis and pre-filled data files.
The analysis of the application is an improved version of the analysis that was created in the
previous section.
1.Close (if necessary) the current project to display the home window.
2.In the home window, click "Tutorial" and select the project named "Full application
(Exercise)".
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "Full application (Exercise)".
Before we start developing the application, let's take a look at the analysis associated with the
"WD Full application" project.
138
Close the data model editor (click the cross at the top right of the menu).
Corrected projects
You hesitate about the result to get? Or you don't have time to perform all the operations? A
corrected project is available for the application.
The application that we are going to create being quite long (it is a full application that will allow us
to discover the main features of WinDev), two corrected projects are available:
A corrected project corresponding to lessons 3.2 to 3.4. This project contains all the windows
created in these lessons.
To use this corrected project:
1.Close (if necessary) the current project to display the home window.
2.In the home window, click "Tutorial" and select the project named "Full application (With
windows)".
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group, expand
"Tutorial" and select "Full application (With windows)".
A corrected project corresponding to lessons 3.5 to 3.9. This project contains the entire
application.
To use this corrected project:
1.Close (if necessary) the current project to display the home window.
2.In the home window, click "Tutorial" and select the project named "Full application (Answer)".
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group, expand
"Tutorial" and select "Full application (Answer)".
140
and
modification windows
This lesson will teach you the following concepts...
Creating a menu window used to list the products.
Creating a product form.
Managing the addition and the modification of a product
Overview
We are going to create the different windows used to list, add and modify products.. These
operations will allow you to discover several topics regarding the management of data files and
they will also allow you to use some of the WinDev features.
If the "WD Full Application" project was not opened in the previous lesson:
Answer
1.Close (if necessary) the current project to display the home window.
2.In the home window, click "Tutorial" and select the project named "Full application
(Exercise)".
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "Full 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 "Full application (With
windows)".
Notes
142
Notes
5.The name of the window (that will be used in programming) is automatically deduced from
the title of the window. If this name does not suit you, you have the ability to modify it and to
specify a title that differs from the window name.
6.Validate.
This window was named "Menu" because it is the main window of our application.
It will be used as menu but it will also display information.
Notes
A Table control will be used to create the list of products. This control will be linked to the "Product"
data file.
What is a Table control?
Do not confuse "Table" and "Table control".
We talk of Table for a SQL database.
A Table control is used to view data in a table. In this case, the data can be
entered or it can come from a data file (or from a table).
The Table control of WinDev is used to view or modify the data:
in memory: we talk of memory Table control or Table control filled by
programming.
coming from data files or queries: we talk of browsing Table control.
coming from WLanguage variables: we talk of Table control on source.
1.On the "Creation" pane, in the "Data" group, expand "Table and list box" and select "Table
(Vertical)". The control currently created follows the movement of the mouse.
2.Click in the window: the wizard for creating the Table control starts.
3.The Table control that is currently created must display the records found in the "Product"
data file. In the wizard, select "Display the data coming from a file or from an existing query".
Go to the next screen by clicking the arrow at the bottom of the screen.
144
4.The next wizard screen proposes the different data files and the queries found in the current
project. Expand "Analysis" if necessary and select the "Product" file. Go to the next screen.
5.The wizard proposes the list of items found in the data file. By default, all the items are
checked in order to be displayed in the Table control. In our case, we are going to display all
the items EXCEPT for the "ProductID" identifier that corresponds to the automatic identifier of
the data file.
7.The following screens correspond to additional parameters. Keep the default options until
you reach the end of the wizard and validate.
8.The Table control is automatically created in the window.
We are going to reposition the control in the window and to enlarge it:
1.Select the control with the mouse: handles appear around the control.
2.Move the control with the mouse to position it at the top left of the window. Specific lines
appear when the control reaches the "WD Full Application" bar: these lines are positioning
rulers that are used to optimize the positioning of controls in the window.
Notes
3.Enlarge the Table control to the bottom (with the handles) so that it occupies the entire
window.
146
Let's take a look at the control that was just created: the data is already displayed in the control,
even in the editor. This concept is called "Live data": the content of the data files found on the
development computer is used in the windows or reports handled in the editor. This feature is very
useful to define the size of the controls found in a window for example.
Test of the window
We are now going to run the test of the window that was just created.
1. Click
among the quick access buttons.
2. The window is automatically displayed with its data at run time.
3. The products can be scrolled with the scrollbar.
Let's imagine that we are the end user to see the possibilities of the Table control at run time.
Some remarks:
First of all, the Table control has the same aspect at run time and in the editor: this notion is
called WYSIWYG ("What You See Is What You Get").
Small pictos appear at the top of columns:
the double arrow indicates that the column can be sorted ("Reference" or "Caption" column
for example).
147
Click twice the "Caption" column for example: the data is displayed according to a different
order. An arrow on the left of the columns indicates that the column is sorted as well as the
sort direction.
the magnifier indicates that a search can be performed in the column.
Click the magnifier of the "Reference" column for example. An input area is displayed,
allowing you to type the sought reference. Type "REF-010". The product corresponding to this
reference is automatically displayed.
A popup menu is available for the Table control and for each one of its columns. This popup
menu can be displayed:
via a right mouse click on the column of the Table control.
via a click on the arrow found at the extremity of the headers of columns.
This popup menu is used for example to export the content of the Table control in Excel
format, to print, ...
In just a few minutes, we have presented some of the features that are automatically included in
the Table control. No programming is required to propose these features to your users. These
features are called "AAF" (Automatic Application Features).
148
Notes
Several controls propose default AAFs. If these features must not be proposed
(for security or confidentiality reasons), they can be disabled in the editor or by
programming. See the online help (keyword: "Automatic Application Features")
for more details.
Now that the list of products is displayed, we may have to modify a product. To do so, we are going
to create a window used to display the product details.
Close the window via the cross found at the top of the screen. The WinDev editor is
redisplayed.
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 "WD Full
Application" analysis appear in the pane.
2.Click the "+" icon on the left of the "Product" file: the items found in the data file are listed.
3.With the mouse, select all the items displayed in the pane (except for the "ProductID" item).
You can for example use the lasso of the mouse or the multi-selection by keeping the CTRL key
down.
4.Drag and Drop these items to the window that was just created.
5.Different controls are automatically created in the window. These controls are
automatically linked to the corresponding item in the data file. To check this:
Select the "Reference" control for example.
Display the popup menu (right mouse click) and select "Description".
150
This tab allows you to see that the current edit control is linked to the "Reference" item found
in the "Product" data file.
6.Close the description window.
7.Save the window.
Reposition the controls in the window and resize the window in order to get the following
interface:
1.On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow found
below
).
2.The list of preset buttons is displayed.
3.Click "Validate": the shape of the button appears under the mouse.
4.Then, click on the right of the edit controls to create the button.
1.On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow found
below
).
2.In the list of preset buttons, click "Cancel": the shape of the button appears under the
mouse.
3.Then, click below the "Validate" button to create the button.
One of the first optimizations consists in aligning the controls and in giving them the same
size:
1.Select the "Caption" control then all the edit controls found in the window (keep the CTRL key
down while clicking the different controls for example). The first selected control will be used as
reference for the size of the other controls.
2.Display the "Alignment" pane of the WinDev menu. This pane contains all the alignment
options available for the controls
152
Notes
3.We want the outside and inside borders of controls to be aligned. Click "Justify (Ins and
Out)".
If you don't known which alignment to choose, hover the different options
proposed by the "Alignment" pane of WinDev. When an hovering option with the
mouse cursor, the selected controls are automatically positioned in the window
according to the hovered option.
If the positioning suits you, all you have to do is click the option.
If the positioning does not suit you, all you have to do is click inside the window:
the controls are moved back to their initial position.
1.On the "Modification" pane, in the "Preview" group, click "Preview". This runtime mode is used
to display the interface of the window. The different codes are not run.
2.Enlarge the window via the sizing handle found at the bottom of the window. The position
of controls is not modified and the window displays a large empty area. Two methods can be
used to solve this problem:
Forbid the window from being resized
Manage the anchors, which means manage the behavior of controls when the window is
resized. That's what we are going to do.
Notes
3.Close the preview: click the "Close" button or the cross found in the top right corner of the
window.
How do I manage the anchors in a window?
To manage the anchors:
1.In the editor, reduce the window to its minimum size. All the outside borders
of the window must be "stuck" to a control.
2.Consider the controls one by one and ask yourself the following question:
"How does this control must react when the window is enlarged?". Then,
apply the coresponding anchor.
1.The "Validate" and "Cancel" buttons must always be stuck to the right.
Select these two controls.
Display the popup menu (right mouse click) and select "Anchoring".
In the window for defining the anchors, select "Right" and validate.
154
Small red arrows appear in the editor, indicating that the controls are anchored to the right.
2.The edit controls must increase in width:
Select the 4 edit controls.
Display the popup menu (right mouse click) and select "Anchoring".
In the window for defining the anchors, select "Width" (
).
Validate.
3.We are going to check the operating mode of this window in preview:
On the "Modification" pane, in the "Preview" group, click "Preview".
Enlarge the window: the controls follow the enlargement in width. We must now define the
operating mode during the enlargement in height.
4.The "Description" control can contain a product description that is more or less important.
This is the most important control of the window: it must occupy the maximum available
space. Apply an anchor in width and height to it (
).
5.The "Price BT" is automatically bordered by a red line: the window editor signals an
anchoring problem. Indeed, if the "Description" control stretches to the bottom, the "Price BT"
control must move to the bottom accordingly.
6.Open the anchoring window for the "Price BT" control. The best anchor is automatically
proposed: "width and bottom" (a green checkmark is displayed). Select the proposed anchor
and validate.
7.We are going to check the operating mode of this window in preview:
On the "Modification" pane, in the "Preview" group, click "Preview".
Enlarge the window: the controls follow the enlargement in width and in height.
We are going to modify the "WIN_Menu" window in order to create a modification button:
1.Position on the "Menu" window: click the "WIN_Menu" button in the button bar:
2.At this time, the Table control occupies the entire window. Enlarge the window to the right.
The Table control is also enlarged via the anchoring mechanism.
3.Reduce the width of the Table control in order for all the columns to be displayed. We are
now going to create the button for viewing the product on the right of the table.
1.On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow found
below
).
2.In the list of preset buttons, click "Modify". The shape of the button appears under the
mouse. Then, click on the right of the Table control to create the button.
3.Right-click the button and select "Code" from the popup menu.
4.In the code window that is opened, enter the following code in the "Click" process:
Notes
Open(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.
5.Let's study this code: Open is used to open the "WIN_Product_form" window. This function
was already presented in the first part of this tutorial.
6.Save the modifications by clicking
among the quick access buttons.
7.Close the code window (click the cross in the top right corner of the code editor).
156
We are now going to modify the "WIN_Product_form" window to display the selected product in the
Table control.
Display the "WIN_Product_form" window in the editor: click the corresponding button in the
button bar.
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 Table control of the "WIN_
Menu" window.
3. Close the code window.
4. Save the window.
Display the "WIN_Menu" window in the editor: click the corresponding button in the button
bar.
Close the windows by clicking the cross (x) in the top right corner of the windows.
Managing the modification of a product
We are now going to modify the "WIN_Product_form" window in order to manage the modification
of a product.
We are going to:
allow the user to modify the image of the product.
add buttons to save or cancel the modifications performed in the form.
Modifying the image of the product
The user will be able to modify the image of the product in the Product form. To do so, we are going
to create a "Modify" button below the image of the product. This button will open a file picker used
to select the requested image
First of all, display (if necessary) the "WIN_Product_form" window in the editor: click the
corresponding button in the button bar.
1. On the "Creation" pane, in the "Usual controls" group, expand "Button" (click the arrow found
below
).
157
2.In the list of preset buttons, click "Modify". The shape of the button appears under the
mouse. Click in the window, below the image of the product.
3.Resize the button if necessary (with the handles) in order for the button and the Image
control to have the same width.
4.Right-click the button. Select "Code" from the menu that is displayed.
5.In the code window that is opened, enter the following code in the "Click" process:
fImageSelect(
Notes
7.Keep all the default options proposed by the wizard and validate. The corresponding code is
automatically inserted.
sFile is string
// Opens the image picker
sFile = fImageSelect("", "", "Select an image...")
This code is used to assign the selected file to the Image control found in the window.
9.Close the code editor (click the cross in the top right corner of the code window).
158
This feature will be checked when the management of modifications performed in the form is
completed.
Validate the modifications made to the product
Two buttons have been created in the "WIN_Product_form" window:
a "Validate" button to manage the validation of modifications
a "Cancel" button to manage the return to the list of products.
We are now going to enter the WLanguage code required for them to operate.
First of all, display (if necessary) the "WIN_Product_form" window in the editor: click the
corresponding button in the button bar.
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 on" process, enter the following code:
ScreenToFile()
HModify(Product)
Close()
Our window uses less than 10 controls and the benefit is already there; think of the windows
that use a lot more controls: a single code line performs all the assignments!
HModify is used to update the data found in the data file for the current record.
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).
The modifications performed in the "Product form" window must be taken into account in the
Table control used to list the products. To do so, we are going to modify the code of the
"Modify" button in the "WIN_Menu" window.
1.Display the "WIN_Menu" window in the editor: click the corresponding button in the button
bar.
2.Select the "Modify" button and display the code editor ("Code" from the popup menu of the
button).
Notes
3.In the list of products, select a product in the Table control (the first one for example) and
click the "Modify" button.
4.The details of the selected product are displayed in the form window.
5.Modify the price of 100.23 Dollars and enter 200.00 Dollars, then click the "Validate"
button.
6.When going back to the list of products, you will notice that the price was updated for this
article.
7.Display the project details again.
8.Click the "Modify" button below the image. The image picker is displayed. Select an image
and validate. The image is displayed in the form.
9.Click the "Cancel" button. The modification of the image was not taken into account in the
data file.
10.Click the cross to close the application.
160
1.Display the "WIN_Menu" window in the editor: click the corresponding button in the button
bar.
2.On the "Creation" pane, in the "Usual controls" group, expand "Button" and select "New".
3.The shape of the button appears under the mouse. Click in the window: the button is
created.
4.Position the button above the "Modify" button (modify the position of the "Modify" button if
necessary).
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 "Validate" button and select "Code" from the popup menu.
In the "Click on" process, replace the existing code by the following code:
ScreenToFile()
IF Product..NewRecord THEN
HAdd(Product)
ELSE
HModify(Product)
END
Close()
162
This window signals to the user that a duplicate was found: the reference (that is a unique
key) is identical for two products.. This window is used to modify the value of the reference
(displayed in a red area): enter "REF-338" for example.
This window is one of the windows for automatic management of HFSQL errors.
Notes
Several errors may occur when adding or modifying a record: duplicate error,
integrity error, password error, ...
WinDev proposes several modes for managing these errors:
the automatic mode: a specific window is displayed to the user whenever
an error occurs when managing the database records. This window allows
the user to modify his data directly.
the advanced programmed mode: a custom procedure or window for error
management is called whenever an error occurs when managing the
database records.
The "Detecting Errors" example, supplied with WinDev, allows you to check these
different modes for error management. This example can be opened:
via the home window of WinDev ("Open a project"),
via the "Wizards, Examples and components" pane.
164
3.Sort the elements by reference (click the header of the "Reference" column) and to two
added records appear.
search and
record browse
This lesson will teach you the following concepts...
Managing the search for records
Browsing the records
166
Overview
We have managed the addition and modification of records. It's fine. But it would be even better to
be able to find a record (to modify it for example). That's what we are going to do now.
We are going to modify the main window of the "WD Full Application" application to use the tab
panes.
The first tab will be used to display the list of products and to manage the addition and modification
of products (the operations have been performed in the previous lessons).
The second tab will propose to find a customer according to his name. The customer form will be
displayed in the tab.
Two search modes will be implemented:
an exact-match search,
a generic search.
Answer
Then, you will have the ability to browse the records found in the data file from the customer
displayed.
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 "Full application (With
windows)".
168
Notes
5.A green border appears when hovering the controls on the Tab control. This border indicates
that the controls placed on the current pane will be automatically associated with the pane.
6.Enlarge (if necessary) the window and the Tab control to display the Table control and the
buttons in the Tab control.
Handling controls in a Tab control:
To check whether all the controls are associated with the current tab pane,
click another tab pane.
To resize the Tab control while ignoring the anchors defined for the controls
found in the pane, press the [SHIFT] key during the resize operation.
1.Double-click the Tab control that was just created: the description window of the control is
displayed.
2.Modify the name of the control. The control is named "TAB_Viewing".
3.Validate the description window of the control.
Two panes are created by default. We are going to modify their caption directly:
3.Click "Pane 2". The pane is displayed. Click "Pane 2" again. Enter the caption: "Finding
customers". Press the ENTER key to validate.
We are going to associate an image with each tab pane. To do so:
1.Display the description window of the Tab control (double-click the control for example). The
"General" tab of the description window is used to configure the characteristics of each tab
pane. The panes are found in the top section and their characteristics can be modified in the
lower section.
2.In the description window, click the "List of products" tab.
3.In the lower section of the window, click "Details (pane)". We are going to associate an image
with the tab via the image catalog of WinDev.
170
Notes
4.Click the "Catalog" button. The window of the image catalog is displayed.
5.In the search area, specify "Product" and select the "Flat Soft" theme. Click the magnifier to
start the search.
A new control was just created: we must now define its anchor in the window. When the
window is enlarged, the Tab control must also be enlarged in order to occupy the entire
available space. Therefore, the control must stretch to the right and to the bottom.
1.Select the Tab control.
2.Display the popup menu (right mouse click) and select "Anchor".
and validate.
3.In the window for defining the anchor, select
among the quick access buttons.
4.Save the window by clicking
To create the different controls used to display information about the customer:
1.Display the WIN_Menu window in the editor and click the "Finding customers" tab. The empty
tab pane appears.
2.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 "WD Full
Application" analysis appear in the pane.
3.Click the "+" icon on the left of "Customer" file: the items found in the data file are listed.
4.With the mouse, select all the items displayed in the pane. You can for example use the
lasso of the mouse or the multi-selection by keeping the CTRL key down.
5.Drag and Drop these items to the "Finding customers" tab.
6.The controls are automatically created in the tab. These controls are automatically linked to
the corresponding item in the data file.
172
We are going to align the controls and to give them the same size:
1. Select the "City" control then all the edit controls found in the window (keep the CTRL key
down while clicking the different controls for example). The first selected control will be used as
reference for the size of the other controls.
2. On the "Alignment" pane, in the "Inside and outside" group, click "Justify (Ins and Out)".
173
Exact-match search
To perform an exact-match search, we are going to select the name of the customer in a Combo
Box control. The "Find" button will be used to display the form of the corresponding person. A
single person corresponds to the selected name.
The Combo Box control will be positioned above the created controls. If you controls are too
close to the tab, they must be moved to the bottom. To do so:
1.Select all the controls found in the tab:
Press CTRL A: all the controls found in the window and in the current pane are selected.
Press the CTRL key.
Click the tab: only the controls found in the tab pane are selected.
2.With the mouse, move one of the selected controls to the bottom.
1.Create a Combo Box control: on the "Creation" pane, in the "Usual controls" group, click
"Combo".
2.Click in the "Finding customers" pane, in the section found between the tab pane and the
"Customer identifier" control.
3.The wizard for creating combo boxes is displayed. We are going to create a combo box
based on the "Customer" data file.
174
4.Select "Display the data coming from a file or from an existing query". Go to the next wizard
screen.
5.Select the "Customer" data file. Go to the next screen.
6.We are going to display the last and first names of the person.
7.The "FullName" item will also be used to sort the list of customers displayed in the Combo
Box control. Select the "FullName" item. Go to the next screen.
8.The value returned by the Combo Box control will be the "CustomerID" identifier. This is the
value that will be sought in the Customer file. Select the "CustomerID" item and go to the next
screen.
9.The Combo Box control will be linked to no item. Keep the "No" option and go to the next
screen.
10.Validate the next screen with the yellow arrow.
11.Give a name ("COMBO_Customer" for example) and a caption ("Sought customer" for
example) to the control.
176
12.Validate. Position the Combo Box control in the window (top left corner for example).
13.Select the Combo Box control and resize it (via the handles) in order for the full customer
name to be displayed.
1.Create a button: on the "Creation" pane, in the "Usual controls" group, click
.
2.Position the button beside the combo box that was just created.
3.This control is named "BTN_ExactMatchSearch" and its caption is "Exact-match search".
4.Adapt (if necessary) the size of the button in order for the caption to be properly displayed
in the button.
5.Enter the following code:
// Finds the customer from his identifier
HReadSeekFirst(Customer, CustomerID, COMBO_Customer)
IF HFound(Customer) THEN
// Displays the customer data
FileToScreen()
END
Note
1. Display (if necessary) the "Finding customers" tab of the "WIN_Menu" window in the editor.
2. Create an edit control: on the "Creation" pane, in the "Usual controls" group, click
.
3. In the window, click below the Combo Box control ("Sought customer"). The edit control is
created.
4. This control is named "EDT_Sought_name" and its caption is "Sought name".
178
1. Create a button: on the "Creation" pane, in the "Usual controls" group, click
2. Position the button beside the edit control that was just created.
Note
HReadSeek is used to perform a generic search. In this example, the search is performed on
the "Customer" file and on the "FullName" item. The sought value corresponds to the value
entered in the "EDT_Sought_Name" control. This value is obtained by using the name of the
control.
An exact-match search can be performed by HReadSeek: to do so, use the
hIdentical constant.
179
4.The result is immediate. However, if several records correspond to the search, only the first
one is displayed.
5.Stop the test and go back to the editor.
Browsing the forms
We are now going to add four buttons used to browse the different records of "Customer" file.
These buttons are "recorder buttons".
To create the button used to display the first record of the data file:
A skin template will be used to standardize the interface of the project windows. This skin
template defines the style for all the controls found in the windows. A sepcific style is defined
for each recorder button. To apply this style:
1.Select the button if necessary.
2.Display the popup menu (right mouse click) and select "Choose a style".
180
3.All the defined for the buttons are displayed in the window. Select the "BTN_First" style.
4.Validate.
We are now going to enter the WLanguage code associated with this control:
1.Right-click the control. Select "Code" from the menu that is displayed.
2.In the code window that is opened, enter the following code in the "Click" process:
// Reads the first customer
HReadFirst(Customer)
IF HOut(Customer) = True THEN
// No customer
Info("No form to view.")
ELSE
// Displays the customer data
FileToScreen()
END
HReadFirst is used to read the first record of the data file, according to the key used for the
last search (FullName in our case).
183
search
184
Overview
In the previous lesson, we have explained how to perform a search on a single criterion (the
customer name). In this lesson, we will give the user the ability to perform a multicriteria search.
In our example, this search will be performed on the "Orders" file. The user will be able to select:
the status of the order,
the payment mode,
the order dates taken into account.
The interface of the "WIN_Menu" window is as follows:
Answer
The first step consists in creating the query for selecting records.
186
In the window that is displayed, specify an ascending sort on the item and validate.
6.A red arrow with the number 01 appears on the right of the "Orders.Date" item. This arrow
indicates that an ascending order is performed on this item. The number "01" indicates that
this sort will be performed first.
7.Give a name to the query: enter "QRY_FindOrders" instead of "QRY_NoName1" in the "Query
name" area:
8.Validate the description window of the query (green button at the bottom of the screen).
188
Notes
In our case, we want to display the orders corresponding to the search criteria only. To do so,
we must use a query with parameters.
A popup menu is displayed when a right click is performed on the result of the
query. The result can be exported to:
an XLS file (Excel).
an XML file (eXtensible Markup Language).
a text file.
To define the query parameters, display the description window of the query: double-click the
background of the graphic representation of the query.
4.Validate the description window of the condition. The number "1" appears on the right of the
"Orders.Status" item, indicating that a selection condition was defined.
We are now going to define a condition on the payment mode. This item is not found in the
result of the query but a condition will be applied to it. To do so, the item will be included in
the result of the query and it will be made invisible so that it is not visible in the result.
1.On the left section of the description window of the query, in the "Orders" file, double-click the
"PaymentModeID" item. The "PaymentModeID" item appears in the list of query elements.
2.To avoid displaying this item in the result:
Click
.
In the menu that is displayed, select "Don't display".
3.To define a selection condition on the "Orders.PaymentModeID" item:
Select the "Orders.PaymentModeID" item (in the middle of the screen).
Expand the "Selection condition" button and select "New condition".
In the window that is displayed, specify that the selection condition corresponds to a
parameter:
Select "Is equal to".
Check "the parameter".
Specify the name of the parameter: "pPaymentModeID".
4.Validate the definition of the selection condition.
The last selection condition to define affects the date of the order. This date must be included
190
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 used to specify the parameters of this query, to run it and
to display the result.
192
7.In the lower section of the window, click "Details (pane)". We are going to associate an image
with the tab via the image catalog of WinDev.
8.Click the "Catalog" button. The window of the image catalog is displayed.
9.In the search area, specify "Search" and select the "Flat Soft" theme. Click the magnifier to
start the search.
10.Select, among the proposed images, the icon representing the binoculars and validate.
11.Keep the options found in the setting screen of the generated image and validate.
Creating the interface used to configure the criteria and to display the result
We now want to display the result of our multicriteria search.
We are going to create a Table control based on the query then the different controls allowing the
user to select the search criteria.
Creating the Table control
To create the Table control used to display the result of the search:
1.In the "WIN_Menu" window, click the "Finding orders" pane. The empty tab pane appears.
2.Create a Table control: on the "Creation" pane, in the "Data" group, expand "Table and list
box" and select "Table (Vertical)".
3.Click in the tab pane: the wizard for creating the Table control starts.
4.The Table control will be based on the "QRY_FindOrders" query (that was created
beforehand). Select "Display the data coming from a file or from an existing query". Go to the
next wizard screen.
5.Select the query that will be used as data source for the Table control:
Expand the "Queries" group if necessary.
Select the "QRY_FindOrders" query.
Go to the next wizard screen.
194
7.Keep the default options in the different wizard screens and validate the creation of the
Table control.
8.The Table control is automatically created in the "Finding orders" tab.
9.Modify (if necessary) the position of the Table control so that it is entirely displayed in the
tab pane.
For better legibility, we are going to rename the captions of columns in the Table control.
Notes
2.Click the "COL_OrderID" column. The title of the column is displayed in the lower section of
the screen. Replace the "Identifier of Order" caption by "ID".
3.Click the "COL_FullName" column. Replace the "Full name" caption by "Customer".
4.Click the "COL_Caption" column. Replace the "Caption" caption by "Payment mode".
5.Validate the description window of the Table control. The control is automatically updated
with the modifications performed.
196
Notes
6. Increase the size of the ID, Date and Status columns in the Table control:
Hover the column separator on the right of the column to enlarge. The mouse cursor turns
into double arrow.
Click and keep the mouse button down while enlarging the column.
Release the mouse button once the column was resized.
7. Reduce the size of the "Payment mode" column in order for all the columns to be displayed
in the Table control:
Display the extremity of the table by using the horizontal scrollbar (as if the window was in
execution).
Hover the column separator on the right of the "Payment mode" column. The mouse cursor
turns into double arrow.
Click and keep the mouse button down while reducing the column.
Release the mouse button once the column was resized.
among the quick access buttons. We are going to check
8. Save the window by clicking
the sizes of columns by running the window.
Why is the Live Data not operating in this control?
The data is not directly displayed in the Table control because this control is
based on a query. The data displayed in the control depends on the query result
therefore it is known at run time only.
197
Let's take a look at the processes associated with the Table control:
The test parameters have been retrieved as default parameters for the execution. We are now
going to modify the window in order for the parameters to be entered by the user, via controls.
4.Close the code editor (click the cross at the top right of the editor).
We are now going to create in our window the different controls allowing the user to select the
query parameters. These controls will be positioned above the Table control.
Move (if necessary) the Table control in the window and reduce its height in order to get
available space for creating the different controls.
First parameter: Status of the order
Notes
198
The radio buttons are also called "option box". They are used to select a single
option among the proposed ones.
How do I differentiate a radio button from a check box?
An easy way to remember: think of the old radios: a single frequency could be
selected via the button !
The radio button is used to select a single option.
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 "WD Full
Application" analysis appear in the pane.
2.Click the "+" icon on the left of "Orders" file: the items found in the data file are listed.
3.Select the "Status" item found in the Orders file and Drag and Drop this item to the "WIN_
Menu" window.
4.The Radio Button control is automatically created. Position this control above the Table
control.
We are now going to pass the value selected in the Radio Button control in parameter to the
query:
1.Display the processes associated with the Table control:
Select the Table control.
Display the popup menu (right mouse click) and select "Code".
2.In the initialization process of the Table control, replace the line:
by
MySource.pStatus = RADIO_Status
In this code, RADIO_Status is the name of the Radio Button control that was just created. The
value of this control is associated with the pStatus parameter expected by the query.
3.Close the code editor.
Before running the test, we are going to create a button used to re-display the content of the
Table control according to the value selected in the Radio Button control:
1.Create a Button control:
on the "Creation" pane, in the "Usual controls" group, click
.
then, click at the top right of the window.
2.Select the control and press the "Enter" key on the keyboard. The button caption becomes
editable. Type "Find" and press the "Enter" key on the keyboard.
In this code, the taInit constant is used to re-run the initialization process of the Table control
(the process in which the parameters are passed to the query).
We are now going to check how the first parameter is passed:
1. Save the window by clicking
200
Notes
Several payment modes can be used for an order: cash, check, ... The available payment modes
are stored in the "PaymentMode" data file.
We are going to use a Combo Box control based on this data file to allow the user to select the
requested payment mode.
The "Combo Box" control is used to display a list of elements and to select an
element from this list.
Unlike a list box, a combo box is not expanded: it is expanded upon request or
when the cursor is positioned on the list.
The elements displayed in a combo box can be defined when the control is
created in the editor. These elements:
are defined by programming.
come from a data file or from a query.
1.On the "Creation" pane, in the "Usual controls" group, click "Combo box".
2.Click the location where the control must be created in the window (beside the radio button
that was just created for example).
3.The wizard for creating the Combo Box control starts.
4.Select "Display the data coming from a file or from an existing query" and go to the next
screen.
5.Select the "PaymentMode" data file and go to the next screen.
6.The item that must be displayed in the Combo Box control is "Caption". Uncheck
"PaymentModeID" and check "Caption". Go to the next screen.
7.Select the sort item: "Caption". Go to the next screen.
8.Select the return value: "PaymentModeID". This return value is very important because it
will be passed in parameter to the query. Go to the next screen.
9.Keep the default options in the different wizard screens and validate the creation of the
Combo Box control.
10.The Combo Box control is automatically created in the window.
We are going to modify some characteristics of the Combo Box control:
1.Select the Combo Box control and display the description window of the control ("Description"
from the popup menu).
2.In the "General" tab, modify the caption of the control: replace "PaymentMode Combobox"
by "Payment mode".
3.In the "Content" tab, specify the initial value displayed by the Combo Box control. In our
case, enter "1". This value corresponds to a payment in cash.
4.Validate the description window of the control.
Change the style of the control: to occupy less space, we are going to select a style that
displays the caption above the control.
1. Select the Combo Box control.
2. In the popup menu (right mouse click), select "Choose a style".
3. In the window that is displayed, select the "COMBO_Internal" style and validate.
4. Reduce the size of the control.
We are now going to pass the value selected in the Combo Box control in parameter to the
query:
1. Display the processes associated with the Table control:
Select the Table control.
Display the popup menu (right mouse click) and select "Code".
2. In the initialization process of the Table control, replace the line:
MySource.pPaymentModeID = 1
by
MySource.pPaymentModeID = COMBO_PaymentMode
In this code, COMBO_PaymentMode is the name of the Combo Box control that was just
created. The value of this control is associated with the pPaymentModeID parameter
expected by the query.
3. Close the code editor.
among the quick access buttons.
4. Save the window by clicking
We are now going to check how the first two parameters are passed:
among the quick access buttons.
1. Click
2. Select the "Finding orders" tab if necessary.
3. Change the status of orders via the radio button and modify the payment mode via the
Combo Box control, then click the "Find" button. The content of the Table control is modified.
202
Notes
The last query parameter corresponds to the date of the orders taken into account. The user must
be able to enter a date interval. To do so, we are going to use a control template.
A control template is a specific window containing different controls. All types
of controls can be included in this window. A control template is a file whose
extension is "WDT".
The first benefit of a control template is the reusability. A control template found
in a project can be re-used in any project window.
The control templates can be overloaded: source code can be added, the controls
can be moved in the window that is using the control template. The controls can
be modified.
3.Select the created control template and display its description ("Description" from the popup
menu).
4.In the description window, rename the control template. The new name is "CTPL_
ChoosePeriod".
5.Validate the description window.
6.Reposition and align the controls if necessary.
We are now going to pass the selected dates in parameter to the query:
1. Display the processes associated with the Table control:
Select the Table control.
Display the popup menu (right mouse click) and select "Code".
2. In the initialization process of the Table control, replace the lines:
MySource.pStartOfPeriod = "20110101"
MySource.pEndOfPeriod = "20110331"
by:
MySource.pStartOfPeriod = EDT_StartDate
MySource.pEndOfPeriod = EDT_EndDate
In this code, EDT_StartDate and EDT_EndDate are the names of the two edit controls found
in the control template. Their values are associated with the pStartOfPeriod and pEndOfPeriod parameters expected by the query.
3. Close the code editor.
among the quick access buttons.
4. Save the window by clicking
We are now going to check how the parameters are passed:
among the quick access buttons.
1. Click
2. Select the "Finding orders" tab if necessary.
3. Define the different parameters of the search:
Status of orders,
Payment mode,
Range of dates taken into account.
4. Click the "Find" button. The content of the Table control is modified.
the content of a
Overview
WinDev allows you to print your data:
by programming.
via the reports. A report is the name given to the graphic representation of a print. A report is
created via the report editor.
WinDev proposes several types of reports:
Blank
Form
Label
Table
Crosstab
TreeView table
Gantt chart
Organizer or scheduler
Multicolumn report
Mailing
Form
Composite
We are now going to explain how to create the different types of reports in the "WD Full Application"
application.
206
Answer
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (With windows)".
A corrected project of the application is also available: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Full application (Answer)".
In this case, to follow the rest of this tutorial, select the "Windows 32-bit
executable" configuration.
Note
In the previous lessons, you have noticed that several automatic features (called AAF) were
proposed by WinDev. An AAF allows you to print the content of a Table control.
The entire list of AAFs (Automatic Application Features) is available in the WinDev
AAF 19.PDF file. This file is automatically included in your application if you
choose the "Help for AAF" option when creating the automatic menu.
207
7.Click "Print".
8.Choose (if necessary) to print the content of the Table control in "Landscape" mode. The
report corresponding to the control is displayed in a preview window.
208
Note
1.On the "Creation" pane, in the "Data" group, expand "Table and list box" and select "Report on
Table control".
2.Our window containing 2 Table controls on different tab panes, WinDev asks you to select
the requested Table control. In our case, select "TABLE_QRY_FindOrders" and validate.
3.The shape of a button appears under the mouse cursor. This button is automatically created
and it contains the code used to print the content of the Table control. Click the position where
the button must be created in the window (below the "Find" button for example).
4.The report is automatically created.
5.A window proposes to add the report to the project. Validate.
6.The report editor appears with the report that was automatically created.
among the quick access buttons.
7.Save the report by clicking
8.This report includes the titles of the columns found in the Table control. We are going to
perform a modification in this report: we want to modify the title:
Select the control corresponding to the report title ("QRY_FindOrders table" is displayed in
the control) and double-click this control.
In the description window, modify the caption and enter "Sought orders".
Validate.
among the quick access buttons.
9.Save the report by clicking
10.Go back to the "WIN_Menu" window (click the "WIN_Menu" button found in the bar of
opened elements for example).
11.Modify (if necessary) the size and position of the "Print" button (in order for its size to be
identical to the one of the "Find" button).
among the quick access buttons.
12.Save the window by clicking
13.Run the test of the window.
Select the "Finding orders" tab if necessary.
Define the different parameters of the search:
Status of orders
Payment mode
Range of dates taken into account.
Click the "Find" button.
14.When the data is displayed in the Table control, click the print button or select "Print" from
the popup menu of the Table control: the report that was just created is used in both cases.
210
an order
Overview
Answer
We want to give the user the ability to print the details of the sought order. The report can be
directly printed via the popup menu of the Table control.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (With windows)".
A corrected project of the application is also available: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Full application (Answer)".
Note
First of all, we are going to list the information that must be displayed in the report:
The characteristics of the order: date and order number.
The personal details of the customer: name, address, zip code, city and country.
The characteristics of the order lines:
Quantity ordered
Reference of product
Caption of product
Total BT
Total IOT
To easily create this report, the data to print will be grouped in a query. This query can be used by
the report or by any other element of the WinDev project (Table control, Looper control, ...).
212
WinDev proposes to create reports from several data sources: data files, queries,
controls, text files, ...
In most cases, we advise you to group the data to print via a query and to create
a report based on this query. To add an information into the report, all you have
to do is add the corresponding item into the query.
The reports based on data files must be simple reports, which means reports
used to display data coming from a single data file.
The query editor will be used to create the base query of the report.
Note
1.Click
among the quick access buttons. Click "Query" in the wheel that is displayed. The
wizard for query creation starts.
2.Select "Select".
Indeed, this query will be used to select the records that will be printed in the report. Go to
the next screen.
3.The description window of the query is displayed. To build the query, we are going to select
the elements that will be displayed in the result.
4.Double-click the items found in the analysis on the left of the description
window. The items taken into account are displayed in the middle of the screen.
We want to print in the report:
the details regarding the customer. In the "Customer" file, double-click the FullName,
Address, ZipCode, City and Country items.
the details regarding the order. In the "Orders" file, double-click the OrderID and Date items.
the details regarding the product. In the "Product" file, double-click the Reference, Caption
and PriceBT items.
the details regarding the order line. In the "OrderLine" file, double-click the Quantity and
TotalBT items.
the details about the grand total of the order. In the "Orders" file, double-click the TotalBT
and TotalIOT items.
The order in which the items are inserted into the query is important. Indeed,
this order corresponds to the order used to display the data in the report. The
creation of the corresponding report will be simplified if this order is properly
defined.
At this time, this query is used to select all the orders and the corresponding order lines.
We want to select the data corresponding to a single order whose identifier is known. Therefore,
we are going to define the order number in parameter.
214
6.Validate the description window of the query (green button at the bottom of the screen).
7.The graphic representation of the query is displayed:
6.In the list of data files and queries, select the "QRY_OrderForm" query. Go to the next screen.
216
7.The wizard asks you to specify whether a break is required. No break will be used in this
report. This concept will be presented later in this tutorial. Answer "No". Go to the next screen.
8.You are going to specify the order in which the items will be printed and how they will be
distributed in the different blocks. In the wizard, the items are listed according to the order
defined in the query:
The items regarding the customer will be displayed in the "Page header" block. Indeed, this
information must not be repeated on each line of the order.
For the FullName, Address, ZipCode, City and Country items, click the line corresponding to
the item. In the "Block" column, expand the combo box and select "Page header".
The items regarding the order will also be displayed in the "Page header" block. Indeed, this
information must not be repeated on each line of the order. For the OrderID and Date items,
click the line corresponding to the item. In the "Block" column, expand the combo box and
select "Page header".
Furthermore, we are going to modify the caption of the "OrderID" item.
Select the line containing the OrderID item.
Click the Caption column and enter "Order #".
The items regarding the order lines will be displayed in the body of the report. These items
will be displayed for all the order lines of the order.
The items regarding the totals for the order will be displayed in page footer. Indeed, this
information must not be repeated on each line of the order. For the TotalBT_Or and TotalIOT
items, click the line corresponding to the item. In the "Block" column, expand the combo box
and select "Page footer".
218
Notes
Print margins
When choosing the print margins, don't forget to take into account the physical
margins of the printer. The physical margins of the printer are margins in which
no printing is allowed. Furthermore, the physical margins differ according to the
type of printer.
14.Validate.
15.The report being too big to be printed in Portrait mode, the report editor proposes to:
print on several pages,
use the landscape mode,
reduce the table.
In our case, select the landscape mode and validate. Then, accept to reduce the table if
necessary.
1. The report editor asks for the print destination. The print destination can be:
220
2.The report editor asks for the parameters of the query used by the report. Don't forget that
a parameter was used to specify the number of the order to print. For the example, enter the
test value "1".
Validate.
3.The report is displayed on the screen.
You can:
Print the current page or the entire document by clicking the printer
Create a duplicate copy.
Select a different zoom value with the icons
.
Save the report as a Word document (in RTF format).
Save the report in HTML format.
Save the report in PDF format.
Save the report in XML format.
Create an email with the report in HTML format in message body.
Create an email with the report in PDF format in attachment.
Annotate the document.
Perform a search in a document.
Add watermarks.
We are now going to position the information regarding the customer and the order in the
page header:
1. Delete the "Order form" caption found in page header.
2. Delete the captions found in front of the customer information (Full name, ...).
3. Position the item containing the city beside the zip code.
4. Select the information regarding the customer and move it with the mouse on the right of
the report.
5. Move the order number and the order date up (to the top of the "Page header" block).
We are going to position the totals properly in the page footer:
1. Select the controls (captions and items) corresponding to the totals found in the page footer.
2. Position these controls with the mouse in the bottom right corner of the table.
222
1.Open (if necessary) the "WIN_Menu" window in the editor (double-click its name in the project
explorer for example).
2.On the "Window" pane, in the "Bars and menus" group, expand "Popup menus" and select
"New popup menu".
3.A new popup menu appears in the editor. This menu includes a single option named "Menu
option".
Notes
224
We are now going to define the caption of the option and its code.
In this code:
iPreview is used to specify that the report print will be performed in the print preview.
iInitReportQuery is used to specify the parameters expected by the query associated with
the report. In our case, the query expects the order number in parameter. This order number
is found in the COL_OrderID column of the TABLE_QRY_FindOrders Table control for the
current row.
iPrintReport is used to print the specified report (the RPT_Order_form report in our case).
5.Close the code window and the window containing the popup menu.
6.Save the "WIN_Menu" window.
Associating the popup menu with the Table control
Last step: we are going to link the popup menu to the Table control.
5.Validate.
226
a list of
customers
This lesson will teach you the following concepts...
Creating a report with breaks
Starting the report print
Overview
Answer
This lesson is used to print a list of customers, grouped by country and by state or province.
To do so, we are going to use a table report in order to clearly represent a list of data.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (With windows)".
A corrected project of the application is also available: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Full application (Answer)".
228
4.Select the data source of the report. The report will be based on Customer file. Select "From
a data file or from an existing query". Go to the next screen.
5.In the list of data files and queries, select the "Customer" file. Go to the next screen.
6.Define the search key of the file. In our case, the Customer file will be browsed according to
the full name of the customer. Select the "FullName" search key. Go to the next screen.
7.We are now going to define the sort option of data in the report. By default, the wizard
proposes the item used as search key in the data file. As we want to create a report used to list
the customers by country and by state, we are going to add a sort on these two items.
Validate.
9.To add a sort on the state:
Click the "+" button to add a sort item.
In the window that is displayed, select the Customer.StateProvinceRegion item.
Validate.
10.Modify the order of the sort items. the customers must be sorted by country, by region,
then in alphabetical order.
The "Customer.Country" item appears in second sort item. Select this item and move it in
first sort item via the arrow buttons.
The "Customer.StateProvinceRegion" item appears in third sort item. Select this item and
move it in second sort item via the arrow buttons.
230
Notes
What is a break?
A Break is an operation used to group the records (or rows) according to one or
more criteria. Caution, the records (or rows) will be printed.
A break must NECESSARILY be linked to a sort.
You will notice the presence of a break header and footer.
The information common to the different rows is found in the break header.
The totals, counters, ... are found in the break footer.
This break is used to group a set of records according to the same criterion. In
our example, the break is performed on the country and it is used to group all the
customers living in the same country.
Uncheck the CustomerID, Complement, Phone, Mobile and Email items. Go to the next
screen.
232
Notes
23. The report is displayed in the report editor. Save the report.
The report is done. Let's now run the test of the report.
234
You have the ability to directly print the current page or the entire document by clicking the printer
.
1. Display the "WIN_Menu" window in the editor (double-click its name in the "Explorer" pane for
example).
2. On the "Window" pane, in the "Bars and menus" group, expand "Main menu" and select
"Add the main menu".
3. A menu is inserted into the window, below the title bar. This menu contains an option
named "Menu".
4. Select the "Menu" option:
Display the popup menu (right mouse click).
Select "Add after".
235
236
We are now going to modify this menu by adding an option used to exit from the application.
1. In the editor, select the "Menu" option.
2. In the popup menu (right mouse click), select "Transform to expand a sub-menu".
3. In the input area that is displayed, type "Exit".
4. We are going to associate this menu option with the "ALT + F4" shortcut:
Select the "Exit" option.
In the popup menu (right mouse click), select "Option description".
In the "General" tab, in the "Keyboard shortcut" area, select "F4" and check "Alt".
Validate
5. Display the code of the option and in the "Menu selection" process, enter the following code:
// Asks the user whether he wants to exit from the application
IF YesNo(No,"Exit from the application? ") = Yes THEN
// End of application
EndProgram()
END
237
and
238
Overview
Answer
3.Validate the description of the sum. The sum of "TotalIOT" was added into the list of query
result.
Notes
You will notice that the query editor of WinDev creates the queries in everyday's
language (and also in SQL language).
This allows you to check whether your query performs the proper operations.
240
We are now going to group the data by year and to sort it:
The query is created. We are going to give it a name and to save it.
1.At the top of the screen, enter the name: "QRY_SalesEvolutions".
2.Enter the caption: "Sum of orders by date".
3.Validate.
4.The graphic representation of the query is as follows:
5. Click
6. Click
242
4.In the wizard, select a "Bar" chart. Go to the next wizard screen.
5.Enter the parameters of the chart:
the title of the chart: "Sales evolution".
the legend: the chart has no legend.
the labels must be displayed.
For the series (values displayed in the Chart control): the Chart control will display a single
series corresponding to the total IOT calculated by the QRY_SalesEvolutions query.
Double-click the "Source of series" table.
Enter the caption: "Series 1".
the source corresponds to: Browsing a file or a query,
the data corresponds to the "sum_TotalIOT" item in the QRY_SalesEvolutions query.
244
Notes
Example
To master the use of a Chart control, don't forget to take a look at the examples
supplied with WinDev:
Unit example: Chart control
Training example: WD Chart
These examples are available from the "Wizards, Examples and Components"
pane.
As for the Chart control, we are going to include the Pivot Table control in a new tab of the WIN_
Menu window.
246
1.In the "WIN_Menu" window, select the "Pivot Table" tab if necessary.
2.On the "Creation" pane, in the "Data" group, expand "Table and list box" and select "Pivot
table (PVT)". The control appears under the mouse cursor.
3.Click the "Pivot table" tab. The wizard for creating a Pivot Table control starts.
4.Go to the next screen.
5.In the cells, we want to display the following information:
the total amount of sales
the quantity sold
We are going to select the source file in the wizard: OrderLine.
For the first information, select:
Display: "The sum of"
Source: "TotalIOT"
Click the "Add an additional value" button.
For the second information, select:
Display: "The sum of"
Source: "Quantity"
9.In the headers of rows, we want to display the products grouped by country. In the left
section:
expand the Customer file and double-click the Country item.
expand the Product file and double-click the Caption item.
among the quick access buttons). Click the "Pivot table" tab
CAUTION: The calculation time depends on the size of the database and on the
number of row and column headers. The result of the pivot table can be saved to
avoid re-calculating at each interrogation.
Click the "+" signs to expand the different columns and rows.
Stop the test. We are now going to improve this pivot table. Indeed, nothing indicates that one
of the numbers found in the cells corresponds to a quantity. We are going to use a specific
display mask for this value.
250
1.Display the description of the Pivot Table control (double-click the control).
2.In the "Content" tab, click "VAL_NoName2". The description of values displayed in the cells
is displayed.
3.In the "Mask" area, add the "Qt: " prefix.
an email
252
Overview
Several WLanguage functions can be used to manage the incoming and outgoing Internet
messages (called "emails"). Furthermore, WinDev allows you to find out all the characteristics of
an email:
sender, recipients
outgoing date, subject, message
attachments...
WinDev proposes several methods for managing the emails:
The POP3/SMTP protocols (most common method). These protocols are protocols for email
management recognized by all the service providers. These protocols allow you to directly
communicate with the server, available at your ISP.
The "<strong>Simple Mail API</strong>" (also called SMAPI or Simple MAPI): this mode for
email management is used by most of the Microsoft applications, especially by Microsoft
Exchange.
The Lotus Notes or Outlook messaging software: these programs allow you to send and
receive emails.
The IMAP protocol: this protocol for receiving emails is used to leave the emails on the
server so that they can be consulted from different messaging clients or webmail.
In this lesson, we are going to create a window allowing the user to send an email from the "WD
Full Application" application. This window is as follows:
To do so, we will be using the POP3/SMTP protocols. Indeed, this mode is commonly used all over
the world.
See the online help for more details about the other methods.
Answer
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (With windows)".
A corrected project of the application is also available: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Full application (Answer)".
Example
See the "WD Email" example (full example supplied with WinDev) for more details.
This example is accessible from the "Wizards, Examples and Components" pane
of WinDev.
254
To create the edit control corresponding to the name of the SMTP server:
1.On the "Creation" pane, in the "Usual controls" group, expand "Edit".
2.Select a preset Integer edit control.
3.The shape of the control appears under the mouse cursor.
4.Click below the "SMTP server" control: the edit control is automatically created.
5.Select the control and press the [ENTER] key on the keyboard. The caption becomes
editable. Type "Port" and validate.
To create the edit control corresponding to the name of the user:
To create the edit control corresponding to the password of the user:
Tip
1.On the "Creation" pane, in the "Usual controls" group, expand "Edit".
2.Select a preset "Password" edit control.
3.The shape of the control appears under the mouse cursor.
4.Click below the "User" control: the edit control is automatically created.
The "Password" edit control appears in the editor with a bullet and an eye.
At run time, when the user types his password, the characters will be replaced
by bullets. A click on the eye will allow the user to see his password in clear and
to check it.
This feature can be disabled by programming if necessary. See the online help
for more details.
or CTRL S).
To create the edit control corresponding to the address of the sender:
1.On the "Creation" pane, in the "Usual controls" group, expand "Edit".
2.Select the preset "Email" edit control.
3.The shape of the control appears under the mouse cursor.
4.Click below the "Password" control: the edit control is automatically created.
5.Select the control and press the [ENTER] key on the keyboard. The caption becomes
editable. Type "Sender" and validate.
The control used to enter the address of the recipient must list the addresses of the
customers found in the database but it must also allow the user to type another address. To
do so, we will be using an "Editable combo box" control linked to the Customer data file.
1.On the "Creation" pane, in the "Usual controls" group, click "Combo box".
2.The shape of the control appears under the mouse cursor.
3.Click below the "Sender" control: the wizard for creating the Combo Box control is
automatically started.
4.Select "Display the data found in a file or in an existing query". Go to the next screen.
256
To create the edit control corresponding to the subject of the email:
An HTML edit control will be used for the body of the message: the user will have the ability to
We are going to create a file picker allowing the user to add an attachment. Instead of
Note
creating it from scratch, we will be using the corresponding supercontrol supplied with
WinDev.
The supercontrol, like the control template, is one of the solutions available in
WinDev to re-use a set of controls.
The supercontrol is an advanced type of control. A supercontrol groups a set of
controls for a specific purpose (directory picker, file picker, ...). The supercontrol
contains:
the necessary controls,
the necessary code.
1.Display the "Wizards, Examples and Components" pane if necessary: on the "Home" pane of
the menu, in the "Environment" group, expand "Panes" and select "Wizards, Examples and
Components".
2.Click the "Controls" button then "Supercontrol". The list of available supercontrols is
displayed.
3. Select the supercontrol named "File picker" and perform a Drag and Drop from the pane to
the "WIN_Sending_an_email" window: drop the control below the "HTML text" control. The file
picker is immediately created. This control includes an edit control and a button used to select
the file.
258
We are now going to create the button used to send the emails.
Sending the email
This code is using an advanced EmailSMTPSession variable. The different properties of this
variable are used to define the characteristics of the SMTP session. Then, EmailStartSession
associated with this variable is used to start the session.
the code for preparing the email:
MyMessage is Email
// Clears the Email variable
EmailReset(MyMessage)
MyMessage..Sender = EDT_Sender
MyMessage..Subject = EDT_Subject
MyMessage..HTML = EDT_HTML_Text
MyMessage..Message = HTMLToText(EDT_HTML_Text)
// Adds a recipient
Add(MyMessage..Recipient, COMBO_Recipient..DisplayedValue)
// Adds the attachment if necessary
IF SC_FilePicker <> "" THEN
EmailLoadAttachment(MyMessage, SC_FilePicker)
END
This code is using an Email variable. The different properties of this variable are used to
define the characteristics of the email to send. This code associates the content of the
different window controls to the properties of the Email variable.
the code for sending the email:
// Sends the email
IF EmailSendMessage(MySession, MyMessage) = False THEN
Error("Message not sent.", ErrorInfo())
ELSE
// Message sent
ToastDisplay("Message sent", toastShort, vaMiddle, haCenter)
END
The email is sent by EmailSendMessage. All you have to do is pass in parameter the variable
containing the characteristics of the SMTP session and the variable containing the characteristics of the email to send.
If the email is sent, a Toast message is displayed, indicating that the email was sent. A Toast
message corresponds to a furtive message.
the code for closing the SMTP session:
// Closes the SMTP session
EmailCloseSession(MySession)
or CTRL S).
1.On the "Creation" pane, in the "Usual controls" group, expand "Button": the list of preset
buttons is displayed.
2.Click the "Close" button.
3.Click the position where the button must be created in the window (bottom right of Send
button for example).
Formatting
Select the "Sender", "Recipient" and "Subject" controls: these controls must be anchored in
width.
Select the "HTML text" control: this control must be anchored in width and in height.
Select the buttons: these controls must be anchored to the right and at the bottom.
Select the supercontrol for file selection: this control must be anchored in width and at the
bottom.
Note
1.Display the "WIN_Menu" window in the editor (double-click its name in the "Explorer" pane for
example).
2.In the editor, expand the "Menu" option and select "Exit".
3.Display the popup menu of the "Exit" option (right mouse click) and select "Add before".
4.Enter the caption of the option ("Send an email") and validate.
5.Select the "Exit" option again.
6.Display the popup menu of the "Exit" option (right mouse click) and select "Insert a
separator".
7.Display the popup menu of the "Send an email" option (right mouse click) and select "Code".
8.Enter the following code:
// Opens the window for sending emails
OpenChild(WIN_Send_an_email)
In this code, OpenChild is used to perform a "non-modal" opening of the window: the user will
be able to write an email and to see the information displayed in the main window at the
same time.
262
or CTRL S).
among the quick access buttons) and open the window for
user groupware
This lesson will teach you the following concepts...
What is the user groupware?
Integrating the user groupware
Configuring the user groupware
Checking the user groupware
264
Overview
An application can be used by several contributors with different profiles. It is often necessary to
define several access levels according to the user.
Let's take a simple example: when implementing an application for sales management, the
application proposes the following features:
Viewing the price list
Modifying the price list
Entering orders
Entering customers.
The accesses differ according to the user. Some examples:
the administrative assistants can see the price list and create orders
the sales people can see the price list, place orders and create new customers.
the sales directors have access to all the options.
Answer
WinDev allows you to easily manage these access levels via the user groupware.
We are going to include the user groupware in our "WD Full Application" application and to
configure it.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (Answer)".
To include the user groupware in the "WD Full Application" project:
1.On the "Project" pane, in the "Project" group, click "User groupware". The window for
configuring the user groupware is displayed.
Note
7.In the "Files" tab, select "Enable the history of connections". This option allows the supervisor
to get information about the connected users.
266
8.Select the "Options" tab. This tab is used to define the identification mode of the user:
management by the user groupware.
use of a LDAP directory. In this case, when installing the application, the user will be able to
enter the parameters of his LDAP directory.
use of the Windows authentication.
Note
A single user exists by default, the supervisor. During the first startup of the
application, connect yourself by using the name: "supervisor". You will have the
ability to define the password used by the supervisor.
268
Note
Configuring the groupware consists in defining the different users of the application as well as
their rights on the different windows and controls.
The configuration of users can be performed:
when developing the application. The necessary data files (regarding the users
and their rights) can be installed along with the application.
when the application is installed, by the administrator of the application.
To configure the user groupware, we are going to create a "Test_1" user and associate this
user with the "Tests" group. Then, we are going to configure the management of rights for the
group.
Note
1.Click the "New" button found below the "Users" area. The screen for entering a new user is
displayed.
2.Enter the following information:
Login: Test_1
Last name: Test_1
Password: Test_1
By default, the password is hidden during the input. To check the
password, click the icon shaped like an eye: the password appears in
clear as long as the mouse button is pressed.
3.Click the "Save" button. The "Test_1" user appears in the list of users defined for the user
groupware.
1.Click the "New" button found below the "Groups" area. The screen for entering a new group is
displayed.
2.Enter the name of the group: "Tests".
3.Click the "Save" button. The "Tests" group appears in the list of groups defined for the user
groupware.
270
Define the rights on the "WIN_Menu" window. This window contains a menu option used to
display the window for email management as well as the "New" and "Modify" buttons.
1.Select the "WIN_Menu" window.
2.Click the "Next" button.
3.The window for configuring the rights on the window controls is displayed.
4.Switch the "BTN_Modify" and "BTN_New" buttons to "Grayed":
272
We are now going to run the application test by using the "Test_1" login.
among the quick access buttons). A login window is displayed.
1.Run the test of the project (
2.Connect yourself as "Test_1" with the "Test_1" password. Validate.
3.The application starts. You will notice that the "New" and "Modify" buttons are grayed and
that the "Send an email" option is invisible.
Note
The user groupware will no longer be used in the rest of this tutorial. Therefore, it can be disabled.
1.On the "Project" pane, in the "Project" group, click "User groupware".
2.In the window that is displayed, in the "Options" tab, select "No user groupware".
3.Validate.
274
If automatic tests are run in your application, the user groupware must be
configured in order not to use the login window. To do so, fill the "Automatic
login in test mode" option in the "Runtime" tab of the window for configuring the
groupware.
external components
This lesson will teach you the following concepts...
What is an external component?
Creating an external component, step by step.
Distributing an external component.
Overview
A WinDev component is a building
brick that can be re-used in an
unlimited number of projects (and
therefore executables).
An external component allows you
to have an identical process with
a single source code to perform
a given operation even if this
process must be performed by
several projects.
The projects that use an external
component have access in the
WinDev editor to the name of
objects, procedures or methods made visible by the creator of the component. The projects cannot
see or modify the source code. This ensures confidentiality and stability of the source code.
Creating an external component is child's play.
How do I proceed? Proceed as usual, create your windows, procedures, classes. Then, instead of
choosing the option for creating the executable, choose the option for creating a component!
Notes
A component can contain source code, windows, an analysis, data files, etc.!
Five methods can be used to share "code" in WinDev:
1.The sets of procedures
2.The classes
3.The supercontrols (via the use of a dictionary)
4.The external components
5.The internal components
Let's present some cases in which the external components can be useful.
Teamwork
A developer creates and maintains an external component that is made available to the other
developers. No risk of modifications "made by mistake"!
The large projects
The external components allow you to have several small projects as well as a central project in
which the elements found in the other projects are visible. The external components are a lot
more convenient to use than the libraries (WDL files).
276
Step by step
Step 1: Creating an external component
We are going to create an external component from the "WD Full Application" project. This project
is used to manage the orders, the products and the customers. This external component will be
used to immediately find out in another application the customers corresponding to a given city.
During the call to the external component, you will have the ability to:
Pass a city in parameter.
Retrieve a string containing the name of the customer and the total amount of his orders.
Answer
To avoid having to develop the code required for the component to operate, the "WD Full
Application" project contains all the necessary elements.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (With windows)".
A corrected project of the application is also available: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Full application (Answer)"
a "QRY_OrdersByCity" query. This query is a query with parameters used to find out the
customers corresponding to a given city as well the total amount of their orders.
a set of procedures "SET_Component". This set of procedures contains:
the "GiveOrdersPerCity" procedure that returns, for the city passed in parameter, a string
containing the name of the customer and the total amount of his orders.
the "DataLocation" procedure that is used to localize the data required by the component.
an analysis used to described the data files for storing the information.
Notes
We are now going to create our component. To do so, a project configuration must be created.
278
The project configurations are used to create several "targets" from the same
project:
A 32-bit application,
A 64-bit application,
A component,
...
You have the ability to choose the requested configuration at any time and to
generate in a single operation all the elements for all the configurations of a
project.
1.On the "Project" pane, in the "Project configuration" group, expand "New configuration" and
select "External component (WDK)".
2.The wizard for creating a project configuration starts. WinDev proposes to create a project
configuration whose type is "Component". Go to the next screen.
3.Give a name to your project configuration: "CompOrdersByCity" for example. Go to the next
screen.
4.Keep the default options. Go to the next screen.
5.Select the elements that are included in the project configuration. In this example, these
elements are the ones that will be found in the component.
Click the "None" button.
Select the "QRY_OrdersByCity" and "SET_Component" elements.
6.Go to the next screen and validate the creation of the configuration.
7.The new configuration automatically becomes the current configuration.
Notes
To find out and modify the current configuration, use the "Project explorer" pane.
3.Select all the elements ("All" button) and go to the next screen.
4.The wizard asks you to select the component elements that will be accessible from the
client application.
280
If "Allow the component to be translated" is checked, the specified component elements can
be translated from the application that is using the component.
This translation will be performed via WDMSG, independent module used to check out and
check in the project messages to translate.
In this example, don't check this option. Go to the next screen.
7.Choose the languages of the component. Our example will contain the English language
only. Go to the next screen.
8.The wizard proposes to manage the different versions of the component. In our example,
the component was just created.
Keep the default options. Go to the next screen.
13.Go to the next screen. The wizard will automatically generate the documentation about the
component. This documentation can be based on the comments inserted into your source
code.
14.Go to the next screen. You have the ability to modify the generated documentation.
Don't do anything. Go to the next screen.
15.You have the ability to create a help file associated with your component (CHM format).
This help file will be supplied along with the component. The users will be able to access it by
pressing F1 from the code of the component.
We won't generate any help file. Go to the next screen.
16.You can allow the end users of the component to enter their own WLanguage code in order
to customize your processes. The suggestions can be directly sent to you. No input of "User
Macro-Code" will be allowed in this example. Go to the next screen.
17.The component will not be saved in the SCM. Go to the next screen.
18.All we have to do now is give a physical name to our component.
282
Validate. Well done, you have just created your first ready-to-use component!
To do so, we are going to create a new project and import our component into this project.
1.Close the current project: on the "Home" pane, in the "General" group, expand "Close" and
select "Close the project".
2.Validate the closing of the project and validate the backup of modifications if necessary.
3.The home window is displayed.
4.Create a new project: click "Create a project" in the home window.
This project is a Windows application.
This project is named "CompUse" and it has no analysis.
5.On the "Project" pane, in the "Project" group, expand "Import" and select "An external
component .. From a file".
6.In the directory of the "WD Full Application" project, select the "EXE\CompOrdersByCity" subdirectory, then the "CompOrdersByCity.wdi" file. The "WD Full Application" project is available in
the "Tutorial\Exercises\WD Full Application (With windows)" sub-directory.
7.Click "Open", the description of our component is displayed. This description contains:
In the "General" tab, the elements entered when creating the external component as well as
its location.
Notes
In the "Details" tab, the description of the component as well as the help that was
automatically generated. This allows you to identify the re-usable elements of the
component.
The description of the component can be accessed at any time. All you have to
do is select the component in the project explorer and select "Description" from
the popup menu. In this case, you can define the load mode of the component.
We are now going to create a blank window to use the component.
284
4.We are going to call the DataLocation function of the component in the "End of initialization"
process. This function expects in parameter the path used to access the data files handled by
the component. Enter the access path to the data found in the "WD Full Application" example.
SET_Component.DataLocation("C:\WinDev\Tutorial\...\")
// Specify the path of YOUR data
Edit the code of the "BTN_Search" button. During a click on this button, we are going to run
Run the window test by clicking the "GO" button found among the quick access buttons. In the
edit control, type "New York" (by respecting the case) and click the "Search" button. The list of
customers is displayed.
You know how to create a component and how to re-use it in your applications. You also have the
ability to manage the setup procedures of your components, in order to distribute them separately
from your applications for example.
286
Professional distribution
The distribution of components via a setup procedure consists in supplying a setup program
to the users of the WinDev component. This program installs all the files required for using the
component in the directory specified by the user.
This setup mode is used to automatically manage:
the WDO file and the setup of additional files used by the component.
the automatic setup of necessary tools (MDAC, ODBC driver for HFSQL,...).
the automatic update of the data files used by the component (if necessary).
the uninstall program of the component.
Go back to the "WD Full Application" project. Select (if necessary) the project configuration
corresponding to the component in the project explorer.
To create the setup, on the "Project" pane, click "Setup procedure".
The wizard for creating the setup of the component starts.
We won't go into details about the different setup modes of a component. Follow the instructions
given by the wizard. See the online help (keyword: "External Component, Distributing a component")
for more details.
Webservice
288
Overview
In most cases, an XML Web service is defined as an application accessible via the standard
Internet protocols. More specifically, the Web services allow several computers connected via
Internet to interact between themselves.
The Web services allow you to run procedures and processes on a remote Web server (.NET or
J2EE) from a client computer.
With WinDev, these Web services can be used as client, via the SOAP protocol on HTTP (the
standard Internet protocol for transferring HTML pages), with the SOAPxx, DotNetxx and J2EExx
functions.
Notes
Regardless of the platform of the Web server (.NET, J2EE, ...), a Web service can be accessed via
the SOAP protocol.
With WinDev, you don't even need to be an expert in this field. A wizard takes care
of ("almost") everything !
Practical example
A Webservice specific to the Tutorial allows you to check the different operations that can be
performed on a Webservice.
Included in the "WD Full Application" project, this Webservice is used to interrogate a supplier
database to check the availability (stock) of a product from its reference.
In a first time, the Webservice will be imported into the "WD Full Application" project then it will be
used in the application to check the availability of the product from a Product form.
Importing a Webservice
Answer
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (With windows)".
A corrected project of the application is also available: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Full application (Answer)"
1.On the "Project" pane, in the "Project" group, expand "Import" and select "A Webservice".
2.The import wizard starts. Go to the next screen.
3.Specify the address into which the WSDL description of the Webservice must be imported:
http://examples.webdev.info/WSTUTORIAL_WEB/awws/WSTutorial.awws?wsdl
Reminder: this Webservice is used to interrogate a supplier database to check the availability
(stock) of a product from its reference.
5.Validate the information window. The imported Webservice is found in the "Webservices"
folder of the project explorer.
290
Consuming a Webservice
In our "WD Full Application" example, the call to the Webservice will be included in the tab used to
see the list of products. A button "In stock ?" will be used to check the availability of the product
via the Webservice.
1.Open the "WIN_Menu" window in the window editor (double-click its name in the project
explorer for example).
2.Add a button into the "List of products" pane:
.
On the "Creation" pane, in the "Usual controls" group, click
In the window, click below the "Modify " button.
The button is automatically created.
3.Modify the characteristics of the button ("Description" from the popup menu). This control is
named "BTN_InStock" and its caption is "In stock?".
4.Display the processes associated with the button ("Code" from the popup menu).
5.Enter the following code in the "Click on BTN_InStock" process:
// Variable that contains the parameters for interrogating
// the ProductInStock function of the Webservice
MyQuery is ProductInStock
// Variable that retrieves the result
// of the ProductInStock function
MyResponse is ProductInStockResponse
// Defines the parameter: the reference of the product
MyQuery.sProductReference = COL_Reference
// Uses the function of the Webservice
MyResponse = ProductInStock(MyQuery)
// Displays the response of the Webservice
InfoBuild("Number of ""%1"" products in stock: %2", ...
COL_Reference, MyResponse.ProductInStockResult..Value)
292
the evolution of
your applications
This lesson will teach you the following concepts...
What is the dashboard?
Automatic tests
294
Overview
Answer
The project dashboard is a main element for managing the WinDev projects. The project dashboard
gives an overall view of the progress status of a project.
The dashboard includes several elements (Widgets) that give an overall view of the status of a
project.
In this section, we will present the operations that can be performed on the dashboard elements
and the management of automatic tests, as well as the optimization of queries.
If you did not create the windows in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (With windows)".
A corrected project of the application is also available: on the "Home" pane, in
the "Online help" group, expand "Tutorial" and select "Full application (Answer)"
To display the project dashboard (if not already done), on the "Project" pane, in the "Project"
group, click
The dashboard
The project dashboard includes several Widgets. Each Widget displays various information about
the project.
For example, the "Performances" Widget is used to start the performance profiler or to open the
last performance report.
The "Static audit and Compilation" Widget is used to quickly see whether the project contains
compilation errors.
You have the ability to enable (or not) a Widget, to add one or to delete one at any time.
(c) PC SOFT - www.windev.com - Express Version - Not to be released
295
296
Notes
This Widget is used to easily find a project element. All you have to do is type some letters found in
the name of the sought element. The selection is automatically performed.
You want to find an element without being positioned in the dashboard ? Press
[CTRL] + [E] ... and the same features will become available.
Automatic tests
One of the most interesting features of the dashboard is to give information about the tests that
have been run on the application.
Several tests have already been run while developing our application.
On the "Automatic tests" pane, in the "Tests" group, click "Show the results". A window displays
the validation rate of the application.
This window returns the list of all the tests that have been run on the application:
Manual tests (the tests that have already been run)
Automatic tests.
The automatic tests are a category of specific tests. The automatic tests are used to automatically
perform some operations on your windows. These tests are recorded as WLanguage scenarios
and they can be easily modified in the code editor. Once recorded, the automatic test can be
re-run as many times as necessary, to test for example the impact of a modification made to a
window, a procedure, ...
Note
Let's give it a try! We are going to create an automatic test on the edit window that was created at
the beginning of this lesson.
298
To create an automatic test on a window, all you have to do is run the test of the window:
Note
Note
14.The test is automatically run and the test editor displays the result (the test is successfully
run in our case).
15.Close the test editor and save the test if necessary.
We are now going to perform a modification in our window and to run the test again. The
Another feature of the test editor is the ability to modify or add WLanguage code in the test
scenarios. We are going to add code lines to check whether the Table control contains at least one
record.
1.Display the test editor (double-click "TEST_Menu" in the project explorer for example).
2.Display the code of the test ("Code" from the popup menu of "Test for finding orders").
300
the application
302
Overview
Answer
A full application was created, allowing you to discover several features of WinDev. We must now
generate the executable and install the application on the user computers. That's what we are
going to do now. So, you will be familiar with the main topics for developing a WinDev application.
If you did not perform the operations in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (Answer)"
Note
1.In the area of quick access buttons found in the ribbon, expand the wheel and select
"Generate the 32-bit Windows executable (.exe)".
2.The wizard for executable creation starts. A first screen presenting the status of automatic
tests is displayed. In our case, all the automatic tests have been successfully run. Go to the
next screen.
3.The next screen is used to describe the general options of the executable:
the name of the executable: we will keep the default name.
the name of the icon associated with the executable: you can select an icon found in the
image catalog.
the splash screen. WinDev proposes several types of splash screens. A splash screen with
animated text is selected by default. The "Options" button is used to configure it.
Note
304
Note
7.This screen is used to specify whether the executable will take the patches into account.
When a modification is performed in the application, to avoid having to
provide the entire executable, the additional resources (windows, reports, ...)
can be supplied as patches. These patches are additional libraries.
If "Yes, the executable will take these updates by patch into account" was
checked when creating the executable, the elements found in the patch will
replace the elements found in the application library when the application is
started.
See the online help for more details.
Note
Select the option corresponding to the system used by your users. Go to the next screen.
11.We are now going to enter the executable information. This information is displayed in the
Windows explorer by selecting the file properties.
Enter the following information for example:
Note
To use the necessary libraries only, select "Use the framework specific to the application".
To use the framework common to all the WinDev applications installed on the computer,
select "Use the common WinDev framework". With this option, the framework is installed
once only on the computer (it can also be downloaded by Internet) and it is used by all the
WinDev applications. Check this option.
Go to the next screen.
306
14.A screen regarding Windows Vista (and later) is displayed. This screen allows you to
include a manifest for a use in Windows Vista (and later).
Go to the next screen. WinDev proposes to save the project. This backup is used to keep a
version of the project whenever the executable is created. In our case, select "No: don't save
the project" and validate the wizard.
15.The executable is created. It can be run immediately to check its operating mode. To do so,
click the "Run the executable" button.
Note
That's it, the executable creation is ended. Several steps are required but as soon as a first
configuration is performed, you have the ability to validate all the steps from the beginning.
You also have the ability to click the steps specified in the wizard in order to
reach a wizard screen directly. The default options of the other screens will be
automatically validated.
Note
1.On the "Project" pane, in the "Generation" group, expand "Setup procedure" and select
"Create the setup procedure". The wizard for creating the executable and the setup starts.
The executable was already created: the selected options are stored.
In the wizard, click the "Complement" caption found in the "Executable" section.
2.A screen proposes to save the project. Select "No: Don't save the project" and go to the
next screen.
3.Let's now go to the "Setup" section of the wizard. In this first screen, choose the setup mode:
Individual setup for an independent application, installed and started on each computer. We
will choose this option.
Setup with automatic update, for a setup on a server. The applications will be installed from
the server. In case of update, only the server must be updated. The applications installed
on the computers will be automatically updated.
Go to the next screen.
4.Choose a standard setup. Go to the next screen.
5.We will not change the default setup directory. Go to the next screen.
6.Keep the files proposed in the list of installed files. By default, WinDev proposes the
Executable file and the help file (created via the new features). We are going to add the data
files:
Click the "Add" button. The Windows explorer displays the content of the generation directory
of the application.
Select the Customer, Orders, OrderLine, PaymentMode and Product data files (files with ".
fic", ".ndx" and ".mmo" extension).
Validate.
308
We will choose the optional tools to install and we will include the uninstaller. The uninstaller
will allow the users to uninstall the application from the program manager of Windows. Go to
the next screen.
10.We will select WDOptimizer. This tool is used to optimize the data files of the application
on a regular basis.
11.Click "Medium" on the left of the wizard. The setup will be generated in a single directory.
By default, the setup program is created in the "Install" sub-directory of the project. You can:
Specify a password for the setup. In this case, only the user who knows the password will be
able to install the application.
Sign the setup with a certificate. This option is used to ensure the integrity of the setup
pack.
12.Validate. The setup program is automatically created.
13.A screen is displayed, allowing you to check the setup or to open the generation directory.
Installing an application
In the window for the end of setup creation, click the "Test" button. If this window was closed, run
the "Install.exe" program found in the directory of the setup program. The setup of the application
starts.
We are going to follow the different steps of the setup program for the "WD Full Application"
application.
1.If you are using an operating system corresponding to Windows Vista (or later), a window
requests the authorization to run the program. Validate this window.
2.Choose the language of the setup program and click "OK".
310
312
314
Notes
"Reports & Queries" allows the users to modify and create their own reports and queries for your
applications.
A user thinks that an information is missing from the standard report? "Reports and Queries"
allows the user to add this information from the print preview directly. This modification can be
useful to the other users? The report can be made available to all the users who are using the
application in network. Same for the queries.
"Reports & Queries" is free and it can be distributed with your applications
created in WinDev. See the license for more details about the distribution and
the conditions.
Answer
We are going to present these different steps in details by using the "WD Full Application" project.
316
If you did not perform the operations in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (Answer)"
To use "Reports & Queries" from your application, you must configure the project associated
Notes
4.Validate.
Configuring the analysis
We are going to open the analysis in order to configure the files and items that can be used in
"Reports & Queries".
Notes
"Reports & Queries" does not allow the user to add, modify or delete records
(HAdd, HModify and HDelete are not allowed). No data file can be created or recreated (HCreation and HCreationIfNotFound are not allowed).
1.In the data model editor, select the requested data file.
2.Display the description window of the file ("Description of data file" from the popup menu).
3.In the "Reports and Queries" tab, uncheck "Visible to the end user in "Reports and Queries"".
4.Validate.
1.In the data model editor, select the requested data file.
2.Display the description window of the file ("Description of items" from the popup menu).
3.Select the requested item in the table.
4.In the "Reports and Queries" tab, uncheck "Visible to the end user in "Reports and Queries"".
5.Validate.
To take into account the modifications performed in the analysis, you must regenerate the
analysis ("Generation" option in the "Analysis" pane). An automatic modification of data files
is proposed to take the modifications into account.
To allow the "RPT_Table_QRY_FindOrders" report (found in the "WD Full Application" project)
318
To create the setup program of your "WD Full Application" application:
Notes
1.On the "Project" pane, in the "Generation" group, click "Setup procedure". The wizard for setup
creation starts. Click the "Setup" link on the left of the wizard.
2.Select "Create the executable and edit the help".
If you follow this lesson from the corrected example, the help file does not exist.
The wizard only proposes the "Create the executable now" option.
In this case, select this option and go to step 4 directly.
3.The executable is automatically created (with the options defined when creating the
executable).
4.The wizard for setup creation starts.
5.Choose an "Individual setup". Go to the next screen.
6.Choose a "Standard setup". Go to the next screen.
7.Validate the proposed setup directory and go to the next screen.
8.In the screen named "Files installed", select if necessary the data files (.fic, .mmo and .ndx)
found in the directory of the executable. To do so, click "Add" and select these files. Go to the
next screen until the screen named "Additional modules".
9.In the screen named "Additional modules" (accessible by clicking the "Complement" link on
the left), make sure that "Include the setup of Reports and Queries" is checked.
10.In the screen named "Reports and Queries":
Specify whether the setup of "Reports and Queries" must be included in your setup program.
In this case, the setup package of "Reports and Queries" will be sought. By default, this
setup pack is found in the "Reports and Queries" sub-directory of the setup directory of
WinDev.
Caution: Including "Reports and Queries" significantly increases the size of your setup (about
215 MB).
Specify (if necessary) the directories corresponding to the reports and queries modified or
created by the end user.
The directory of custom reports and queries corresponds to the directory of the reports and
queries visible by the user who created them.
The directory of shared reports and queries corresponds to the directory of the reports and
queries visible by all the users of the application.
These directories can be modified when installing the application: all you have to do is check
"Allow these directories to be modified during the setup".
11.Click "Medium" on the left of the wizard.
12.Validate the wizard. The setup program is generated. Don't close the window indicating the
end of setup creation.
320
In the window for the end of setup creation, click the "Test" button. If this window was closed,
run the "Install.exe" program found in the directory of the setup program. The setup of the
application starts.
We are going to follow the different steps of the setup program for the "WD Full Application"
application.
1.If you are using an operating system corresponding to Windows Vista (or later), a window
requests the authorization to run the program. Validate this window.
2.Choose the language of the setup program and click "OK".
3.The setup wizard starts.
4.Validate the setup directory of the application.
5.The screen named "Reports and Queries" is used to install "Reports & Queries" (only if this
program is not already installed on the current computer).
322
.
1.Click
2.The report is displayed in edit in "Reports & Queries".
In this example, the modified report is available to you only. For a network application, the user
has the ability to make a modified report available to all the users.
You are now familiar with "Reports & Queries". See the online help (keyword: Reports and Queries)
for more details.
Conclusion
The development step of our application is ended. The following lessons will allow you to discover:
how to transform your application into a multilingual application,
how to include your application in the Source Code Manager (SCM).
324
the
multilingual feature
This lesson will teach you the following concepts...
What is a multilingual application?
Creating a multilingual application, step by step.
Answer
1.Display the project description: on the "Project" pane, in the "Project" group, click "Description".
2.Click the "Languages" tab. Our application will support English and French.
3.Click the "Add" button. The window for selecting languages is displayed.
326
The "Languages" tab can also be used to configure the linguistic options regarding the
numbers, the currencies, the dates, ... for the selected language. Let's see an example:
1.Click the "French" language.
2.Select the "Date" tab.
3.The linguistic options of Windows are used by default. Select "Use the following parameters":
you now have the ability to define the date format as well as the translation used for the days
and for the months.
4.Keep "Use the settings defined in the linguistic options of the operating system".
Notes
In the linguistic options, you have the ability to choose the text direction for
the language ("Various" tab, "Text direction" option). This allows you to create
interfaces with a language written from right to left.
Validate. A message proposes to synchronize the different project elements. Answer "Yes". All
the project elements opened in the editor (windows, reports, ...) are closed and the additional
languages are added to these elements.
328
Note
To enter the shared information in several languages, let's take a simple example: the caption
Note
4.In the "Caption" area, type the caption for the French language: "Adresse".
5.Validate.
The shared information of the analysis can be translated:
when creating the analysis.
at any time via the editor.
at any time via WDMSG and WDTRAD, tools used to check out, translate and
check in the different elements.
To take into account the modifications performed in the analysis, you must generate the
analysis: on the "Analysis" pane, in the "Analysis" group, click "Generation".
330
Open the "WIN_Menu" window in the editor (double-click its name in the "Project explorer"
pane for example).
First of all, we must check whether the WIN_Menu window is associated with the different
languages defined in the project:
1.Display the window description ("Description" from the popup menu of the window).
2.Select the "Language" tab: the two languages selected in the project are displayed.
3.Select the "General" tab: the title of the window must be translated.
Localizing an image
To change the image of the bar used in the WIN_Menu window according to the runtime
language:
1.Open the "WIN_Menu.WDW" window.
2.The image of the bar is found in the template associated with the window. Therefore, the
associated window template must be opened:
Click the "WD FullApplication" control and display the popup menu.
Select "Open the template".
6.For our example, in the "French" area, select the "header-fr.png" file.
7.Validate. The "Multilingual value" caption appears in the "Image" area of the description
window.
8.Validate the description window of the control.
or CTRL S).
9.Save the window template (
10.Update the windows that use the window template by clicking the icon
in the orange
bar. Validate the update window.
11.Close the window template displayed in the editor.
332
For our example, we are going to translate the first pane of the Tab control.
2.To translate this type of message, position the cursor in the string "Exit from the application
?" and press [CTRL T]. You also have the ability, on the "Code" pane, in the "Languages" group,
to expand "Translate the strings" and select "Translate the messages".
4.This window allows you to translate all the messages of your program into all project
languages.
5.In the "French" area, type "Quitter l'application?" and validate.
6.The icon
as well as a number appear in the code editor.
1.On the "Display" pane, in the "Options" group, expand "Language displayed" and select the
language that must be viewed in the editor (French in our case).
2.The menu options are displayed in the selected language. If no translation corresponds to
the selected language, the menu options are displayed in English.
3.Expand the "Menu" option.
4.Select "Send an email".
5.Press the [space] key on the keyboard: the captions becomes editable.
6.Enter the caption in French: "Envoyer un email".
7.Modify the displayed language again: on the "Display" pane, in the "Options" group, expand
"Language displayed" and select "English".
334
3.Specify:
Whether the regional settings must be automatically enabled according to the language
used for the input. In this case, if the language requires a specific character set, this
character set will be automatically selected.
The software or the site that must be used for the translation. You have the ability to use
WDDixio, translation dictionary supplied with WDMSG (see next page), a specific translation
software or site, ou Google Translate (see the online help for more details).
The supported languages.
4.Once the translation parameters are defined, you have the ability to use the button
found in the different description windows of the project elements: this button allows you
to use the software defined for the translation.
336
1.Open (if necessary) the "WIN_Menu" window in the editor (double-click its name in the project
explorer).
2.Click the "Menu" option of the window. The menu is expanded.
3.Select "Send an email".
4.Display the popup menu (right mouse click). Select "Add after". Enter the "Languages"
caption and validate.
5.Select the "Languages" option that was juste created.
6.Display the popup menu (right mouse click) and select "Transform to expand a sub-menu".
7.Enter the caption of the first sub-option: "English".
8.Press the [Enter] key twice and enter the caption of the sub-option: "French".
We are now going to enter the WLanguage code required to change language.
Programming
Nation(nationFrench)
Nation is used to change the runtime language of the project. The constants passed in parameter
allow you to specify the language to use.
The change of language performed by Nation is immediately effective.
338
Introduction
The development of a large IS system requires the participation of several developers. These
developers must work on a single WinDev project while sharing the different resources (windows,
classes...).
WinDev is supplied with a Source Code Manager named "SCM" used to share the source code
of different projects between the developers and to find out the full history of the modifications
performed (in the code, in the interface, ...).
Whenever a developer wants to modify a project element (window, report, query, ...), he
informs the SCM that he is becoming the temporary owner of this element. To do so, this
element will be checked out from the SCM database by the developer.
This developer gets exclusive rights on this element: all the requested modifications can be
performed on this element.
The other developers are still working on the copy of the reference version of this element
(found in the SCM database).
Once the modifications have been made by the developer, the checked-out element is
checked back into the SCM database.
340
The other developers are automatically notified of this check-in operation. They can now
update their local copy.
The SCM supports teamwork and it allows you to find out the history of all the modifications.
The SCM can also be used to manage and control the elements shared between several projects.
Creating the SCM database
To share a project via the Source Code Manager, a SCM database must be created. This SCM
database must be created once only on a server.
This SCM database can be created:
when installing WinDev.
when creating a project that is using the SCM.
when importing a project into the SCM.
in the SCM administrator directly.
Notes
Our SCM database will be created when a project is imported into the SCM (next step).
We advise you to perform backups of the SCM database on a regular basis. To do
so, connect as administrator to the tool for SCM management and select "Tools ..
Management .. Full database backup".
Answer
To use an existing project with the Source Code Manager, all you have to do is include this project
in the SCM database.
If you did not perform the operations in the previous lessons, you can follow this
lesson by opening a corrected project: on the "Home" pane, in the "Online help"
group, expand "Tutorial" and select "Full application (Answer)"
We are now going to include the "WD Full Application.WDP" project in the SCM database:
1.On the "SCM" pane, in the "Project" group, click "Add the project". The wizard for adding
projects into the SCM starts:
The SCM database was not created yet. We are going to create one.
Note: We are going to create a "local" SCM database (on the development computer). The
operating mode would be similar for a network SCM database.
2.Click the "Create a database" button.
342
Notes
The SCM database can be in HFSQL Classic format (local or network) or in HFSQL Client/
Server format. We are going to create a SCM database in HFSQL Classic format.
If the SCM database is in HFSQL Client/Server format, this SCM database can
be used remotely.
4.Keep the "Creating a database in network share mode" option selected and specify the
directory of this SCM database ("C:\My Projects\Local SCM database" for example).
5.Validate the creation of the SCM database ("Create the database" button).
6.Validate the message. The SCM database is now created. We are going to include our
project in this SCM database.
7.Go to the next screen.
8.The wizard proposes to place the project in the "WinDev projects" sub-directory of the SCM
database.
344
Notes
11.Validate the inclusion of the project in the SCM. The project and all its elements have
been added into our SCM database.
A help window about the toolbar for using the SCM is displayed. Read and validate this
window.
Sharing the project elements
When the projects that share the same resources (same analysis, same windows,
...) are included in the SCM, the relevant elements can be shared between the
different projects. Therefore, the same element is checked in once only into the
SCM.
3.In the screen that is displayed, specify (if necessary) the connection and the local directory:
Notes
Note: If the project was already opened from the SCM, the SCM proposes to open the project as
usual or to overwrite the content (to retrieve the entire project).
This operation must be performed once only by each developer who is using the project.
The developer who added the project into the Source Code Manager (you in this case!) has no
operation to perform.
The method for opening a project managed by the SCM is identical to the method
for opening a project not managed by the SCM: all you have to do is open the
project (".WDP" file) corresponding to the local copy.
346
When working on the elements of a project found in the SCM, the element must be checked out
from the SCM database before it can be modified, then it must be checked back in once the
modifications have been performed. Therefore, the modified element becomes available to all the
SCM users.
WinDev proposes two modes for checking out the project elements:
the standard mode: if you display a SCM element that is not checked out, a dialog box
indicates that this element must be checked out before it can be modified. The element can be
checked out immediately (check-out button found in the panel).
the automatic mode: if you try to modify a SCM element that is not checked out, the SCM
automatically proposes to check out this element. Once the check-out is validated, the element
can be modified.
Note: this mode is not recommended when the SCM is used with a slow Internet connection.
In this tutorial, we will be using the automatic check-out.
To make sure that the automatic check-out is enabled, on the "Home" pane, in the
"Environment" group, expand "Options" and select "General options of WinDev". In the
"General" tab, check whether "Checking out elements during the first modification" is
selected. If not, enable this option.
Check-out mode of the project
Notes
The Project file (WDP file) contains the different options used to configure the project (initialization
code of the project, list of linked elements, name of the first project window...).
WinDev proposes two management modes of the project:
Master/Guest mode: Only the master can modify the project and apply these modifications to
the SCM database. The master can also check back in all the elements to create the executable
and the setup program. The modifications made to the project by the guests will not be taken
into account by the SCM database.
The Master/Guest mode is recommended when the SCM is used by a single
developer.
Notes
Automatic mode: The project file is checked out only if the action performed requires this checkout (regardless of the user). Once the action was performed on the project, the project file is
automatically checked back in.
The "Automatic" mode quickly becomes essential for the large projects shared by
several developers.
To make sure that the automatic check-out is enabled, on the "SCM" pane, in the "Project"
group, expand "Master/Guest" and check whether "Manage the project checkout
automatically" is checked.
We are going to modify the project by asking to display the skin template on the system
windows:
1.Display the project description: on the "Project" pane, in the "Project" group, click "Description".
2.Click the "Style" tab.
3.Check "Apply the theme of skin template to the system windows".
4.Validate the description window of the project.
1.First of all, the window for automatic project check-out is displayed. Indeed, we want to modify
a project characteristic therefore the project must be checked out.
348
3.A new window appears. This window is used to add elements and their dependencies into
the project found in the SCM database. Indeed, the option that was selected adds several
windows into the project:
6.A window for project check-in appears. Indeed, the project modifications have been
performed and the project is checked back in:
1.Select the "WIN_Product_form" window in the project explorer and double-click the element
to open it in the window editor.
Notes
If "Check out elements during the first modification" is not selected in the WinDev
options, an orange bar is displayed, indicating that the element is not checked
out from the SCM.
350
1.Display the description window of the Image control ("Description" from the popup menu).
2.In the "GUI" tab, modify the cursor used: select the "System hand" cursor.
3.Validate the description window of the control.
4.Display the code of the Image control: select the Image control and press [F2] for example.
5.Enter the following code in the "Click" process:
// Runs the click code of the button that modifies the image
ExecuteProcess(BTN_Modify, trtClick)
On the "SCM" pane, in the "Current element" group, click the "Check in" button. The following
screen is displayed:
352
Notes
Notes
access the history of the element found in the SCM database ("Properties" button).
enter a comment about the modifications performed. By default, WinDev proposes the
comment entered during the check-out.
send a message to the other developers.
check in the modifications made to the element while keeping the element checked out
("Keep the element checked out").
If you are using the Control Centers, the current task can be ended when the
element is checked back into the Source Code Manager. This feature is useful to
follow the monitoring of the tasks, the corrections of bugs, ...
354
SCM administrator
The SCM administrator is used to directly handle the different projects included in the source code
manager.
It allows you to:
manage the SCM databases (creation, connection to a SCM database).
manage the files and directories found in a project of the SCM database (add, delete,
rename, ... files and directories).
manage the different files of the SCM database (check-in, check-out, share...).
start some tools (options, maintenance, ...).
show the history of an element.
show the status of the elements.
perform backups.
grant rights to the different SCM users.
list the projects in which you are taking part in order to dissociate from them (if necessary).
Start the SCM administrator: on the "SCM" pane, in the "Database" group, click the "Manage"
button. All the project elements are listed in the administrator.
Conclusion
We have presented the main steps for developing an application.
WinDev proposes several tools to optimize your applications. See "Project audits" (page 385) for
more details.
356
PART 4
Managing a
HFSQL Client/
Server database
358
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
Overview
WinDev allows you to create applications that access HFSQL Client/Server databases.
A HFSQL Client/Server application runs an application on several computers (called client
computers) and stores the databases and processes on a server. This operating mode makes
response times faster and more reliable, and it simplifies the maintenance of the database.
360
362
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
Overview
In this lesson, we are going to perform all the operations required to develop and deploy a HFSQL
Client/Server application.
Caution!
The first operation to perform before developing a HFSQL Client/Server application consists in
installing a HFSQL server.
This server can be installed locally on the development computer (that's what we are going to do).
In deployment, this server can be installed on a specific computer.
The setup program of the HFSQL server is available on the WinDev CD. If you do not own this CD,
the setup of the HFSQL server is also available from our Web site (www.windevcom).
To install the HFSQL server locally:
1.Start the setup program of WinDev.
2.Choose "Setup of HFSQL C/S server".
3.Then, select "Install a HFSQL Client/Server server".
4.Accept the license agreement.
5.Choose the platform ("For Windows on this computer").
6.Choose "Install a new server".
7.Select the setup directory and specify the name and port of the server. The port 4900 will
be used by default. You have the ability to install the HFSQL Control Center if this one is not
found or not accessible from your computer.
The HFSQL Control Center is required to manage the HFSQL Client/Server
database.
8.The setup is performed. By default, to connect to the server in administrator mode, use the
"admin" user without password.
Answer
6.Specify the name of the connection (keep the proposed name). Go to the next screen.
364
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
the name of the server (name of your computer for example) and the port number,
the name of the user and his password (leave this information empty to use the
administrator)
the name of the database ("WD Full Application" in our example).
8.Go to the next screen and validate. The connection to the database is automatically
created. The wizard proposes to associate the different data files found in the analysis with
the connection that was just created.
9.Click "Yes".
12.Select the data files that will be copied onto the server: in our case, all the data files found
in the EXE directory. Go to the next screen and validate.
366
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
13.The data files of the analysis are automatically transformed into HFSQL Client/Server data
files and associated with the selected connection.
14.Generate the analysis: on the "Analysis" pane, in the "Analysis" group, click "Generation".
An automatic modification of data files is automatically performed. You have the ability to
cancel the automatic modification of data files if all the data files are updated.
Notes
15.The development project was migrated. You may also have to migrate the deployed
application (if the deployed application is using HFSQL Classic files for example). This operation
is configured when creating the setup program of the application.
368
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
Client/Server
database
This lesson will teach you the following concepts...
The HFSQL Control Center
Creating a user in the HFSQL Control Center
Saving the database
Overview
Now that we know how to create and/or migrate an application in HFSQL Client/Server, let's see
how to manage the associated database.
Indeed, a Client/Server database requires:
a specific configuration of the computers (setup of a HFSQL server, ...)
a management performed via the HFSQL Control Center.
370
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
4.Click "HFSQL Client/Server file". The list of data files in HFSQL Client/Server format is
displayed.
The Control Center lists the data files found in the analysis linked to the current project. No
connection is established.
5.To view the data files, double-click one of the data files in the list on the left. The HFSQL
Control Center displays a connection window used to establish the effective connection to the
HFSQL Client/Server server used.
Caution!
A single user account is created when installing a HFSQL server and when creating a database:
the administrator account ("Admin" login without password).
Using a user account allows you to secure the access to the data. Indeed, all the users of the
application are not administrators. Specific rights can be granted to each user (or group of users).
The user rights specified in the HFSQL Control Center are granted for the
database (and not for the application).
Do not confuse the management of rights for the Client/Server databases with
the user groupware.
Some users may not have the rights to write into some data files for example.
To run a simple test, we are going to create a user and allow this user to see the records found in
Customer file.
1.In the HFSQL Control Center, click
and validate the closing of connections if necessary.
2.The home window is displayed in the HFSQL Control Center.
3.The option "Connect to a HFSQL server" is selected by default. Specify the characteristics of
the server installed in the previous lesson.
4.The characteristics of the HFSQL server are displayed:
in the panel on the left, the computer, the name of the HFSQL server as well as the list of
databases found on this server.
in the right section of the screen, the different tabs are used to manage the HFSQL server.
372
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
5.In the right section of the screen, select the "Users and Groups" tab. This tab is used to
manage the users of the server.
6.Only the "Admin" user exists at this time.
7.To create a new user, click the "New" button (below the list of users). The screen used to
define the characteristics of the user is displayed.
Notes
9.Validate the creation of the user. By default, no rights are granted to this user.
374
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
We are now going to grant rights to the user: the "Test" user can connect to the database and he
can read the Customer file.
To grant the rigths to connect to the database:
1.In the HFSQL Control Center, select the "WD Full Application" database.
2.Click the "Rights" tab.
3.Select the "Test" user in the list of users.
4.In the list of rights, select "Rights to connect to the server" (encrypted and non-encrypted
connection). Select the green checkmark in the "Defined rights" column.
5.Click the "Apply" button found on the right of the list of rights. The rights become effective.
To grant the rights to read the Customer file:
1.In the HFSQL Control Center, select the "WD Full Application" database then select the
Customer file.
2.Click the "Rights" tab.
3.Select the "Test" user in the list of users.
4.In the list of rights, select "Rights to read the file records" and select the green checkmark in
the "Defined rights" column.
5.Click the "Apply" button found on the right of the list of rights. The rights become effective.
Notes
In our example, the "Test" user will have the ability to browse the records found in Customer file.
If this user tries to perform another action, a message will be displayed: "The Test user has no
sufficient rights to XXXX" (where XXXX corresponds to the action performed).
Once the account is created, it can be used when the application connects to the server (when
HOpenConnection is used).
The users and their rights can also be managed by programming with the
WLanguage functions. See the online help for more details.
376
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
Conclusion
The HFSQL Control Center is a tool for managing the databases, allowing you to:
stop or restart a server if a problem occurs,
manage the users and their rights,
reindex the data files if necessary,
perform backups of the database.
The HFSQL Control Center is a redistributable tool that can be installed on the computers of the
users who are working with HFSQL Client/Server databases. The HFSQL Control Center must be
used by the administrator of the database.
on user computers
378
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
Overview
Installing a Client/Server application requires several specific options. These options are taken
into account by the wizard for setup creation.
We are going to create the setup procedure of our "WD Full Application" application.
If these options are checked, the next screens are used to configure the elements that must
be taken into account for the setup on the user computers.
See the online help for more details.
380
Part 4: Managing a HFSQL Client/Server database (c) PC SOFT - www.windev.com - Express Version - Not to be released
PART 5
Optimizing and
debugging a
project
382
Overview
Your application is created. It operates properly, several automatic tests have been created to
avoid the regressions. You want to deploy it on the user computers.
Do you know that several WinDev tools can be used to optimize your application? WinDev proposes
several tools and features allowing you to optimize your application and to avoid predictable bugs.
This section presents these tools and their use.
A project to optimize was prepared, allowing you to handle these features!
Opening the project
Start WinDev 19 (if not already done). Close (if necessary) the current project to display the
home window.
To do so, in the home window, click "Tutorial" and select "Optimize a project".
Tip: if the home window is not displayed, on the "Home" pane, in the "Online help" group,
expand "Tutorial" and select "Optimize a project".
384
audits
What is an audit?
The audits bring a set of features used to automatically improve the quality and the performances
of a project and to follow the conditions in which it is implemented.
The main audits are as follows:
The static audit. The static audit performs a detailed analysis of a project and elements. This
audit is performed from the project editor.
The dynamic audit. The dynamic audit analyzes the behavior of a project during its execution.
This audit can be performed in test mode or in the production environment.
We are going to check these audits on the "WD Optimization" project.
Static audit
The static audit is a feature of the environment allowing you to analyze the project elements in
order to detect the different problems and to propose improvements.
The static audit includes:
The static audit of the project
The audit of the content of the application library
The audit of the setup content
1.On the "Project" pane, in the "Audit and performances" group, expand "Edition audit" and
select "Trigger the edition audit".
Notes
The static audit of the project can also be started from the project dashboard,
via the "Static audit and Compilation" widget.
All you have to do is click the arrow button.
2.The wizard starts, allowing you to define the target of the static audit.
386
3.Select "Start the static audit on the entire project" and validate the wizard.
4.The audit report is displayed:
1.Click the [...] button to get more details. The window that lists the dead codes is displayed.
2.The procedure named "ObsoleteProcedure" is never called. This window is used to:
specify that the procedure is still used ("Mark as used" button). In this case, the procedure
will not be taken into account anymore during the audit.
see the procedure ("View" button).
delete the procedure if it is actually unused.
3.In our case, this procedure is actually unused, click "Delete".
4.A window is displayed, asking you to confirm the deletion. Click the "Delete" button to
confirm the deletion.
5.Close the window of dead code (click the cross in the top right corner).
In the window of static audit, click the "Refresh" button to update the audit report.
388
Orphan element
Our project contains an orphan element.
As for the procedures run, you may create windows or reports in order to run a quick test, save
them and forget everything about them... The presence of orphan elements in the executable
unnecessarily consumes the resources distributed to the end users.
1.Click the [...] button to get more details. The window that lists the orphan elements is
displayed.
2.The window named "WIN_UnusedWindow" is never called. The window that lists the orphan
elements is used to:
specify that the element is still used ("Mark as used" button). In this case, the window will
not be taken into account anymore during the audit. This option can be interesting when
using a test window specific to the development for example.
see the element ("View" button).
delete the element if it is actually unused.
3.In our case, this "WIN_UnusedWindow" window is actually unused, click "Delete".
4.Close the window of orphan elements (click the cross in the top right corner).
In the window of static audit, click the "Refresh" button to update the audit report.
Query to optimize
Our project contains a query to optimize. This optimization is used to improve the execution speed
of the query. The optimization of a query is based on the following principle: a wizard defines the
composite keys that must be modified and/or added in the analysis associated with the project.
1.Click the [...] button to get more details. The window that lists the modifications to perform is
displayed.
2.The wizard proposes to modify an analysis item by changing it into a key with duplicates.
3.We are going to apply this change: click the "Apply these modifications to the analysis"
button.
4.A window is displayed, asking you to confirm the analysis modification. Validate this window.
5.The data model editor is opened and the modification is performed. A message indicates
that the analysis must be generated. Click "Yes" to confirm the generation of the analysis.
6.The application is using data, an automatic modification of data files is required. Validate
the different screens of the wizard for data modification (by keeping the default options).
7.The window of the static audit is automatically refreshed.
390
Dynamic audit
The dynamic audit of an application is used to analyze its performances at run time. A dynamic
audit can be performed in a test environment or on a live application. The audit is used to detect
problems such as:
Excessive memory consumption
Slowness of the algorithms used
Errors "hidden" at run time
...
The "WD Optimization" project contains a specific window triggering errors that can be detected by
the dynamic audit.
The dynamic audit and the project test will be started at the same time.
1.On the "Project" pane, in the "Test mode" group, expand "Test mode" and select "Debug the
project while the audit is enabled". The test of the project is run.
Notes
The static audit of the project can also be started from the project dashboard,
via the "Execution" widget. All you have to do is expand the arrow button and
select "Detailed Go of project".
Note: The dynamic audit is automatically run whenever the application is started
by a project GO. A status report is automatically displayed in the dashboard:
392
The top section of this window is used to choose the display mode of data. You can:
choose a chronological display (respecting the order in which the events occurred) or an
overall display, used to group the different types of problems. In this case, the chronological
border allows you to see the position and importance of problems.
choose the type of problem to display (error, assertion, ...). This allows you to concentrate on
the major errors, ...
The bottom section displays the different events that occurred and that may cause problems
in the application.
Notes
394
profiler
Overview
The performance profiler (also called Profiler) is used to check and optimize the execution time of
your application.
Its principle is straightforward:
You run the test of your application.
During this test, the performance profiler keeps track of all the actions performed and the
corresponding processes run.
At the end of the test, the performance profiler displays:
the 10 most time consuming operations
all the actions performed in the application whose test was run, sorted by duration (from the
longest one to the shortest one).
You have the ability to select a specific process in order to analyze the reasons for its duration.
The "WD Optimization" project contains a specific window used to view the interesting results with
the performance profiler.
ProfilerEnd
In this case, only the code found between ProfilerStart and ProfilerEnd is analyzed. The result is
saved in a WPF file.
396
The first method will be used in our example. To start the performance profiler on the "WD
Optimization" project:
1.On the "Project" pane, in the "Audit and performances" group, expand "Analyze the
performance" and select "Analyze the performance".
Notes
The performance profiler can also be started from the project dashboard, via the
"Performances" widget. All you have to do is expand the arrow button and select
"Detailed Go of project".
Let's study the report window of the performance profiler. The results are displayed in several
tabs:
the "Summary" tab presents the ten longest processes.
the "Mapping" tab presents a graphical view of the main processes.
the "Details" tab presents all the processes run during the test of the application (from the
slowest one to the fastest one).
the "Calls" tab is used to view the details of the operations performed in a process.
The "Summary" tab presents the ten longest processes. In our example, you can see that
the local procedure named "UpdateProductStock" takes more than 3 seconds to be run.
The "Mapping" tab is used to visually identify what took the longest time. In our case, it is a
call to the Ping function:
398
The "Details" tab presents all the processes run, from the slowest one to the fastest one.
The slowdown is caused by the fact that the address specified for the Ping function is not
accessible.
Let's check the operating mode of the application by optimizing this code:
1.Replace the code line containing the Ping function by the following code line:
// Checks the accessibility of the supplier server
Ping("http://windev.com")
400
1.On the "Project" pane, in the "Audit and performances" group, expand "Analyze the
performance" and select "Analyze the performance".
2.The test of the project is run.
3.Click the "Test window of performance profiler" button.
4.Click the "Process to analyze" button.
5.Validate the information window and stop the project test. The report window of the
performance profiler is displayed.
6.In the "Mapping" tab, the Ping function does not appear with the same importance.
a project
402
Overview
Let's take a look at the debugger supplied with WebDev.
What is the debugger?
The debugger is a powerful tool used follow the progress of a code or application, step by step.
Enhancing a process or even an application is child's play.
We are going to use the debugger on the long process found in the WIN_PerformanceProfiler
window.
Note
1. Open the "WIN_PerformanceProfiler" window in the window editor (double-click its name in
the project explorer).
among the quick access
2. Run the test of the "WIN_PerformanceProfiler" window (
buttons).
3. Start the debugger by using one of the following methods:
Press CTRL + Pause: the debugger will be automatically started during the next user action
in the window whose test is run.
Go back to the WinDev editor and position a breakpoint in the code of the "Process to
analyze" button (click in front of the first code line of click process, a red dot appears). The
debugger will be automatically started when the line preceded by the breakpoint is run.
Several methods can be used to start the debugger. See the online help (keyword:
"Debugger, Run a test") for more details.
4. Click the "Process to analyze" button. The debugger starts. The current line is preceded by
a little arrow.
403
The "Debugger" pane appears in the lower section of the screen. This pane displays two distinct
areas:
the call stack: this area is used to find out the hierarchy of the processes displayed in the
debugger. In our example, we are currently debugging the click process on the BTN_LongProcess
button.
the list of expressions to evaluate. By default, the main variables used in the code are displayed
in this section. You have the ability to add variables to follow their evolution (this feature will be
presented later).
We are going to perform some modifications in the debugger to check its capabilities.
404
First of all, we are going to run the different statements step by step and see the content of
variables:
1.Press the F8 key (or click the "Step by step" button found in the ribbon). The line following the
current line is automatically run. The values of the variables are modified (if necessary) in the
"Debugger" pane (displayed at the bottom of the screen).
2.When the cursor shaped like an arrow reaches the "PROGBAR_Progress..MaxValue = ..."
line, hover "PROGBAR_Progress" with the mouse. A tooltip is displayed with the value of the
expression:
Let's continue our operations in the debugger. We are now going to run the
We are now going to add an expression to monitor the evolution of its value in the "Debugger"
pane. This expression can have any type: variable, function, operation on variables, ... The
result of the expression is calculated and displayed.
This expression is used to perform a custom debugging. For example, you can find out the
content of a variable as it is being used in the application.
1.Press F7 to run the different lines of the UpdateProductStock procedure until you reach the
line:
PROGBAR_Progress++
The F8 key is used to run the code of the InterrogateSupplierDatabase procedure without
running it step by step in the debugger.
2.Click the following line with the mouse:
IF HExecuteQuery(QRY_QuantityOrdered) THEN
3.Press the F6 key (or click the "Run until cursor" button found in the ribbon).
4.The arrow indicating the line currently run moves until it reaches the line where the mouse
cursor is positioned. The code lines following are automatically run.
We are now going to add a breakpoint and to run the code until it reaches the breakpoint:
1.Click in the hatched area with the mouse, before the HModify function. A breakpoint (red
bullet) appears.
406
2.Press the F5 key (or click the "Continue" button found in the ribbon). The code is run until it
reaches the breakpoint. The arrow used to identify the current line moves until it reaches the
breakpoint.
3.Click the breakpoint to remove it.
To end this test, we will be using an "Auto-stop" expression. An "Auto-stop" expression is used
to start the debugger as soon as a condition is checked or when the value of a variable is
modified. In our example, the debugger will be started as soon as the value of the progress
bar is set to 50%:
1.In the "Debugger" pane, select the "PROGBAR_Progress" expression that was added
beforehand.
2.Click the green circle.
3.Press F5 to continue the test.
4.A message is displayed, indicating that the value of the "PROGBAR_Progress" expression
changed.
5.Validate.
6.In the "Debugger" pane, select the "PROGBAR_Progress" expression. Select "Edit the
expression" from the popup menu and enter in the expression area: "PROBGAR_Progress=
50".
7.Press the F5 key. The program continues to run. The debugger is started again when the
value of the progress bar is set to 50.
The main topics of the debugger have been presented here. To stop the test in the debugger,
click "End the test" found in the ribbon.
408
PART 6
Advanced
programming
Overview
This section presents several advanced features. You don't necessarily have to read it but it will
allow you to discover some advanced features proposed by WinDev.
The different lessons found in this section are based on examples supplied with WinDev.
WinDev proposes different types of examples:
full examples: these examples correspond to a full application that is using one or more features.
tutorial examples: these examples correspond to a small application allowing to discover a
specific feature.
unit examples: these examples correspond to a window allowing you to quickly check the use of
a function.
Practical example
To simplify the presentation of the different features, we will be using unit examples or training
examples supplied with WinDev.
4.To open a project, all you have to do is click the link found in the window.
412
To open a training example from the "Wizards, Examples and components" pane:
1.Display the "Wizards, Examples and components" pane if necessary: on the "Home" pane, in
the "Environment" group, expand "Panes" and select "Wizards, Examples and components".
2.In the pane, click "Examples". The list of examples is displayed. The examples are displayed
by category.
3.In the "Training" category, select the requested example ("Text files" for example) and doubleclick its name: the corresponding project is automatically opened in the editor.
1.Display the "Wizards, Examples and components" pane if necessary: on the "Home" pane, in
the "Environment" group, expand "Panes" and select "Wizards, Examples and components".
2.In the pane, click "Examples". The list of examples is displayed. The examples are displayed
by category.
3.In the "Unit examples" category, select the requested example ("Handling text files" for
example) and double-click its name: the corresponding window is automatically opened in the
editor.
414
Overview
The errors can be automatically managed by WinDev. This feature helps you reduce the number of
code lines while centralizing the management of errors.
The use of this feature also makes the code easier to read.
Operating mode
Two operations are performed when an error is detected by a WLanguage function:
a return value of error is returned by the function (fOpen returns "-1" if the specified file was
not opened for example).
the error is detected by WLanguage (the ErrorDetected variable is set to True) and the error
details are returned by ErrorInfo.
This second operation can be managed automatically via the error management of WinDev.
Implementation
The automatic management of errors can be configured:
in the code editor: all you have to do is click the "If error: by program" link in the code editor:
Types of errors
Two types of errors can occur in WLanguage:
the "non-fatal" errors (or runtime errors): in most cases, these errors are managed in the
code and they do not stop the application. For example, opening a file that cannot be
accessed or an archive that does not exist.
the "fatal" errors (also called programming errors): in most cases, these errors are linked to
a hardware problem (insufficient disk space, loss of network connection, ...) or to major
development problems (access to a non-declared file, use of non-existing controls, ...). A
"fatal" error can also occur after a "non-fatal" error that was not processed properly. In this
case, the application will be stopped.
The mechanism for managing the errors is used to manage these two types of errors according to
different methods in order to specify behaviors adapted to the errors that occur.
To understand the different error cases, we will be using a training example supplied with
WinDev.
1.Close the current project if necessary. The home window is displayed.
2.In the home window, click "Open an example". The list of complete and training examples
supplied with WinDev is displayed.
3.Type "Error" in the search area. Only the examples containing this word are listed.
4.Select the "WD Auto Error Management" project. The project is loaded.
416
1.The following window is displayed. This window is used to check the error when an integer is
divided by 0.
418
1.The following window is displayed. This window is used to check an error on several levels
(process calling a procedure that opens an archive that does not exist).
Example
the external
files
This lesson will teach you the following concepts...
Handling text files (CSV , ...)
Handling directories
Handling XML files
Handling XLS files
420
Overview
WinDev allows you to easily handle the most common data formats:
text files (INI, CSV, ...),
XML files,
XLS files, ...
Several families of WLanguage functions can be used to read and create these files. This allows
you to easily read data generated by another software in your WinDev applications or to create
files that require a specific formatting.
Furthermore, several WLanguage functions can be used to handle the directories containing the
files.
In this chapter, we will focus on:
Text files (text files, INI files and CSV files)
XML files
XLS files
managing directories
Open the "Text files" training example and run the test of the corresponding project.
This project groups the different operations that can be performed on the external files with
WinDev.
Handling directories
Several WLanguage functions are used to handle the directories and their files.
Practical example
Open (if necessary) the "Text files" training example and run the test of the corresponding
project. Click the "Managing directories" tab.
This project groups the different operations that can be performed on the disks and
directories:
create a directory
find out the current directory
check the existence of a directory
return the list of directories
copy a directory
delete a directory
...
See the online help (keyword: "External file") for more details.
422
Example
XML is used to structure a document containing data. A HFSQL data file containing several items
and records can be exported to an XML file for example (XML* functions).
See the "XML" training example (supplied with WinDev) for more details. This
example is accessible from the "Wizards, Examples and Components" pane of
WinDev.
WinDev supports:
the files in XML format via a native access supplied with WinDev. See the online help for
more details.
the export to XML (TableToXML, TextToXML, HExportXML)
the import of XML data (HImportXML)
the use of an XML document via the advanced XMLDocument type and via the WLanguage
functions starting with XML.
The XML file can also be handled in the code editor directly. To do so:
1.Drop the XML file from the file explorer to the project explorer, "XML and XSD descriptions"
folder.
2.Drop the XML file from the project explorer to the code editor. The xmlDocument variable is
automatically created as follows:
<Variable name> is xmlDocument, description = <Document name>
3.You now have the ability to access the nodes of the variable by their names. These names
are automatically proposed by the mechanism for automatic completion of the code editor.
Practical example
Open the "Reading and writing in XML format" unit example and run the test of the
corresponding window. This window is used to:
create an XML file. This file is created by the XML functions.
Notes
To check the use of xlsXXX functions, open the "Excel functions" unit example and run the test
of the corresponding window. This window is used to:
import data coming from an Excel worksheet.
export the data from a Table control to Excel.
Go back to the editor and study the code of the different buttons.
424
To check the use of advanced variables, open the "XLS class" training example:
1.Display the "Wizards, Examples and components": on the "Home" pane, in the "Environment"
group, expand "Panes" and select "Wizards, examples and components".
2.In the pane, click "Examples". The list of examples is displayed. The examples are displayed
by category.
3.In the "Training examples" category, select the "XLS classes" example and double-click its
name: the corresponding project is automatically opened in the editor.
4.Run the test of the project.
Notes
5.Go back to the editor and study the code of the different buttons.
We won't go into details about all the features proposed by the XLS functions and
the advanced types. See the online help for more details.
compilation
426
Overview
The dynamic compilation is used to compile a code at any time in the application. A common
example? Your application contains a formula that can be configured. To change the parameters,
there is no need to supply the executable again: the modification of a text file is sufficient.
Example
The dynamic compilation will be presented via the training example named "WD Dynamic
compilation".
The "WD Dynamic compilation" project explains how to dynamically compile a WLanguage
code (stored in string format), run the procedure that was generated dynamically and process
the possible runtime errors.
1.Open the training example "Dynamic compilation".
2.Run the test of the example.
Let's go back to the code editor and study the code of the first "Run" button.
1.Display the code of the "Run" button (right click on the button, "Code" option). This code calls
the CompileDynamicCode procedure.
2.Position the mouse cursor on the name of the procedure and press [F2]. The code of the
procedure is automatically displayed in the code editor.
The code of this procedure can be divided into several sections:
1.Initializing the variables.
2.Compiling the code.
sCompilationResult = Compile(DYNAMIC_PROCEDURE, ...
EDT_COMPIL_CODE)
4.Press CTRL + F2. The click code of the "Run" button re-appears in the code editor.
In the rest of this code, you can see that the function that is dynamically compiled is
run by Execute.
428
event
Introduction
Each action performed by Windows corresponds to a Windows event. Different types of events can
occur, for example:
A window is hovered by the mouse,
The system is stopped,
A dialog box is displayed,
A software error,
Etc.
When these events occur, they can be intercepted in order to prepare or to run a specific process.
WinDev proposes an automatic management of the most commonly used events. For example,
the following events are proposed for an edit control:
Initializing the control,
Entry in the control,
Modifying the control,
Exit from the control.
To manage additional events, you can:
use the optional processes proposed by WinDev.
use the Windows events.
Practical example
The management of events will be presented via the unit example named "Event function".
1.Display the processes linked to the List Box control found in the window of the unit example:
Select the List Box control.
Press the F2 key.
The code editor is displayed.
2.A toolbar is available at the bottom of the code window:
This toolbar presents the main available optional processes. To identify the processes, hover
the different icons.
430
3.To add a process, click the corresponding icon. The corresponding process is automatically
displayed in the code editor.
4.To display the full list of available optional processes, all you have to do is click "...".
5.To add a process, all you have to do is check the corresponding box and validate this
window. Add the "Key Pressed" event for example.
Windows events
Notes
To manage more "specific" events, you have the ability to use Event. This WLanguage function is
used to associate a WLanguage procedure to a Windows event.
To use Event, you must be familiar with the Windows programming, especially the
Windows events.
See the online help (keyword: "Value of constants for the Windows 32-bit API") to find out the
entire list of Windows events.
Run the test of the "WIN_Event_Function" window. This window detects whether the list is
handled by the mouse or by the keyboard.
1.Click the List Box control with the mouse.
2.Use the mouse or the keyboard to move the selection bar.
3.A message is displayed, specifying whether the mouse or the keyboard was used.
This code line is used to include the content of the WINCONST.WL file in the application
code via the EXTERN keyword. This file contains the declaration and values of the Windows
constants. During the compilation, the entire code found in the Winconst.WL file will be
automatically included in the application code.
Then, all the supported events are declared:
// Events on the LIST_Month control
// Keyboard key down
Event("MouseOrKeyboard",LIST_Month..FullName,WM_KEYDOWN)
// Left mouse click
Event("MouseOrKeyboard",LIST_Month..FullName,WM_LBUTTONDOWN)
432
The MouseOrKeyboard procedure is called whenever the keyboard is used on the list
(corresponding Windows event: WM_KEYDOWN) or whenever the left mouse click is used
(corresponding Windows event: WM_LBUTTONDOWN).
4.Display the code of the procedure:
Position the mouse cursor on "MouseOrKeyboard".
Press the F2 key
5.The code of the procedure is quite simple:
If the keyboard is used, the caption displayed below the List Box control contains "Selection
with the keyboard".
If the mouse is used, the caption displayed below the List Box control contains "Selection
with the mouse".
PROCEDURE MouseOrKeyboard()
// The _EVE.wMessage variable contains the message number
SWITCH _EVE.wMessage
// It's the keyboard
CASE WM_KEYDOWN
// Message indicating that the keyboard was used
STC_SelectionType = "Selection with the keyboard"
STC_SelectionType..Color = LightRed
// It's the mouse
CASE WM_LBUTTONDOWN
// Message indicating that the mouse was used
STC_SelectionType = "Selection with the mouse"
STC_SelectionType..Color = LightBlue
END
threads
434
Definition
The threads are used to run a code (or processes) in parallel of the main application. Therefore,
several long processes can be run in background task without locking the main application (also
called "Main thread").
The threads replace some types of timers.
In most cases, a secondary thread is used to detect an event such as a user action, an incoming
email, a phone call,...
Examples for using the threads:
Retrieving emails in background task while typing a new email for example.
Application for communication: management of phone calls, communications via socket, ...
WinDev allows you to:
manage the threads (Thread* functions).
use "signals" in order to synchronize several threads (Event* functions).
use the threads with "semaphores" in order to manage the access to the resources shared
by different threads (Semaphore* functions).
Example
Example
WinDev is supplied with an example that presents the interest and the use of
threads: "Thread Pool" (this training example is accessible from the "Wizards,
Examples and Components" pane of WinDev).
sockets
436
Overview
WinDev proposes several functions used to perform an advanced management of sockets.
A socket is a communication resource used by the applications to communicate between
computers regardless of the network type.
This communication mode is used to establish a communication between two applications found
on different computers (connected by Internet or on the same local network) or on the same
computer.
Example
To read and write on the socket, the WinDev server application must use SocketRead and
SocketWrite.
Caution: To perform a read operation, a write operation must have been performed beforehand.
For example:
1.The client computer writes into the socket: it sends a request to the server.
2.The server performs a read operation on the socket in a thread. As soon as a message is
received, the message is processed by the server.
3.If a response to the message is required, the server identifies the client computer
(SocketClientInfo) and sends a response to it.
Closing the socket
To end the communication, the server can close the socket with SocketClose.
Note: the socket can also be closed by the client computer.
Client application
A client application of a socket server connects to a standard server in order to exchange
information via a socket.
Example: A client WinDev application can connect to a standard news server on Internet.
The steps for creating a client application are as follows:
1.Connecting to the server
2.Exchanging data
3.Ending the communication
Connecting to the server
To connect to a server socket, all you have to do is use SocketConnect. This function is used to
perform a request for connecting to the server.
The socket is identified by its port and by its address.
Exchanging data
When two computers are using the same socket, a communication stream is established between
these two computers. These two computers can read and write character strings on the socket.
Note: To avoid locking the applications, the incoming messages are managed by a specific thread
in most cases.
To read and write on the socket, the WinDev client application must use SocketRead and
SocketWrite.
Ending the communication
To end the communication, all you have to do is close the socket from the client computer with
SocketClose.
Note: you also have the ability to end the communication from the server.
438
Practical example
The programming of sockets will be presented via the unit example named "Using sockets".
Test of the example
computer A. Computer A is the Server application and computer B is the Client application.
1.On computer A, click the "Create" button to create the socket.
2.The computer B can connect to the socket created by computer A. All you have to do is click
the "Connect" button (in Computer B section).
3.Computer B sends a message to computer A:
Type message to send in the "Sentence to send to computer A" area.
Click the "Send" button found in the "Computer B" area.
4.To retrieve the message on computer A, click the "Retrieve" button found in the "Computer
A" area.
5.Click the "Disconnect" buttons to disconnect the two computers.
Let's study the code of the different buttons that have been used.
First of all, we are going to study the processes performed by the socket server (computer A).
1.Display the code of the "Create" button found in the "Computer A" area:
Select the "Create" button.
Press F2 to display the processes.
2.In the "Click on" process, you will notice the presence of SocketCreate that is used to create
the socket. Close the code editor.
3.Display the code of the "Retrieve" button found in the "Computer A" area:
Select the "Retrieve" button.
Press F2 to display the processes.
4.The following code is used in the "Click on" process:
EDT_SentenceReceivedFromComputerB = SocketRead("ComputerA",
False, 2000)
IF EDT_SentenceReceivedFromComputerB <> "" THEN
Info("Message received from IP address # " + ...
SocketClientInfo("ComputerA", SocketAddress))
END
You will notice the presence of SocketRead that is used to read the socket that was created
beforehand. The message read is immediately displayed in the "EDT_SentenceReceivedFromComputerB" control. Close the code editor.
1.Display the code of the "Connect" button found in the "Computer B" area:
Select the "Connect" button.
Press F2 to display the processes.
2.In the "Click on" process, you will notice the presence of SocketConnect that is used to
connect to the socket created by computer A. Close the code editor.
3.Display the code of the "Send" button found in the "Computer B" area:
Select the "Send" button.
Press F2 to display the processes.
4.The following code is used in the "Click on" process:
IF NOT SocketWrite("ForComputerA", ...
EDT_SentenceToSendToComputerA) ALORS
Error(ErrorInfo(errMessage))
RETURN
END
You will notice the presence of SocketWrite that is used to send a message onto the socket
to which computer B is connected. Close the code editor.
Note: In this lesson, we have seen a "simple" communication between a server and a client
computer: the client sends messages and the server processes the messages. You have the ability
to create more complex applications.
You have the ability to establish a communication between two applications, both client and
server. In this case, the management of threads becomes very important to manage the send
operations and the responses.
440
Overview
The FTP (File Transfer Protocol) is a standard protocol used to transfer files from a computer to
another one. One of the computers must be an FTP server.
Several WLanguage commands allow you to transfer files by using this protocol with a server.
These programming functions start with "FTP".
WinDev only proposes the "client" functions for FTP. A standard FTP server is required.
The programming of sockets will be presented via the unit example named "FTP functions".
Open the "FTP functions" unit example. This example presents the main features that can be
used on an FTP server.
442
Note: You also have the ability to specify the port number for connecting to the FTP server ("21" by
default) as well as the connection mode ("True" for a "passive" connection, "False" for an "active"
connection). See the online help (keyword: "FTP, Functions") for more details.
Sending a file
To send a file to an FTP server, all you have to do is use FTPSend.
Let's see an example of code that can be used:
Caution!
Pay great attention to the case (uppercase/lowercase characters) for the name
of directories on the server. Indeed, some FTP servers operate under UNIX and
are "case sensitive", which means that the case is taken into account for the
name of files and directories.
For example, a directory named "MyDirectory" is found on the FTP server. If you
try to access "mydirectory", an error such as "Path not found" will be returned by
the FTP server because the case is incorrect.
FTPListFile(gnConnectionID,"*.*",...
"CallBackFTPListFile", ftpFile+ftpDirectory)
// Check the execution of the function
IF ErrorOccurred THEN
Error("Error while browsing the files found on the FTP
server",ErrorInfo())
RETURN
END
3.In the example, the procedure called is used to display the files found in a trace window.
PROCEDURE CallBackFTPListFile(sFileName,nFileSize
<useful>,sAttribute,sModifDate <useful>,sModifTime <useful>)
// Is it a file or a directory
IF sAttribute = "D" THEN
// Directory or sub-directory
Trace("Directory: "+sFileName)
ELSE
// File
Trace("File: "+sFileName)
END
// Continue to browse the files
RESULT True
444
Retrieving a file
To retrieve a file from an FTP server, all you have to do is use FTPGet.
Let's see an example of code that can be used:
// When connecting to the server with FTPConnect, we have
// retrieved the connection number in the gnConnectionID variable
// Download the "/Document/File.DOC" file found
// on the FTP server to the "D:\Temp" directory on
// the current computer
bResult is boolean = FTPGet(gnConnectionID, ...
"/Document/File.DOC","D:\Temp")
IF YesNo(No, ...
"Do you want to close the connection to the FTP server?")=Yes
THEN
// Disconnection from the FTP server
FTPDisconnect(gnConnectionID)
IF ErrorOccurred THEN
// Error while closing the connection
Error("Unable to close the FTP connection", ErrorInfo())
RETURN
END
// The connection is ended
Info("The connection with the FTP server is ended")
END
Other FTP functions are available but we won't go into details about them in this tutorial. They are
mainly used to:
create, delete, modify directories on the FTP server,
create, delete, modify files on the FTP server,
retrieve information about a directory and/or a file,
...
See the online help (keyword: "FTP, Functions") for more details.
446
Concepts
The Object-Oriented Programming (OOP) is designed for better code reusability. The programs
developed in OOP are structured: they include modules, each one of these modules being used
to manage a feature of the software. These modules can easily be re-used in other software. They
group a set of procedures (called methods) and they encapsulate the data structure on which the
methods will act.
To use the object-oriented programming, you must declare the classes, the members and the
associated methods.
The classes
A class contains the description of a data structure (the members) and the procedures (methods)
that handle the members.
Therefore, a class defines a type of data and its behavior.
The objects
A class is used to create objects. Each created object owns the members described in its class
and it can be handled via the methods of its class. An object is defined as an instance of the class.
When the class is declared, all you have to do is associate an object with a class in order for the
object to be handled by all the methods of this class.
The members
A member is a data (or parameter) of the object.
The methods
A method is used to act on the object, to modify its members for example.
A method is a procedure. Its operating mode is similar to the one of the standard procedures of
WLanguage.
Concept of inheritance
The inheritance is used to include the characteristics of an existing class (base class) in a new
class (derived class). The inheritance allows you to create a new type of data from a known type in
order to add features to it or to modify its behavior. Therefore, the base class will not be modified.
A class can inherit from a class: it becomes a sub-class of this class.
A derived class inherits from the members and methods of its parent class (which can, itself, be
a sub-class of another parent class), in addition to its own members and methods (and also from
the members and methods of the first parent class in case of multiple inheritance). There is no
need to duplicate the members and methods of the parent classes.
448
Simple example
To illustrate these concepts, we will be using the "Simple OOP" training example.
1.Open the "Simple OOP" training example.
2.Run the test of this example.
3.Click the different buttons corresponding to the animals in order to add them.
4.Stop the example test to go back to the editor.
Note: We won't go into details about the syntax of OOP but we will present a simple example of an
object-oriented program. See the online help (keyword: "OOP, Class") and the programming guide
of WinDev for more details.
Declaring a class
WinDev allows you to easily declare the classes from the project explorer. To create a class:
4.The code of the class is displayed in the code editor. The declaration code of the class is as
follows:
cSavanna is Class
PROTECTED
// Name of the Image control used for the drawing
m_sNameImageControlForDrawing is string
// List of savanna animals
m_arrTheAnimals is array of cAnimal dynamic
END
WinDev allows you to easily declare the methods from the project explorer. To create a
method:
1.Right-click your class found in the project explorer.
2.Select "New method" from the popup menu.
3.In the window that is displayed, specify the name of the method and validate.
4.Enter the code of the method in the code editor.
450
UML diagram
The "Simple OOP" example is associated with an UML diagram.
3.The different classes used by the "WD Simple OOP" project are found in this diagram.
452
Notes
We won't go into details about the use of UML language with WinDev. See the online help (keyword:
"UML") for more details.
454
Conclusion
Conclusion
The tutorial is over now!
This course has discussed a wide range of topics, but not all the features of WinDev, far from it!
You are now familiar with the main concepts.
You can also explore the examples supplied with WinDev: some are simple and only address one
topic, while others are more complex. These examples illustrate the different aspects of WinDev.
Reading the source code is also a good way to learn.
It would take too much room to discuss all the available topics (there are hundreds, even
thousands!). WinDev proposes several other features not presented in this tutorial:
HTTP and telephony functions
creation of skin templates...
nested reports, queries with parameters...
calls to DLL, external languages...
Conclusion 455