ThinkC program--why wont it work?

Ernie Oporto EAO102 at psuvm.psu.edu
Wed Mar 6 03:01:54 AEST 1991


I have entered this program into Think C for compilation.  It appeared in the C
 Users Journal in the August 1990 issue.  When I try to compile it, I get
"t_window ..." and "t_windinfo not defined".  What should I do.


Each  ; char with a - over it indicates a tab.

/*** generic main event loop ***/


#include "WindowMgr.h"
#include "EventMgr.h"
#include "QuickDraw.h"

void mainevent()
{
   EventRecord event;

   while(1)  /* forever */
   {
      GetNextEvent(everyEvent,&event);

      switch (event.what)
      {
         case mouseDown:
            do_mousedown(event);
            break;
         case keyDown:
         case autoKey:
            do_keydown(event);
            break;
         case activateEvt:
            do_activate(event);
            break;
         case updateEvt:
            do_update(event);
            break;
         default:
            do_idle();
            break;
       }
   }
}

/*** window info structure ***/

typedef struct wind
{
   char dirty; /* contents saved? */
   char zoom;  /* window "zoomed"? */
   void **data; /* window contents */

/* window messages/methods */

   void(*activateproc)();
   void (*updateproc)();
   void (*keydownproc)();
   void (*contentproc)();
   void (*goawayproc)();
   void (*growproc)();
   void (*zoomproc)();
   void (*idleproc)();
   void (*disposeproc)();
   void (*cutproc)();
   void (*copyproc)();
   void (*pasteproc)();
   void (*clearproc)();
   void (*findproc)();
} WIND;

/*** text window creation function ***/

void create_t_window(title,wrect,closebox)
char *title;
Rect wrect;
int closebox;

{
/*    ...     */

/* allocate new window info */

   t_windinfo =
      (WIND *)NewPtr(sizeof(WIND));

/* allocate new window */

   t_window =
      NewWindow(NIL,&wrect,title,TRUE,8,FRONT,closebox,NIL);
/*     ...     */

/* insert window methods */

   t_windinfo->activateproc = t_activate;
   t_windinfo->updateproc = t_update;
   t_window->keydown = t_keydown;
/* etc... */

/* insert info into window refCon */

   SetWRefCon(t_window,t_windinfo);
}

/***text window activate method ***/

void t_activate(window,windinfo)
WindowPtr window;
WIND      *windinfo;
{
   TEHandle  tehandle;

      /* get data handle */

   tehandle =
      (TEHandle)windinfo->data;
         /* activate event */
   if(event.modifiers & activeFlag)
   {
      TEActive(tehandle);
      HiliteControl(((WindowPeek) window)
        ->controlList,ENABLE);
      TEFromScrap();
      enable_edit((**tehandle).selEnd
        - (**tehandle).selStart);
      enable_find();
      }
      else /* deactivate event */
      {
         TEDeactivate (tehandle);
         HiliteControl(((WindowPeek) window)
           ->controlList,DISABLE);
         ZeroScrap();
         TEToScrap();
         disable_edit():
         disable_find();
      }
}

/*** activate message dispatcher ***/

void do_activate(event)
EventRecord event;
{
   WindowPtr window;
   WIND   *windinfo;

   window = (WindowPtr)event.message;

   windinfo = (WIND *)GetWRefCon(window);

   (*windinfo->activateproc)(window,windinfo);
}

/*** Macintosh application ***/

main()
{
/* Mac specific initialization */

   init_mac();

/* set up application menus */

   setup_menus();

/*   etc...   */

/* call main event loop */

   mainevent();
}



More information about the Comp.lang.c mailing list