TweetFollow Us on Twitter

cdev Debugging
Volume Number:6
Issue Number:2
Column Tag:Pascal Procedures

Related Info: Control Panel Dialog Manager

CDEV Debugging

By J. Peter Hoddie, Palo Alto, CA

A cdev Shell

This article describes a shell program created to simplify the process of writing, testing, and debugging Control Panel devices. The shell is written in MPW Pascal (actually it was developed in TML Pascal II, but the two are compatible) and so is appropriate for use with cdev’s written in the MPW environment. The cdev shell has been tested with Apple’s SADE debugger. This article does not describe how to write a cdev. For the details on writing a cdev, including a working example, see Inside Macintosh Volume 5.

Without a cdev shell, the process of testing a cdev is less then simple. You must compile and link the cdev, place it in the system folder, and select the Control Panel. Under these circumstances you cannot use a source level debugger, only MacsBug. Using the cdev shell, you simply link your cdev with the shell code and run it as a normal application which gives you access to a source level debugger. The cdev shell has several features designed specifically for testing. The shell itself does not appear graphically identical to the Control Panel, however as far as the cdev itself is concerned there is no difference.

The cdev shell was designed not only to allow the use of a source level debugger, but also to provide a collection of features for easily testing the many messages to which a cdev is expected to respond. Further, because as you are developing a cdev you may not have written code to handle each messages, a dialog presented from the “Message Masks...” menu item allows you to filter out any combination of cdev messages. Your message mask settings are stored as a resource type ‘msks’ so that you don’t have to reset them each time you use the shell.

An option to force the cdev to update its entire window to test your drawing code is available as the “Force Update” menu item.

A small window named “Other Window” appears above and to the right of the Control Panel window. This window allows you to test the activate and deactivate messages by making the “Other Window” the active window. By covering areas of your cdev’s panel with the “Other Window” you can further test the screen updating capabilities of your cdev.

All of the options on the standard Edit menu are passed to the cdev as the corresponding cdev messages.

When you start up the cdev shell, the test cdev is not selected. Either click on its icon or select Open from the file menu. To close the cdev, select Close from the file menu or click on the stop sign icon. This allows you to test the open and close cdev messages multiple times without having to relaunch the cdev shell. By not immediately selecting the test cdev in the shell, you have the opportunity to set break points, modify the message masks, and perform any other required actions.

Tech Note #215 - “New” cdev Messages - describes a cdev message, cursorDev, that is not documented in Inside Macintosh. It states that if a ‘CURS’ -4064 (cursor) resource is present in the cdev file, that the cdev will receive a cursorDev message (number 14) whenever the cursor is inside the cdev’s window. This allows the cdev to have its own cursor as appropriate. The shell fully supports this new message.

The shell also checks that certain required resources are present. If a required resource is missing, an error message is generated and the shell aborts. The cdev resources that the shell must have to run are ‘DITL’, ‘mach’, ‘nrct’, and ‘ICN#’ all with ID -4064. The only required resources that the shell does not check for are the ‘cdev’ code, ‘BNDL’ and ‘FREF’ resources.

The shell does other error checking as appropriate. For example, the macDev message is only allowed to return one of two values. If any other value is returned, the shell issues a warning alert.

The shell will only send the cdev the macDev message if the values of the hard and soft masks in the ‘mach’ -4064 resource are set as documented in Inside Macintosh. Otherwise the shell compares these to HwCfgFlags and ROM85 in low memory as described in Inside Macintosh. While Inside Macintosh claims that HwCfgFlags is a low memory global, its location is never given. I had to fish it out of one the “private” MPW Assembler equates files.

This article does not include a sample cdev to use with the shell. It is currently set up to work with the Sample provide in Inside Macintosh Volume 5. The only call the cdev shell makes to code outside itself is to the entry point of the cdev unit that is being tested. The name of the unit that the cdev shell expects to find is “cdev” and the name of the main cdev routine (really its entry point) is “Sample” - exactly as the sample unit in Inside Macintosh.

There is one minor bug in the Sample cdev from Inside Macintosh. In the function EnoughRoomToRun the call to GetResource should be replaced with a call to RGetResource or the cdev will not run.

The shell is not a great example of how to write a Macintosh application. It clearly demonstrates what Tech Note #203 - Don’t Abuse the Managers - tries to drive home: the Dialog Manager is not a user interface! Unfortunately, since the Control Panel relies on the Dialog Manager, there was no choice for the cdev shell. Also, the shell was originally written in THINK C, and then translated to Pascal when I found out that a cdev shell was shipping with THINK C Version 4. Anyone who is interested in the C version may contact me directly for a copy. Converting the code presented in this article to run under THINK Pascal should be an easy task.

File: cdevShell.make

