HelloWorld: A simple GUI application with a single view

This example demonstrates a simple application using a GUI with a single view.


Click on the following link to download the example: HelloWorldGUI.zip

Click: browse to view the example code.

Design and implementation

This application consists of 4 classes:

E32Main() marks the entry point to the example. It calls EikStart::RunApplication() to create a new application instance. The UI framework then calls CExampleApplication::AppDllUid() to obtain the application's UID. The UID returned must match the second value defined in the project definition file.

Once the application is created, the UI framework calls CExampleApplication::CreateDocumentL() to create an instance of the document class. CreateDocumentL() internally calls the constructor of the document class and passes the supplied reference to the constructor initialisation list. The document has no real work to do in this simple GUI application.

As soon as the document has been created the UI framework creates an instance of the application UI (appUI). The appUI class is an instance of a CEikAppUi -derived class and this class takes care of user interaction.

AppUI creation uses two phase construction where first CExampleDocument::CreateAppUiL() is called and then the framework calls the second phase constructor of the appUI class. CExampleAppUi::ConstructL() creates and owns the view. User commands are handled by the CExampleAppUi::HandleCommandL() method.

The app view class is used to draw the view. The view in this example consists of a simple outline rectangle with text drawn in the middle.

The example contains a resource file HelloWorld.rss which defines resource information. This includes a menubar with four menu items, an icon and caption.

HelloWorld.hrh defines the menu command IDs and HelloWorld.pkg file is the source file used for installation file (SIS file) generation.

Building and configuring

Steps to build the example:

  • You can build the example from your IDE or the command line.

    If you use an IDE, import the bld.inf file of the example into your IDE, and use the build command of the IDE.

    If you use the command line, open a command prompt, and set the current directory to the source code directory of the example. You can then build the example with the SBSv1 build tools with the following commands:

    bldmake bldfiles

    abld build

  • For the emulator, the example builds an executable called helloworld.exe in the epoc32\release\winscw\<udeb or urel>\ folder.