Issue 15: Jan 2002






Tip of the Day


My trip down the Champs-Elysées


'C'ing through the window 'pains'


Atari UK 2


Star Alliance - Battle for Earth


M: Interactive Composition




Calamus from scratch


Porthos 1.28


Put a Little Bee Under the Bonnet of your TT



'C'ing through the window 'pains'

by Steve Ollett


Back in the March 2001 issue of MyAtari, I wrote a tutorial covering the creation of menus in C, using Lattice C and WERCS.

In the meantime, there's been the birth of my daughter, extensive decorating of my house, and of course researching into window handling using C. This month I'm back with a short tutorial on how to interact with GEM windows and menus.

At the end of this article you will find a link to a ZIP archive that contains all the files you'll need to make the most of this tutorial, including the executable and source code.

So what does 'New Menu Program' do?
After double clicking the executable file,
NEW_MENU.PRG, the following screen will be displayed.

[Screen-shot: New Menu Program]

From here the user can access the GEM menubar at the top of the screen which allows you to do the following;

[Screen-shot: /|\ menu]

'About NEW MENU...' displays a dialog box which provides details about the program.

[Screen-shot: File menu]

'Open' opens a GEM window.
'Close' closes the open GEM window.
'Quit' exits the program.

[Screen-shot: Options menu]

'Dim Me' disables the menu item.
'Check Me' toggles a tick on/off.
'Notes...' displays another alert dialog.

Selecting the 'Open' menu item under the 'File' menu opens a GEM window similar to the one shown below.

[Screen-shot: Test Window]

The user is able to interact with the GEM window thanks to the DO...LOOP subroutine (detailed in the source code). Whenever the user interacts with the GEM window, a window event is triggered which results in the following;

Window Event



Closes the GEM window


Title bar


Toggles between full size and previous window size. When switching to full size, the contents of the GEM window is redrawn.


I have set the 'Information bar' to inform the user what the last function carried out on the window was.


Resizes the window. As with correct conventions, a window will only redraw if increased in size, not when made smaller, although this feature can be added by modifying the DoSizer() Function.


The window can be moved about the screen, although it is not constrained to be completely within the screen.


If you have XControl in the desk accessories slot, you can switch between it and our test window by clicking on the appropriate title bar.


Left Arrow (disabled)


Right Arrow (disabled)


Horizontal Arrow (disabled)


Up Arrow (disabled)


Down Arrow (disabled)


Vertical Arrow (disabled)

How does the 'New Menu Program' work

Below I have written a brief overview of how the 'New Menu Program' works. For a more detailed explanation, please read the source code provided which includes helpful comments above most of the C commands which explain what's going on.

[Screen-shot: About dialog]

A brief overview is...

  1. Upon execution, load RSC file. If an error occurs then EXIT.
  2. Initialise and display the menubar.
  3. Open a virtual workstation (for window contents).
  4. Loop until a window/menu event occurs. Upon a window/menu event, execute the appropriate code. If the user has not selected 'Quit', return to program loop.
  5. Close any open windows, remove the menubar, close any virtual workstations and clears the resource file from memory.
  6. Returns to the desktop.

Well, this tutorial was a long time in happening. For next time I'll consider having a look at using the slider bars, or maybe a simple dialog box created using WERCS. Bye for now.


  • New Menu Program archive
    ZIP archive containing:
    • NEW_MENU.PRG (Executable)
    • NEW_MENU.RSC (Resource file for executable)
    • NEW_MENU.C (Source code)
    • NEW_MENU.H (Header file produced by resource editor)
    • NEW_MENU.HRD (Header file produced by resource editor)
    • NEW_MENU.O (Object code)
    • NEW_MENU.PRJ (Project file for Lattice C Compiler)

[ Top of page ]

MyAtari magazine - Feature #4, January 2002

Copyright 2002 MyAtari magazine