The core PROLOG contains:
IMPORT "xgr" - declares GraphicsDesigner types, functions, constants.
IMPORT "xui" - declares GuiDesigner types, functions, constants.
declarations for functions GuiDesigner automatically creates for you.
Entry() contains three sections:
1. Initialize GuiDesigner, GuiDesigner variables, and your program.
Xui() ' initialize GuiDesigner
InitGui() ' initialize messages, etc.
InitProgram() ' initialize your program
2. Create and display the main window and any others you design.
CreateWindows() ' create your program's windows
InitWindows() ' initialize windows if needed
3. Process messages in the message loop.
DO ' the message loop ...
XgrProcessMessages ( 1 ) ' processes one message ...
LOOP UNTIL terminateProgram ' and repeat until program terminates
Entry() is your GUI program
No matter how large, sophisticated, and elaborate your GUI program is, Entry() is your program. Everything else is support for Entry(). That may seem far fetched, but consider:
Entry() initializes everything, displays your main window, then enters the message loop where it waits for a message. From then on, the message loop is the "base of operations" for your program. The message loop calls other functions to process user-generated messages as they occur, but those functions always return to the message loop when they're done. Your program spends its life in the message loop, except for occasional excursions to process a message.
the nature of GUI programs
That's how GUI programs work. Most of the time they sleep in the message loop at the bottom of the entry function, waiting for activity. When the user presses a keyboard key or mouse button or otherwise generates a message, the message loop wakes up and calls the function that knows how to process the message. After the function responds to the user action, it returns to the message loop where the program again falls asleep until the user generates another message.
1. Sleep in the message loop until a message arrives. When it does...
2. Call the function that knows how to process the message.
3. Go to step 1.
The basic structure of GuiDesigner programs is amazingly simple. What's more amazing is that this basic structure is flexible enough for any kind of program.
Hey! GUI programs don't have to be difficult after all.