Tuto WINDEV 25
Part 7: Advanced programming 411 Example: Detect the click on a List Box control ▶ 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. 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 procedure MouseOrKeyboard 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).
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==