# Commands to build cdev Shell using MPW Pascal
#
# put the name of your cdev files in place of cdev.p, 
# cdev.p.o, and cdev.r below
#
    Pascal cdev.p -sym on
    Pascal cdevShell.p -sym on
    Link -w -t ‘APPL’ -c ‘????’ -sym on 
 cdev.p.o 
   cdevShell.p.o 
 “{Libraries}”Runtime.o 
 “{Libraries}”Interface.o 
 “{PLibraries}”PasLib.o 
 “{PLibraries}”SANELib.o
 -o cdevShell
    Rez -append -o cdevShell cdev.r
    Rez -append -o cdevShell cdevShell.r
File: cdevShell.p

PROGRAM cdevShell;

USES  MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
 cdev;

CONST
 cursorDev = 14;
 HwCfgFlgs = $0B22;
 ROM85 = $028E;

TYPE
 IntPtr = ^integer;
 IntHandle = ^IntPtr;
 RectPtr = ^rect;
 EventPtr = ^EventRecord;

PROCEDURE doMenu(l: longInt); FORWARD;
PROCEDURE updateDial;FORWARD;
PROCEDURE drawIcon(ih: Handle; selected: Boolean;
 r: Rect);FORWARD;
PROCEDURE startupCdev;  FORWARD;
PROCEDURE shutDownCdev; FORWARD;
PROCEDURE cdevInitDev;  FORWARD;
PROCEDURE cdevHitDev(item: integer; e: EventPtr);
 FORWARD;
PROCEDURE cdevUpdateDev;  FORWARD;
PROCEDURE cdevNulDev(e: EventPtr); FORWARD;
PROCEDURE cdevCloseDev; FORWARD;
PROCEDURE cdevEdit(c: integer);  FORWARD;
PROCEDURE cdevKeyEvtDev(e: EventPtr);FORWARD;
PROCEDURE cdevActivate(e: EventPtr); FORWARD;
PROCEDURE cdevMacDev;FORWARD;
PROCEDURE cdevCursorDev;  FORWARD;
PROCEDURE fatalError(s : Str255);  FORWARD;
PROCEDURE warningError(s : Str255);FORWARD;
PROCEDURE doMsgDialog;  FORWARD;
FUNCTION callCdev( msgCode : integer; item : integer;
 e : EventPtr; st : longInt) :longInt; FORWARD;
PROCEDURE doNRCTs; FORWARD;
PROCEDURE getNRCTrgn;FORWARD;
PROCEDURE HiliteDefault(d: DialogPtr); FORWARD;

VAR
 cdevDial:DialogPtr;
 dP:    DialogPeek;
 cdevItems: integer;
 userItems: integer;
 teWas: integer;
 cdevStorage:  longInt;

 nrctRgn: RgnHandle;
 greyRgn: RgnHandle;
 userArea:Rect;

 stopRect,
 startRect: Rect;
 myStopIcon,
 myStartIcon:  Handle;

 cursorIsArrow:  Boolean;
 cdevMsgOff:array[0 .. 16] of Boolean;
 selected:Boolean;
 running: Boolean;

 env:   SysEnvRec;
 entryVref: integer;
 otherWindow:  WindowPtr;
 error: integer;

 i,j:   integer;
 temp, cdevDITL: Handle;
 e:EventRecord;
 rH:    RgnHandle;
 whichWindow:  WindowPtr;
 key:   char;
 p:Point;
 s:Str255;
 hasCursor: Boolean;
 teH:   TEHandle;
 trashB:Boolean;

PROCEDURE doMenu(l: longInt);
VARmenu, choice, i:integer;
 daName:Str255;
 d:DialogPtr;
BEGIN
 menu := HiWord(l);
 choice := LoWord(l);
 
 case menu of
 1:BEGIN
 if choice = 1 then BEGIN
 d := GetNewDialog(132, nil, WindowPtr(-1));
 HiliteDefault(d);
 repeat
 ModalDialog(nil, i)
 until i = 1;
 DisposDialog(d);
 END;
 if choice > 1 then BEGIN
 GetItem(GetMHandle(1), choice, daName);
 error := OpenDeskAcc(daName);
 END;
 END;
 2:case choice of
 1: startupCdev;
 2: shutDownCdev;
 4: running := false;
 END;
 3:if FrontWindow = cdevDial then
 cdevEdit(choice)
 else
 trashB := SystemEdit(choice - 1);
 4:case choice of
 1: doMsgDialog;
 2: 
 InvalRect(GrafPtr(cdevDial)^.portRect);
 END; { of case }
 END; { of case }
 HiliteMenu(0);
END;

PROCEDURE updateDial;
VAR
 r:Rect;
 patHand: PatHandle;
 i:integer;
 h:Handle;
