Chapter 2. ZHelloWorld

Table of Contents

ZMain: the Application Entry Point
ZHelloWorld_App: the Application Object
Installing the Menus
ZRef: the Thread-Safe Reference Counted Smart Pointer
ZHelloWorld_Window: the Window Objects
The Window Class Declaration
Our First Look at ZPaneLocator
Constructing and Destructing the Window
Creating the Window's Menus
Enabling the Menu Items
Handling Menu Messages

Our first ZooLib application must of course be the proverbial "Hello, World". With ZooLib we display a window with those words, and menu items that show how to retrieve the text from a resource file, and display a BMP graphic.

ZMain: the Application Entry Point

Every ZooLib application's client code starts up in ZMain(). ZMain is used rather than main() because different operating systems have different conventions for the parameters to be passed to main, and on Windows, WinMain is used rather than main(). Most ZooLib applications will have a ZMain that is much like ZHelloWorld's:

int ZMain(int argc, char** argv)
        ZHelloWorld_App theApp;
    catch (...)

    return 1;

The first thing we do is create an instance of our application object, here ZHelloWorld_App. It is a subclass of ZApp. We call the ZApp's Run() method, and when Run() finishes, we exit ZMain, and the program terminates.

There are ordinarily several threads in a ZooLib application. The application object has its own thread, and each window has a thread. The window threads come and go as windows are created and closed, but the application object's thread keeps running the whole time.