Creating a SiMPLE Program
that Runs in a Window
The default display mode for SiMPLE is "Full Screen". This means that you have control over every pixel that your computer is capable of displaying. For example, if you were to run the following short Ultra-SiMPLE program:
| Program Listing |
you would see a dynamic image that fills your entire screen:
But there may be times when you don't need this much control over your screen and you would prefer to use only part of your display, leaving the rest of it for other programs to use.
SiMPLE (Version 4.1 or later) allows you to very easily create not only Full Screen programs, but also programs that run in a window. To make your program run in a window, just add a left square bracket and a right square bracket to the "Ultra-SiMPLE" compiler directive at the beginning of your program listing:
Ultra-SiMPLE []
(As a mental crutch, you can think of the two "[]" characters as forming a little "window".) Making this change in the first line of our previous source listing causes the program to run in a window on the desktop:
Notice that the default message in the window's title bar is "SiMPLE". To display a different message, just insert that message between the "[]" characters. For example:
Ultra-SiMPLE [This is a cool spiral program!]
The default size of the window is 640x480 (the same dimensions as the Pro-SiMPLE graphics screen). To specify a different size window, just indicate that size anywhere following the right square bracket character.
| Program Listing |
[Note: When specifying the window's size, the "x" must be lower case.
If you specify
only a single number (without an "x")
for the size, the result will be a square window.]
In the "Ultra-SiMPLE" compiler directive, any spaces that are not between the "[]" characters are completely ignored.
Writing the Program
Writing a program that runs in a window is not much different from writing a program that runs in Full Screen mode. However, there is at least one important difference that you must be aware of:
In Full Screen mode, any output that your program sends to the display screen goes directly there. (I.e., it appears on the screen immediately.) But, when running in a window, all such visual output is held in a "buffer" until your program requests the window to be "updated".Fortunately, all of the window's visual updating is handled for you automatically whenever your program invokes any of the "wait" tasks or functions (such as "Waitkey", "Delay", "Pause", etc.). Therefore, if you want to keep your display "up to date", you must always remember to invoke at least one such task/function in any loops that your program might be using. (If your program is running a "tight loop" and needs to update the window as quickly as possibly, just use either a "Wait(0)" or a "Delay(0)" somewhere in the loop.)
If you are using SiMPLE's "Drag & Drop" mode to run your program, you may notice that the black "launcher" window is still visible on the screen, even after your window appears.
Feel free to minimize it (or even close it) if you want to. (The launcher is doing nothing but waiting for your program to finish.) If you later use the executable (.EXE) file to run your program, the black launcher window will not even appear at all.
To see more examples of programs that run in a window, look at some of the listings in the "SiMPLE Samples" folder. (Also see: Taking Control of Quitting.)
(Many thanks to James Hart for his help and suggestions.)
[
Webmaster |
FAQ's |
Home Page |
Contact Us ]