ThinkC program--why wont it work?
Ernie Oporto
EAO102 at psuvm.psu.edu
Thu Mar 7 05:34:32 AEST 1991
OK......here's more of a problem.
I inserted the following lines inside of the create_t_window function:
WIND *t_windinfo;
WindowPtr t_window;
That seemed to have cleared up my problems with their being declared, but
now ThinkC is telling me that my #included files can't be openned.
Now what am I doing wrong? Below is the source code:
/*** 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;
{
/* ... */
WIND *t_windinfo;
WindowPtr t_window;
/* 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