quarta-feira, 2 de setembro de 2020

DICAS 3062 -WINDEV TUTORIAL 85 -Licao 7.5-08-09-2020 11hrs-PROGRAMACAO AVANCADA EVENTOS WINDOWS







https://youtu.be/K6hmuVWTtKs


Bom Dia/Boa Tarde/Boa Noite

Esse Ao Vivo vai estrear as 11:00 do dia 08/09/2020 

DICAS 3062 -WINDEV TUTORIAL 85 -Licao 7.5-08-09-2020 11hrs-PROGRAMACAO AVANCADA EVENTOS WINDOWS
Tutoriel WINDEV : Leçon 7.5. Programmation avancée - Evénement Windows


ASSUNTOS

PROGRAMANDO OS EVENTOS DO WINDOWS 
INTRODUCAO
EVENTOS SOPCIONAIS PROPOSTOS POR WINDEV
EXEMPLO PRATICO PCSOFT
   The Event function
EXEMPLO ALTERADO E COLOCADO NO REPOSITORIO WINDEV   
   FUNCOES_EVENTOS_AMARILDO
      COM TRADUCAO PORTUGUES/INGLES/FRANCES/ESPANHOL
MOSTRANDO O EXEMPLO FUNCIONANDO
EXPLICANDO O CODIGO DO EVENTO
  
Video original da Franca

https://youtu.be/OydGgpZxa-8


Playlist Windev Tutorial Amarildo


DICAS 2979 - WINDEV TUTORIAL 2 - 1.2- CRIAR JANELA E INSERIR TEXTO E EXIBIR
DICAS 2980 - WINDEV TUTORIAL 3 - 2.1- VARIAVEIS PARTE 1
DICAS 2981 - WINDEV TUTORIAL 4 - 2.2- VARIAVEIS ESCOPO - PARTE 2
DICAS 2982 - WINDEV TUTORIAL 5 - 2.1- VARIAVEIS OPERADORES PARTE 3
DICAS 2983 - WINDEV TUTORIAL 6 - 2.1.D - VARIAVEIS STRINGS PARTE 4
DICAS 2984 - WINDEV TUTORIAL 7 - 2.1.E - VARIAVEIS ARRAYS PARTE 5
DICAS 2985 - WINDEV TUTORIAL 8 - 2.2.A - CONDICOES IF-SWITCH PARTE 1
DICAS 2986 - WINDEV TUTORIAL 9 - 2.2.B - CONDICOES PARTE 2
DICAS 2987 - WINDEV TUTORIAL 10 - 2.3.A - LOOP PARTE 1
DICAS 2988 - WINDEV TUTORIAL 11 - 2.3.B - LOOP EXEMPLOS PARTE 2
DICAS 2989 - WINDEV TUTORIAL 12 - Lesson 2.4. The procedures - PARTE 1
DICAS 2990 - WINDEV TUTORIAL 13 - Leçon 2.4.b. Procedures Parametros - PARTE 2
DICAS 2991 - WINDEV TUTORIAL 14 - PROCEDURES REFERENCIA - PARTE 3
DICAS 2992 - WINDEV TUTORIAL 15 - PROCEDURES OPCIONAIS OU OBRIGATORIAS - PARTE 4
DICAS 2993 - WINDEV TUTORIAL 16 - PROCEDURES EXEMPLOS - PARTE 5
DICAS 2994 - WINDEV TUTORIAL 17 - PERGUNTAS E RESPOSTA - PARTE 1
DICAS 2995 - WINDEV TUTORIAL 18 - PERGUNTAS E RESPOSTA - PARTE 2
DICAS 2996 - WINDEV TUTORIAL 19 - WINDEV E OS BANCOS DE DADOS
DICAS 2997 - WINDEV TUTORIAL 20 - PROJETO E ANALISE - CRIACAO
DICAS 2998 - WINDEV TUTORIAL 21 - PROJETO E ANALISE - ARQUIVOS DADOS CLIENTE - PARTE 2
DICAS 2999 - WINDEV TUTORIAL 22 - PROJETO E ANALISE - ARQUIVOS DADOS CRIACAO ARQUIVO PEDIDO - PARTE 3
DICAS 3000 - WINDEV TUTORIAL 23 - PROJETO E ANALISE - IMPORTANDO CVS-ARQUIVO TEXTO - PARTE 4
DICAS 3001 - WINDEV TUTORIAL 24 - PROJETO E ANALISE - IMPORTANDO ARQUIVO PRODUTO - PARTE 5
DICAS 3002 - WINDEV TUTORIAL 25 - PROJETO E ANALISE - LINK - PARTE 6
DICAS 3003 - WINDEV TUTORIAL 26 - RAD COMPLETO
DICAS 3004 - WINDEV TUTORIAL 27 - VISAO GERAL
DICAS 3005 - WINDEV TUTORIAL 28 - Adicionar e Modificar Janelas PRODUTOS - PARTE A
DICAS 3006 - WINDEV TUTORIAL 29 - Adicionar e Modificar Janelas PRODUTOS Formulario - PARTE B
DICAS 3007 - WINDEV TUTORIAL 30 - Adicionar e Modificar Janelas PRODUTOS ALINHAR CAMPOS - PARTE C


========================================

PROCEDURE MyWindow()

// 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
OTHER CASE
END
STC_SelectionType..Color = LightRed
END
STC_SelectionType = sTipo_mouse_ou_teclado

=========================
// INITIALIZING LIST_MONTH
// Adiciona os meses
// Adds the months
// Ajoute les mois
// Suma los meses
LIST_Month.DeleteAll()
FOR i = 1 TO 12
ListAdd(LIST_Month, MonthNumberInAlpha(i))
END

==================
//SELECTION A ROW OF LIST_MONTH
// Adiciona os meses
// Displays the selected month
// Ajoute les mois
// Suma los meses

EDT_SelectedMonth = LIST_Month[LIST_Month]
==========



























Lesson 7.5. Windows event
This lesson will teach you the following concepts
  • Programming the Windows events.
Lesson duration

Estimated time: 10 mn
Previous LessonTable of contentsNext Lesson
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 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:
    1. 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.
    2. Click the "Add other events..." link:
      Link 'Add other events'
    3. The complete list of available optional events is displayed:
      List of optional events
    4. 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.

To find out the non-exhaustive list of Windows events, see Value of constants for the Windows 32-bit API.

Example : Detect the click on a list

  • Run the test of "WIN_Event_Function" window. This window detects if the list is manipulated with the mouse or with the keyboard.
    1. Click the List Box control with the mouse.
    2. Use the mouse to move the selection bar.
    3. A message is displayed, specifying whether the mouse or the keyboard was used.
      Window test
    4. Stop the test and go back to the editor.
  • Let's study the code used:
    1. Click in the window.
    2. Display the window events (press F2).
    3. 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).
    4. Display the WLanguage code of the procedure:
      • Position the mouse cursor on "MouseOrKeyboard".
      • Press F2.
    5. 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




Nenhum comentário:

Postar um comentário

Teste

Teste
teste