Article View: comp.sys.mac
Article #24264Writting a DA in LSC
From: Milt Sagen
Date: Fri, 29 Jan 1988 03:51
Date: Fri, 29 Jan 1988 03:51
100 lines
2997 bytes
2997 bytes
I'm making my first attempt at writing a DA using LightSpeed C and I'm not
having very much luck.
The code, which follows, puts up a single window and should only handle update
events. The window does get created by when it is the active window, the
windows below it will no longer update correctly. Also when it is the top
window and I try to quit the underlying application the computer hangs. It is
as if the DA has taken over the machine and is intercepting all events.
Could one of you people with more experience than I (which isn't much) tell me
what I left out or what I am doing that is entirely wrong.
Thanks
THE CODE:
#include <WindowMgr.h>
#include <DeviceMgr.h>
#include <EventMgr.h>
#ifndef NULL
#define NULL 0L
#endif NULL
DCtlPtr dce ;
main(p, d, n)
cntrlParam *p ;
DCtlPtr d ;
int n ;
{
WindowPtr curWindow ;
Rect theRect ;
WindowPeek theWPeek ;
if( d->dCtlStorage == 0 ) {
if( n == 0 ) { /* open the DA */
SysBeep(3) ;
CloseDriver( d->dCtlRefNum ) ;
}
return( 0 ) ;
}
dce = d ;
switch( n ) {
case 0 : /* open the DA */
dce->dCtlEMask = 64 ; /* update events only */
GetPort( &curWindow ) ;
if( dce->dCtlWindow == NULL ) { /* then allocate the window */
SetRect( &theRect, 156, 71, 356, 271 ) ;
dce->dCtlWindow = NewWindow( 0L, &theRect, "\pMy DA", false,
rDocProc, (Ptr)-1, true, 0L ) ;
theWPeek = (WindowPeek) dce->dCtlWindow ;
theWPeek->windowKind = dce->dCtlRefNum ;
}
SetPort( curWindow ) ;
break ;
case 2 : /* dispatch events */
switch( p->csCode ) {
case accEvent :
DoEvents( (EventRecord *) p->csParam ) ;
break ;
}
break ;
case 4 :
GetPort( &curWindow ) ;
DisposeWindow( dce->dCtlWindow ) ;
dce->dCtlWindow = NULL ;
SetPort( curWindow ) ;
break ;
}
return(0) ;
}
DoEvents( theEvent )
EventRecord *theEvent ;
{
WindowPtr curWindow ;
switch( theEvent->what ) {
case updateEvt :
BeginUpdate( (WindowPtr) theEvent->message ) ;
SetPort( (WindowPtr) theEvent->message ) ;
EndUpdate( (WindowPtr) theEvent->message ) ;
break ;
} /* end of switch on theEvent.what */
}
END OF CODE:
I hope the spacing looks alright on your terminals I had to redo some of it
to get it to look readable on mine.
Milt Sagen
Dept of Physics
Oregon STate U.
Corvallis, OR 97331
milt%orstph.UUCP@orstcs.CS.ORST.EDU
Technical Details
Message-ID:
<2201@orstcs.CS.ORST.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!orstcs!mist!miltReferences:
<7971@eleazar.Dartmouth.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!orstcs!mist!milt From: milt@mist.cs.orst.edu (Milt Sagen) Newsgroups: comp.sys.mac Subject: Writting a DA in LSC Keywords: what is wrong? Message-ID: <2201@orstcs.CS.ORST.EDU> Date: 29 Jan 88 03:51:40 GMT References: <7971@eleazar.Dartmouth.EDU> Sender: netnews@orstcs.CS.ORST.EDU Reply-To: milt@mist.UUCP (Milt Sagen) Organization: Oregon State Universtiy - CS - Corvallis, Oregon Lines: 100