Simple graphics programs don't need messages or the message queue, and can simpy ignore them. Only programs that need to detect keyboard and mouse events in graphics windows need messages.
Programs that need to monitor keyboard and/or mouse activities in graphics windows have to recognize keyboard and/or mouse messages, but can discard others.
XgrPeekMessage() and XgrDeleteMessages() are all they need to extract a message from the queue, take whatever action is appropriate, then remove the message from the queue so the next one becomes accessible. In this method, only your own program calls functions in your program.
When a program controls several windows, it's sometimes appropriate to write separate functions for windows that have special functionality that's awkward to handle in a single window function.
Whenever a program is ready to process a message, it can call XgrProcessMessages() and let it call the window function assigned to the window.
Sophisticated programs, like those with graphical user interfaces often send, receive, and process a wide variety of messages. Often they have a wide variety of special purpose grids, supported by one grid function per grid type.
The GuiDesigner programmer guide contains additional discussion of messages and the message queue, since message passing is a central part of its architecture. Furthermore, GuiDesigner contains additional message functions that work together to support sophisticated message passing for any program, whether they perform graphics or not.