// O comando EXTERN é usado para incluir automaticamente o arquivo WINCONST.WL
// The EXTERN command is used to automatically include the WINCONST.WL file
// O comando EXTERN é usado para incluir automaticamente o arquivo WINCONST.WL...
// El comando EXTERN se usa para incluir automáticamente el archivo WINCONST.WL
// Este arquivo contém o valor das constantes do Windows
// This file contains the value of the Windows constants
// Ce fichier contient la valeur des constantes Windows
// Este archivo contiene el valor de las constantes de Windows
EXTERN "WINCONST.WL"
// Eventos no controle LIST_Month
// Events on the LIST_Month control
// Evénements sur le contrôle LIST_Month
// Eventos en el control LIST_Month
// O procedimento MouseOrKeyboard é chamado sempre que o teclado ou mose é usado no controle List Box
// The MouseOrKeyboard procedure is called whenever the keyboard or mose is used in the List Box control
// El procedimiento MouseOrKeyboard se llama siempre que se usa el teclado o mose en el control List Box
// La procédure MouseOrKeyboard est appelée chaque fois que le clavier ou le mose est utilisé dans le contrôle List Box
Event("MouseOrKeyboard", LIST_Month..FullName, WM_KEYDOWN) // Keyboard key down
Event("MouseOrKeyboard", LIST_Month..FullName, WM_LBUTTONDOWN) // Left mouse click
=================================
PROCEDURE MouseOrKeyboard()
// variavel para colocar a mensagem se é teclado ou mouse // variable to put the message if it is keyboard or mouse
// variable pour mettre le message s'il s'agit d'un clavier ou d'une souris // variable para poner el mensaje si es teclado o mouse
sTipo_mouse_ou_teclado is string=""
// A variável _EVE.wMessage contém o número da mensagem // The _EVE.wMessage variable contains the message number
// La variable _EVE.wMessage contient le numéro du message // La variable _EVE.wMessage contiene el número de mensaje
SWITCH _EVE.wMessage
CASE WM_KEYDOWN
// Mensagem indicando que o teclado é usado // Message indicating that the keyboard is used // Message indiquant que le clavier est utilisé // Mensaje que indica que se usa el teclado
SWITCH Nation()
CASE 15
sTipo_mouse_ou_teclado="bra Seleção com o teclado" //Nation(nationBrazilianPortuguese) // 15
CASE 3
sTipo_mouse_ou_teclado="inlg Selection with the keyboard" //Nation(nationEnglish) // 3
CASE 5
sTipo_mouse_ou_teclado="fre Sélection avec le clavier" // Nation(nationFrench) // 5
CASE 7
sTipo_mouse_ou_teclado="esp Selección con el teclado" //Nation(nationSpanish) // 7
OTHER CASE
END
STC_SelectionType..Color= LightBlue
CASE WM_LBUTTONDOWN
// Mensagem indicando que o mouse é usado // Message indicating that the mouse is used // Message indiquant que la souris est utilisée // Mensaje que indica que se usa el mouse
SWITCH Nation()
CASE 15
sTipo_mouse_ou_teclado="Seleção com o mouse" //Nation(nationBrazilianPortuguese) // 15
CASE 3
sTipo_mouse_ou_teclado="Selection with the mouse" //Nation(nationEnglish) // 3
CASE 5
sTipo_mouse_ou_teclado="Sélection avec le mouse" // Nation(nationFrench) // 5
CASE 7
sTipo_mouse_ou_teclado="Selección con el mouse" //Nation(nationSpanish) // 7
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 most common events. For example, the following events are automatically 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 events proposed by WINDEV.
use the Windows events.
Practical example
The management of events will be presented via the unit example named "The Event function".
Open the unit example named "The Event function".
Optional events proposed by WINDEV
WINDEV proposes many optional events for each element (window, control, etc.).
To add an optional event:
Display the WLanguage events associated to the List Box control in the unit example window:
Select the List Box control.
Press F2.
The code editor is displayed.
Click the "Add other events..." link:
The complete list of available optional events is displayed:
To add an event, simply check the corresponding box and validate this window. Add the "Key Pressed" event for example.
Windows events
To manage more "specific" events, you have the ability to use the WLanguage Event function. Event is used to associate a WLanguage procedure to a Windows event.
Remark
To use Event, you must be familiar with the Windows programming, especially the Windows events.
Run the test of "WIN_Event_Function" window. This window detects if the list is manipulated with the mouse or with the keyboard.
Click the List Box control with the mouse.
Use the mouse to move the selection bar.
A message is displayed, specifying whether the mouse or the keyboard was used.
Stop the test and go back to the editor.
Let's study the code used:
Click in the window.
Display the window events (press F2).
Let's study the event "Global declarations" of WIN_Event_Function.
First of all, the code line:
EXTERN "WINCONST.WL"
This code line is used to include the content of WINCONST.WL file in the application code via the EXTERN keyword. This file contains the declaration and values of Windows constants. During the compilation, the entire code found in the WINCONST.WL file will be automatically included in the application code.
Then, all supported events are declared:
// Events on LIST_Month control // Keyboard key down Event("MouseOrKeyboard", LIST_Month..FullName, WM_KEYDOWN) // Left mouse click Event("MouseOrKeyboard", LIST_Month..FullName, WM_LBUTTONDOWN)
The MouseOrKeyboard procedure is called whenever the keyboard is used on the List Box control (corresponding Windows event: WM_KEYDOWN) or whenever the left mouse click is used (corresponding Windows event: WM_LBUTTONDOWN).
Display the WLanguage code of the procedure:
Position the mouse cursor on "MouseOrKeyboard".
Press F2.
The procedure code is straightforward:
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 // Keyboard CASE WM_KEYDOWN // Message indicating that the keyboard is used STC_SelectionType = "Selection with the keyboard" STC_SelectionType..Color = LightRed
// It's the mouse CASE WM_LBUTTONDOWN // Message indicating that the mouse is used STC_SelectionType = "Selection with the mouse" STC_SelectionType..Color = LightBlue END