Xref: utzoo comp.lang.c:36799 comp.sys.mac.programmer:22366 Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!ukma!psuvax1!psuvm!eao102 From: EAO102@psuvm.psu.edu (Ernie Oporto) Newsgroups: comp.lang.c,comp.sys.mac.programmer Subject: ThinkC program--why wont it work? Message-ID: <91064.120155EAO102@psuvm.psu.edu> Date: 5 Mar 91 17:01:54 GMT Organization: Penn State University Lines: 171 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(); }