Tuto WINDEV 25

Part 2: The WLanguage basics 61 ▶ The "Close" Button control must be invisible when the window is opened. This information corresponds to its "initial status". We are going to modify this status in the description window of control: 1. Select the "Close" Button control. 2. Display the popup menu of control and select "Description". 3.  In the "UI" tab, modify the initial state of the control by clicking on "Visible". This option is now unchecked. 4. Validate the control description window. 5.  The "Close" Button control is still visible in the editor. Its status was changed in execution only. 6. Save the modifications by clicking among the quick access buttons (on the left of the ribbon) or by pressing Ctrl + S. Conditional IF statement In our example, a click on the check box must trigger the display of Close button. ▶ We will enter the WLanguage code associated with the Check Box control: 1. Select the Check Box control. 2. Press F2. 3. Write the following WLanguage code in the event "Whenever modifying CBOX_NoName1": IF CBOX_NoName1 = True THEN BTN_Close..Visible = True ELSE BTN_Close..Visible = False END Let’s take a look at this WLanguage code: • CBOX_NoName1 and BTN_Close respectively correspond to the names of Check Box and Button controls. Tip To handle the current control in one of the events associated with it, you can use the keyword MySelf. In our example, you also have the ability to write: IF MySelf = True THEN • The Check Box control is a 2-state control: checked/unchecked. It corresponds in programming to a Boolean variable. If the control is checked, its value is set to True ; if the control is unchecked, its value is set to False. • This code tests the value of the Check Box control. • If Check Box control is checked, Button control BTN_Close becomes visible using ..Visible . • If the Check Box control is unchecked, the Button control BTN_Close becomes invisible. 4. Close the code window (click X at the top right corner of code editor).

RkJQdWJsaXNoZXIy NDQ0OA==