Home Hobby Work Code WWW
wmail Palm route newpic zeef Euro
Tutorial RSI Clock Convert
prevtocnextindex

Handle button

We now got a button, but all it does is turn to black when you click it. To make the make the application actually do something the MainFormHandleEvent function.
MainFormHandleEvent.c
#include "MainFormHandleEvent.h"

Boolean MainFormHandleEvent(EventPtr event) {
  FormPtr frm;      
  Boolean handled = false;

  switch (event->eType) {
    case ctlSelectEvent:
      if (event->data.ctlEnter.controlID == MainHelloButton) {
        WinDrawChars("Hello world!", 12, SysRandom(0) % 110, 
                                         SysRandom(0) % 100 + 20);
        handled = true;         
      } // MainHelloButton
      break; // ctlSelectEvent:

    case frmOpenEvent:
      frm = FrmGetActiveForm();
      FrmDrawForm(frm);
      handled = true;
      break; // frmOpenEvent:
  } // event->eType
  return handled;
} // MainFormHandleEvent

The case ctlSelectEvent has been added. This event is send when a control is selected (a button pushed for example). When this happens we check if the controlID is equal to the id of the button. Now we know the button has been pressed. The text Hello world! is put on a random place on the screen.

The application has put Hello world! on the screen.
The application has put Hello world! on the screen.
If you press the button a few times more, Hello world! appears on other places on the screen.
More Hello world! on the screen.
More Hello world! on the screen.

prevtocnextindex
Tutorial RSI Clock Convert
wmail Palm route newpic zeef Euro
Home Hobby Work Code WWW

Toni Cornelissen
13 September 2004
toni@dse.nl
Lid van de Technetium groep
Daily horoscope NetStat W3C Validator