BEGIN
 SetPort(cdevDial);
 TextSize(9);
 
 PenSize(2,2);
 
 patHand := GetPattern(-16000);
 PenPat(patHand^^);
 PaintRgn(nrctRgn);
 PenPat(black);

 doNRCTs;
 r := cdevDial^.portRect;
 InsetRect(r, -2, -2);
 r.top := r.top + 1;
 FrameRect(r);

 GetDItem(cdevDial, 2, i, h, r);
 r.top := r.top - 2;
 r.bottom := r.bottom -1;
 r.left := r.left - 2;
 r.right := r.right + 1;
 FrameRect(r);

 GetDItem(cdevDial, 1, i, h, r);
 r.top := r.top - 2;
 r.bottom := r.bottom + 2;
 r.left := r.left - 2;
 r.right := r.right + 2;
 FrameRect(r);

 PenSize(1,1);

 drawIcon(myStopIcon, not selected, stopRect);
 drawIcon(myStartIcon, selected, startRect);
END;

PROCEDURE drawIcon(ih: Handle; selected: Boolean; r: Rect);
VAR
 iconBitMap:BitMap;
 fromR: Rect;
BEGIN
 SetRect(fromR, 0, 0, 32, 32);
 iconBitMap.rowBytes := 4;
 iconBitMap.bounds := fromR;
 HLock(iH);
 if (selected) then BEGIN
 iconBitMap.baseAddr := Ptr(ORD4(iH^) + longInt(128));
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcCopy, nil);

 iconBitMap.baseAddr := ih^;
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcXor, nil);
 END
 else BEGIN
 iconBitMap.baseAddr := ih^;
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcCopy, nil);
 END;
 HUnlock(iH);
END;

PROCEDURE startupCdev;
VAR
 temp:  Handle;
 i,j,totalItems: integer;
 hardMask, softMask: integer;
 p:Ptr;
 c:ControlHandle;
 tempD: DialogPtr;
 r:Rect;
BEGIN
 selected := true;
 
 getNRCTrgn;
 
 temp := GetResource(‘mach’, -4064);
 if temp = nil then
 fatalError(‘mach -4064 resource not found’);
 softMask := IntHandle(temp)^^;
 hardMask := IntPtr(2+ORD4(temp^))^;
 if (softMask = 0) and (hardMask = $ffff) then BEGIN
 cdevMacDev;
 if cdevStorage = 0 then
 fatalError(‘cdev refuses to run on this machine’);
 if cdevStorage <> 1 then
 fatalError(‘Invalid result returned from macDev call’);
 END
 else BEGIN
 if integer(BitAnd(softMask, IntPtr(ROM85)^))
 <> Intptr(ROM85)^ then
 fatalError(‘cdev failed SoftMask test’);
 if integer(BitAnd(hardMask, IntPtr(HwCfgFlgs)^))
 <> hardMask then
 fatalError(‘cdev failed HardMask test’);
 END;
 ReleaseResource(temp);

 IntHandle(dP^.items)^^ := cdevItems + userItems;
 dP^.editField := teWas;
 if teWas <> -1 then
 TEActivate( dP^.textH);
 SetPort(cdevDial);
 TextSize(9);
 for i:= cdevItems + 1 to cdevItems + userItems do
 ShowDItem(cdevDial,i);

 doNRCTs;
 
 DisableItem(GetMHandle(2),1);
 EnableItem(GetMHandle(2), 2);

 cdevInitDev;

 InvalRect(GrafPtr(cdevDial)^.portRect);
END;

PROCEDURE shutDownCdev;
VARi: integer;
BEGIN
 cdevCloseDev;

 SetCursor(arrow);
 cursorIsArrow := true;

 if cdevStorage <> 0 then
 warningError(‘Close call did not return zero’);

 for i := cdevItems + 1 to cdevItems + userItems do
 HideDItem(cdevDial, i);
 
 IntHandle(dP^.items)^^ := cdevItems;
 dP^.editField := -1;
 if teWas <> -1 then
 TEDeactivate(dP^.textH);

 selected := false;

 getNRCTrgn;

 EnableItem(GetMHandle(2), 1);
 DisableItem(GetMHandle(2), 2);

 InvalRect(GrafPtr(cdevDial)^.portRect);
END;

PROCEDURE cdevInitDev;
BEGIN
 cdevStorage := callCdev(initDev, 0, nil, cdevUnset);
END;

PROCEDURE cdevHitDev(item: integer; e: EventPtr);
BEGIN
 cdevStorage := callCdev(hitDev, item, e, cdevStorage);
END;

