Xojo has many good code examples,and over my many years of programming, here are some free mini-programs that have been created to help with a concept or theory. Feel free to download and use this free material as you see fit.


Transparent Background


This example writes a string of text and makes the background transparent. Here is the link to download the Transparent Background. The size and colour of the text can be changed and code is in the Canvas2 Paint event. The text can be changed at runtime or can remain static. Them important part was to make it so that the background colour surrounding the text remained transparent. 



Validate Textfield Numerical Data

TFValidateTextfield validate makes only numbers can be allowed in the textfield. If the user tries to type a letter, then the data will be ignored. This may be helpful for formatting telephone number, spreadsheet data, or preventing problems where letters may cause unintended errors. Download here: TFValidate.





Thread On/Off

ThreadScreenGrabWorking with threads has a small need-to-know part which requires the thread to use the App.YieldToNextThread command to allow updating, otherwise the thread uses all of the time to perform work and not allow updating by any of the controls. Here is the example to be downloaded: ThreadOnOff. Start the program and press the Start Threat 1 pushbutton and the counter begins counting. Press the Kill Thread button and the thread is permanently stopped. Pressing Suspend Thread will stop the thread and keep track of where it stopped. Resume Thread 1 continues running where last suspended. Sleep thread will stop the thread from running for 1 second (1000 milliseconds) and will continue from where it left off. 






Text To Speech (Windows OS)

TextToSpeech This example has the ability to show available voices on Windows OS and read text. The left pushbutton says the words "Hello World" and make sure your speakers are turned up. The second pushbutton called 'Get Voices' speaks the words 'Hello World' and also has options for the rate of speech, volume, and shows all of the voices which are installed on the Windows OS computer. The link for the Xojo program is here: Text-To-Speech(tts.zip). Here is how I installed one of the many additional voices on Windows 10:

1) go to Settings>Time & Language>Region and Language>+ Add a language 2) Choose a language (I chose Italian) 3) Click on the Itanliano (Italia) Language Pack and select Options 4) Select Speech (Download) Note: Not all languages have a speech voice addon. Windows will say something like 'we are adding a new feature' 5) Wait for the program to download and install (about 2 minutes on my machine) 6) Go to Settings>Speech and select 'Microsoft Elsa Desktop - Italian (Italy)' and press 'Preview Voice' 7) Run the Xojo program and it should be listed with the for-next loop you created

Some languages, such as Russian, require Windows to be restarted to install the language.

AddHandler Desktop

AddHandlerThis example uses the handling of an event to a delegate method for Windows. A timer action event can be created without creating a timer subclass. An open event creates a new timer instance and the AddHandler action event is added and the TimerAction method fires every 1.0 seconds (1000 milliseconds). The TimerAction method updates the ProgressBar every second.

The Windows example can be downloaded here: Windows AddHandler. This example was created with Xojo 2016 r4.1 on Windows 10 and works in both 32-bit and 64-bit modes.



Dynamic Window

DynWindowPicA dynamic window with dynamic content can be created with this simple example. Two container controls are created for the dynamic label (ContainerControlLabel) and textfield (ContainerControlTF). Pressing the Create Window pushbutton adds two labels and one textfield in the new window. When the window closes the Close event fires in the ContainerControlTF and sends the data to the Textfield in Window1.

 The example was created in Xojo 2016 r4.1 on Windows 10 and can be downloaded by clicking on the following link Dynamic Window.