PROCEDURE cdevUpdateDev;
BEGIN
 cdevStorage := callCdev(updateDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevNulDev(e: EventPtr);
BEGIN
 cdevStorage := callCdev(nulDev, 0, e, cdevStorage);
END;

PROCEDURE cdevCloseDev;
BEGIN
 cdevStorage := callCdev(closeDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevEdit(c: integer);
BEGIN
 case c of
 1:i := undoDev;
 3:   i := cutDev;
 4:i := copyDev;
 5:i := pasteDev;
 6:i := clearDev;
 END;
 cdevStorage := callCdev(i, 0, nil, cdevStorage);
END;

PROCEDURE cdevKeyEvtDev(e: EventPtr);
BEGIN
 cdevStorage := callCdev(keyEvtDev, 0, e, cdevStorage);
END;

PROCEDURE cdevActivate(e: EventPtr);
VARi:   integer;
BEGIN
 if BitAnd(e^.modifiers, activeFlag) <> 0 then
 i := activDev
 else
 i := deactivDev;
 cdevStorage := callCdev(i, 0, e, cdevStorage);
END;

PROCEDURE cdevMacDev;
BEGIN
 cdevStorage := callCdev(macDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevCursorDev;
BEGIN
 cdevStorage := callCdev(cursorDev, 0, nil, cdevStorage);
END;

FUNCTION callCdev( msgCode : integer; item : integer; 
 e : EventPtr; st : longInt) :longInt;
 var  rValue:  longInt;
 error :integer;
BEGIN
 if (not selected) or (cdevMsgOff[msgCode]) 
 then BEGIN
 callCdev := st;
 exit(callCdev);
 END;

 SetPort(cdevDial);
 TextSize(9);
 error := SetVol(nil, env.sysVRefNum);
 rValue := Sample(msgCode, item, cdevItems, 0, e^,
 st, cdevDial);
 error := SetVol(nil, entryVref);

 if (msgCode <> macDev) and 
 (msgCode <> closeDev) then
 case rValue of
 cdevGenErr:fatalError(‘General cdev error’);
 cdevMemErr: fatalError(‘cdev insufficient memory error’);
 cdevResErr: fatalError
 (‘cdev could not locate needed resource’);
 END; { of case }
 callCdev := rValue;
END;

PROCEDURE fatalError(s : Str255);
BEGIN
 ParamText(s, ‘’, ‘’, ‘’);
 error := Alert(130, nil);
 ExitToShell;
END;

PROCEDURE warningError(s : Str255);
BEGIN
 ParamText(s, ‘’, ‘’, ‘’);
 error := Alert(131, nil);
END;

PROCEDURE doMsgDialog;
VARd:   DialogPtr;
 i,kind:integer;
 r:Rect;
 h:Handle;
BEGIN
 d := GetNewDialog(128, nil, WindowPtr(-1));
 HiliteDefault(d);

 for i:= initDev + 3 to cursorDev + 3 do BEGIN
 GetDItem(d, i, kind, h, r);
 kind := integer(cdevMsgOff[i-3]);
 if kind <> 0 then
 kind := 1;
 SetCtlValue(ControlHandle(h), kind);
 END;
 
 repeat
 ModalDialog(nil, i);
 if i > 2 then BEGIN
 GetDItem(d, i, kind, h, r);
 SetCtlValue(ControlHandle(h),
 ABS(GetCtlValue(ControlHandle(h)) - 1));
 END
 until i <= 2;

 if i = 1 then BEGIN
 for i:= initDev + 3 to cursorDev + 3 do BEGIN
 GetDItem(d, i, kind, h, r);
 cdevMsgOff[i-3] :=
 Boolean(GetCtlValue(ControlHandle(h)));
 END;
 h := GetResource(‘msks’, 128);
 if h <> nil then BEGIN
 BlockMove(Ptr(@cdevMsgOff), h^, 16);
 ChangedResource(h);
 WriteResource(h);
 END;
 END;

 DisposDialog(d);
END;

PROCEDURE doNRCTs;
VARh:   Handle;
 r:RectPtr;
 i:integer;
BEGIN
 if not selected then
 exit(doNRCTs);

 h := GetResource(‘nrct’, -4064);
 r := RectPtr(2 + ORD4(h^));
 for i:= 1 to IntHandle(h)^^ do BEGIN
 EraseRect(r^);
 FrameRect(r^);
 r := RectPtr(ORD4(r) + sizeof(Rect));
 END; { of loop }
 ReleaseResource(h);
END;

PROCEDURE getNRCTrgn;
VAR
 h:Handle;
 r:RectPtr;
 rct: Rect;
 i:integer;
 rRgn:  RgnHandle;
BEGIN
 if not selected then
 BEGIN
 SetRect(rct, 86, -1, 322, 255);
 nrctRgn := NewRgn;
 RectRgn(nrctRgn, rct);
 exit(getNRCTrgn);
 END;

 h := GetResource(‘nrct’, -4064);
 if h = nil then
 fatalError(‘nrct -4064 resource is missing’);
 nrctRgn := NewRgn;
 HLock(h);
 r := RectPtr(2+ORD4(h^));
 for i:= 1 to IntHandle(h)^^ do BEGIN
 rRgn := NewRgn;
 RectRgn(rRgn, r^);
 r := RectPtr(ORD4(r) + sizeof(Rect));
 UnionRgn(nrctRgn, rRgn, nrctRgn);
 DisposeRgn(rRgn);
 END; { of loop }
 HUnlock(h);
 ReleaseResource(h);

 SetRect(rct, 86, -1, 322, 255);
 rRgn := NewRgn;
 RectRgn(rRgn, rct);
 DiffRgn(rRgn, nrctRgn, nrctRgn);
 DisposeRgn(rRgn);
END;

PROCEDURE mvWindow(w: WindowPtr; p: Point);
VARtrashR:Rect;
BEGIN
 trashR := screenBits.bounds;
 InsetRect(trashR, 6, 6);
 DragWindow(w, p, trashR);
END;

PROCEDURE HiliteDefault(d: DialogPtr);
VARi:   integer;
 box:   Rect;
 h:Handle;
BEGIN
 SetPort(d);
 GetDItem(d, 1, i, h, box);
 PenSize(3,3);
 InsetRect(box, -4, -4);
 FrameRoundRect(box, 16, 16);
END;

PROCEDURE Initialize;
BEGIN
 InitGraf(@thePort);
 InitFonts;
 InitWindows;
 TEInit;
 InitDialogs(nil);
 InitCursor;
 cursorIsArrow := true;
 MaxApplZone;
 
 SetMenuBar( GetNewMBar(256) );
 AddResMenu( GetMHandle(1), ‘DRVR’);
 DrawMenuBar;
 DisableItem(GetMHandle(2),2);
 
 error := SysEnvirons(0, env);
 error := GetVol(@s, entryVref);

 getNRCTrgn;
 
 temp := GetResource(‘msks’, 128);
 if temp <> nil then
 BlockMove(temp^, Ptr(@cdevMsgOff), 16);

 hasCursor := ( GetResource(‘CURS’, -4064) <> nil );

 SetRect(userArea, 87, 0, 322, 255);
 SetRect(stopRect, 25, 15, 25+32, 15+32);
 SetRect(startRect, 25, 85, 25+32, 85+32);

 myStartIcon := GetResource(‘ICN#’, -4064);
 if (myStartIcon = nil) then
 fatalError(‘Unable to find cdev ICN# -4064 resource’);
 myStopIcon := GetResource(‘ICN#’, 128);

 selected := false;

 cdevDITL := GetResource(‘DITL’, -16000);
 HNoPurge(cdevDITL);
 temp := GetResource(‘DITL’, -4064);
 if temp = nil then
 fatalError(‘Unable to find cdev DITL -4064 resource’);
 cdevItems := 1 + IntHandle(cdevDITL)^^;
 
 userItems := IntHandle(temp)^^;
 IntHandle(cdevDITL)^^ := cdevItems + userItems;
 i := GetHandleSize( cdevDITL );
 j := GetHandleSize( temp );
 SetHandleSize(cdevDITL, i+j-2);
 BlockMove(Ptr(2 + ORD4(temp^)), 
 Ptr(i + ORD4(cdevDITL^)), j-2);
 
 SetDAFont(1);
 cdevDial := GetNewDialog(-16000, nil, WindowPtr(-1));
 SetDAFont(0);
 dP := DialogPeek(cdevDial);
 SetPort(cdevDial);
 TextSize(9);
 ShowWindow(cdevDial);
 for i:= cdevItems + 1 to cdevItems+userItems do
 HideDItem(cdevDial, i);

 IntHandle(dP^.items)^^ := cdevItems;
 teWas := dP^.editField;
 dP^.editField := -1;
 if teWas >= 0 then BEGIN
 teH := dp^.textH;
 teH^^.txSize := 9;
 END;

 otherWindow := GetNewWindow(128, nil, WindowPtr(0));
END; { of Initialize}

PROCEDURE DoNullEvent;
BEGIN
 cdevNulDev(@e);
 SetPort(cdevDial);
 GetMouse(p);
 if (FrontWindow = cdevDial) and 
 PtInRect(p, userArea) then BEGIN
 if hasCursor then 
 cdevCursorDev
 else 
 if cursorIsArrow then
 SetCursor(GetCursor(crossCursor)^^);
 cursorIsArrow := false;
 END
 else
 if not cursorIsArrow then BEGIN
 SetCursor(arrow);
 cursorIsArrow := true
 END
END; { of doNullEvent }

PROCEDURE DoMouseDown;
BEGIN
 i := FindWindow(e.where, whichWindow);
 case i of
 inMenuBar: doMenu( MenuSelect(e.where) );
 inDrag:BEGIN
 mvWindow(whichWindow, e.where);
 e.what := nullEvent;
 END;
 inGoAway:if TrackGoAway(whichWindow, e.where)                 
 then running := false;
 inSysWindow: SystemClick(e, whichWindow);
 inContent: BEGIN
 if FrontWindow <> whichWindow
 then BEGIN
 SelectWindow(whichWindow);
 e.what := nullEvent
 END
 else if (FrontWindow = cdevDial)
 then BEGIN
 p := e.where;
 GlobalToLocal(p);
 if (not selected) and    PtInRect(p, startRect) then
 startUpCdev;
 if selected and
 PtInRect(p, stopRect) then
 shutDownCdev;
 END; { of if frontWindow}
 END; { of inContent}
 END; { end of case }
END;


BEGIN
 Initialize;

 running := true;
 while running do BEGIN
 SystemTask;
 
 if dp^.editField >= 0 then
 TEIdle( dp^.textH);
 
 if GetNextEvent(everyEvent, e) then BEGIN

 if (e.what = keyDown) or (e.what = autoKey) 
 then BEGIN
 key := char(BitAnd(e.message,charCodeMask));
 if BitAnd(e.modifiers, cmdKey) <> 0 then                      BEGIN
 doMenu(MenuKey(key));
 e.what := nullEvent;
 END;
 END;
 
 if e.what = mouseDown then
 DoMouseDown;

 if (e.what = updateEvt) and
 (e.message=longInt(otherWindow))
 then BEGIN
 BeginUpdate(otherWindow);
 EndUpdate(otherWindow);
 END;
 if IsDialogEvent(e) then BEGIN
 if (e.what = updateEvt) and
 (e.message = longInt(cdevDial))
 then BEGIN
 rH :=
 WindowPeek(cdevDial)^.updateRgn;
 error := HandToHand(Handle(rH));
 BeginUpdate(cdevDial);
 updateDial;
 cdevUpdateDev;
 EndUpdate(cdevDial);
 WindowPeek(cdevDial)^.updateRgn
 := rH;
 END;
 if (e.what = keyDown) or
 (e.what = autoKey) then
 cdevKeyEvtDev(@e);
 if e.what = activateEvt then
 cdevActivate(@e);
 
 SetPort(cdevDial);
 TextSize(9);
 if DialogSelect(e, cdevDial, i) then
 BEGIN
 if e.what = mouseDown then BEGIN
 if i =1 then
 error := 
 Alert(-16000, nil);
 if i > cdevItems then
 cdevHitDev(i, @e);
 END;
 END; { of DialogSelect if }
 END; { of DialogEvent if }
 END; { end of GNE if }
 if e.what = nullEvent then
 doNullEvent;

 END;

 cdevCloseDev;
 DisposDialog(cdevDial);
 DisposeWindow(otherWindow);
END.
File: cdevShell.r

#include “SysTypes.r”
#include “Types.r”

resource ‘PAT ‘ (-16000, purgeable) {
 $”40 00 04 00 40 00 04"
};

resource ‘ICN#’ (128, “Other”) {
 { /* array: 2 elements */
 /* [1] */
 $”00 00 00 00 00 7F FF 80 00 80 00 40 01 00 00 20"
 $”02 00 00 10 04 3C 00 08 08 24 00 04 08 20 00 02"
 $”08 3D F0 02 08 04 40 02 08 24 40 02 08 3C 5E 02"
 $”08 00 52 02 08 00 52 02 08 00 12 02 08 00 12 F2"
 $”08 00 1E 92 08 00 00 92 08 00 00 F2 08 00 00 82"
 $”08 00 00 82 04 00 00 82 02 00 00 02 01 00 00 04"
 $”00 80 00 08 00 40 00 10 00 20 00 20 00 1F FF C0",
 /* [2] */
 $”00 00 00 00 00 7F FF 80 00 FF FF C0 01 FF FF E0"
 $”03 FF FF F0 07 FF FF F8 0F FF FF FC 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 07 FF FF FE 03 FF FF FE 01 FF FF FC”
 $”00 FF FF F8 00 7F FF F0 00 3F FF E0 00 1F FF C0"
 }
};

resource ‘DLOG’ (-16000, purgeable) {
 {58, 117, 311, 437},
 documentProc,
 invisible,
 goAway,
 0x0,
 -16000,
 “Control Panel”
};

resource ‘DLOG’ (128, “Msg Masks”) {
 {50, 60, 286, 450},
 dBoxProc,
 visible,
 goAway,
 0x0,
 128,
 “”
};

resource ‘DLOG’ (132, “About...”) {
 {62, 104, 172, 398},
 dBoxProc,
 visible,
 noGoAway,
 0x0,
 132,
 “”
};

resource ‘DITL’ (-15999, purgeable) {
 { {65, 85, 85, 155},
 Button {
 enabled,
 “OK”
 },
 {8, 60, 56, 235},
 StaticText {
 disabled,
 “”
 },
 {61, 81, 89, 159},
 UserItem {
 disabled
 },
 {10, 20, 42, 52},
 Icon {
 enabled,
 0
 }
 }
};

resource ‘DITL’ (-16000, purgeable) {
 { {241, 1, 253, 87},
 StaticText {
 enabled,
 “3.3.1”
 },
 {1, 1, 242, 88},
 UserItem {
 enabled
 }
 }
};

resource ‘DITL’ (-15998, purgeable) {
 { {5, 7, 100, 227},
 StaticText {
 disabled,
 “Contributions by:\n   Steve Horowitz--the “
 “main man\n   scott douglass\n   Kristee Kr”
 “eitman\n   Amy Goldsmith”
 },
 {113, 155, 134, 224},
 Button {
 enabled,
 “Continue”
 }
 }
};

resource ‘DITL’ (130) {
 { {139, 189, 159, 249},
 Button {
 enabled,
 “OK”
 },
 {29, 30, 124, 251},
 StaticText {
 disabled,
 “Fatal Error: ^0”
 }
 }
};

resource ‘DITL’ (128) {
 { {202, 300, 222, 360},
 Button {
 enabled,
 “OK”
 },
 {201, 212, 221, 272},
 Button {
 enabled,
 “Cancel”
 },
 {40, 24, 62, 102},
 CheckBox {
 enabled,
 “initDev”
 },
 {70, 24, 84, 110},
 CheckBox {
 enabled,
 “hitDev”
 },
 {100, 24, 115, 104},
 CheckBox {
 enabled,
 “closeDev”
 },
 {130, 24, 146, 106},
 CheckBox {
 enabled,
 “nulDev”
 },
 {160, 24, 176, 112},
 CheckBox {
 enabled,
 “updateDev”
 },
 {40, 160, 61, 251},
 CheckBox {
 enabled,
 “activDev”
 },
 {70, 160, 92, 276},
 CheckBox {
 enabled,
 “deActiveDev”
 },
 {100, 160, 116, 253},
 CheckBox {
 enabled,
 “keyEvtDev”
 },
 {130, 160, 148, 261},
 CheckBox {
 enabled,
 “macDev”
 },
 {160, 160, 180, 268},
 CheckBox {
 enabled,
 “undoDev”
 },
 {40, 282, 69, 368},
 CheckBox {
 enabled,
 “cutDev”
 },
 {70, 282, 100, 367},
 CheckBox {
 enabled,
 “copyDev”
 },
 {100, 282, 127, 369},
 CheckBox {
 enabled,
 “pasteDev”
 },
 {130, 282, 154, 374},
 CheckBox {
 enabled,
 “clearDev”
 },
 {160, 282, 184, 365},
 CheckBox {
 enabled,
 “cursorDev”
 },
 {8, 8, 33, 278},
 StaticText {
 disabled,
 “Mark Boxes to Disable cdev Messages:”
 }
 }
};

resource ‘DITL’ (131) {
 { {106, 168, 126, 228},
 Button {
 enabled,
 “OK”
 },
 {7, 14, 98, 228},
 StaticText {
 disabled,
 “Warning: ^0”
 }
 }
};

resource ‘DITL’ (132) {
 { {80, 217, 100, 277},
 Button {
 enabled,
 “OK”
 },
 {12, 51, 32, 238},
 StaticText {
 disabled,
 “cdev Shell for Pascal”
 },
 {48, 52, 68, 235},
 StaticText {
 disabled,
 “© 1989 by J. Peter Hoddie”
 }
 }
};

resource ‘CNTL’ (-4048, purgeable) {
 {26, 122, 43, 170},
 0,
 visible,
 1,
 0,
 radioButProcUseWFont,
 0,
 “Show”
};

resource ‘MENU’ (128, “Apple Menu”) {
 1,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 apple,
 { “About it...”, noIcon, noKey, noMark, plain,
 “-”, noIcon, noKey, noMark, plain
 }
};

resource ‘MENU’ (129, “Files”) {
 2,
 textMenuProc,
 0x7FFFFFFB,
 enabled,
 “File”,
 { “Open”, noIcon, “O”, noMark, plain,
 “Close”, noIcon, “W”, noMark, plain,
 “-”, noIcon, noKey, noMark, plain,
 “Quit”, noIcon, “Q”, noMark, plain
 }
};

resource ‘MENU’ (130, “Edit”, preload) {
 3,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 “Edit”,
 { “Undo”, noIcon, “Z”, noMark, plain,
 “-”, noIcon, noKey, noMark, plain,
 “Cut”, noIcon, “X”, noMark, plain,
 “Copy”, noIcon, “C”, noMark, plain,
 “Paste”, noIcon, “V”, noMark, plain,
 “Clear”, noIcon, noKey, noMark, plain
 }
};

resource ‘MENU’ (131, “Options”) {
 4,
 textMenuProc,
 allEnabled,
 enabled,
 “Options”,
 { “Msg Masks...”, noIcon, noKey, noMark, plain,
 “Force Update”, noIcon, noKey, noMark, plain
 }
};

resource ‘MBAR’ (256) {
 { 128,
 129,
 130,
 131
 }
};

resource ‘ALRT’ (-16000, purgeable) {
 {48, 128, 188, 368},
 -15998,
 {
 OK, visible, silent,
 OK, visible, silent,
 OK, visible, silent,
 OK, visible, silent
 }
};

resource ‘ALRT’ (130, “Fatal Error”) {
 {56, 126, 238, 410},
 130,
 { OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1
 }
};

resource ‘ALRT’ (131, “Warning Error”) {
 {54, 134, 192, 378},
 131,
 { OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1
 }
};

data ‘msks’ (128) {
 $”00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
 };

resource ‘WIND’ (128, “Other Window”) {
 {38, 388, 80, 510},
 documentProc,
 visible,
 noGoAway,
 0x0,
 “OtherWindow”
};

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links... | Read more »
Price of Glory unleashes its 1.4 Alpha u...
As much as we all probably dislike Maths as a subject, we do have to hand it to geometry for giving us the good old Hexgrid, home of some of the best strategy games. One such example, Price of Glory, has dropped its 1.4 Alpha update, stocked full... | Read more »
The SLC 2025 kicks off this month to cro...
Ever since the Solo Leveling: Arise Championship 2025 was announced, I have been looking forward to it. The promotional clip they released a month or two back showed crowds going absolutely nuts for the previous competitions, so imagine the... | Read more »
Dive into some early Magicpunk fun as Cr...
Excellent news for fans of steampunk and magic; the Precursor Test for Magicpunk MMORPG Crystal of Atlan opens today. This rather fancy way of saying beta test will remain open until March 5th and is available for PC - boo - and Android devices -... | Read more »
Prepare to get your mind melted as Evang...
If you are a fan of sci-fi shooters and incredibly weird, mind-bending anime series, then you are in for a treat, as Goddess of Victory: Nikke is gearing up for its second collaboration with Evangelion. We were also treated to an upcoming... | Read more »
Square Enix gives with one hand and slap...
We have something of a mixed bag coming over from Square Enix HQ today. Two of their mobile games are revelling in life with new events keeping them alive, whilst another has been thrown onto the ever-growing discard pile Square is building. I... | Read more »
Let the world burn as you have some fest...
It is time to leave the world burning once again as you take a much-needed break from that whole “hero” lark and enjoy some celebrations in Genshin Impact. Version 5.4, Moonlight Amidst Dreams, will see you in Inazuma to attend the Mikawa Flower... | Read more »
Full Moon Over the Abyssal Sea lands on...
Aether Gazer has announced its latest major update, and it is one of the loveliest event names I have ever heard. Full Moon Over the Abyssal Sea is an amazing name, and it comes loaded with two side stories, a new S-grade Modifier, and some fancy... | Read more »
Open your own eatery for all the forest...
Very important question; when you read the title Zoo Restaurant, do you also immediately think of running a restaurant in which you cook Zoo animals as the course? I will just assume yes. Anyway, come June 23rd we will all be able to start up our... | Read more »
Crystal of Atlan opens registration for...
Nuverse was prominently featured in the last month for all the wrong reasons with the USA TikTok debacle, but now it is putting all that behind it and preparing for the Crystal of Atlan beta test. Taking place between February 18th and March 5th,... | Read more »

Price Scanner via MacPrices.net

AT&T is offering a 65% discount on the ne...
AT&T is offering the new iPhone 16e for up to 65% off their monthly finance fee with 36-months of service. No trade-in is required. Discount is applied via monthly bill credits over the 36 month... Read more
Use this code to get a free iPhone 13 at Visi...
For a limited time, use code SWEETDEAL to get a free 128GB iPhone 13 Visible, Verizon’s low-cost wireless cell service, Visible. Deal is valid when you purchase the Visible+ annual plan. Free... Read more
M4 Mac minis on sale for $50-$80 off MSRP at...
B&H Photo has M4 Mac minis in stock and on sale right now for $50 to $80 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses: – M4 Mac mini (16GB/256GB): $549, $50 off... Read more
Buy an iPhone 16 at Boost Mobile and get one...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering one year of free Unlimited service with the purchase of any iPhone 16. Purchase the iPhone at standard MSRP, and then choose... Read more
Get an iPhone 15 for only $299 at Boost Mobil...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering the 128GB iPhone 15 for $299.99 including service with their Unlimited Premium plan (50GB of premium data, $60/month), or $20... Read more
Unreal Mobile is offering $100 off any new iP...
Unreal Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering a $100 discount on any new iPhone with service. This includes new iPhone 16 models as well as iPhone 15, 14, 13, and SE... Read more
Apple drops prices on clearance iPhone 14 mod...
With today’s introduction of the new iPhone 16e, Apple has discontinued the iPhone 14, 14 Pro, and SE. In response, Apple has dropped prices on unlocked, Certified Refurbished, iPhone 14 models to a... Read more
B&H has 16-inch M4 Max MacBook Pros on sa...
B&H Photo is offering a $360-$410 discount on new 16-inch MacBook Pros with M4 Max CPUs right now. B&H offers free 1-2 day shipping to most US addresses: – 16″ M4 Max MacBook Pro (36GB/1TB/... Read more
Amazon is offering a $100 discount on the M4...
Amazon has the M4 Pro Mac mini discounted $100 off MSRP right now. Shipping is free. Their price is the lowest currently available for this popular mini: – Mac mini M4 Pro (24GB/512GB): $1299, $100... Read more
B&H continues to offer $150-$220 discount...
B&H Photo has 14-inch M4 MacBook Pros on sale for $150-$220 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – 14″ M4 MacBook Pro (16GB/512GB): $1449, $150 off MSRP – 14″ M4... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.