Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!indri!nic.MR.NET!umn-cs!mmm!mbrady From: mbrady@mmm.UUCP (Mark W. Brady) Newsgroups: comp.sys.mac.programmer Subject: OpenCPort Keywords: GrafPorts OpenCPort Message-ID: <1244@mmm.UUCP> Date: 22 Mar 89 15:06:49 GMT Lines: 44 I am having problems with a call to OpenCPort. In particular, it is causing my mac to crash. The relevant code segment looks like: { Initialize for offscreen pixel map. } devHandle := NewGDevice( LongInt(-1), LongInt(-1) ); IF devHandle = GDHandle(0) THEN SysBeep(5); SetDeviceAttribute( DevHandle, 0, TRUE ); { sets gdDevType (ie 0) to color } devHandle^^.gdType := 2; { direct color device } WITH devHandle^^.gdPMap^^ DO BEGIN rowBytes := 4*640; SetRect( bounds, 0, 0, 640, 480 ); pmVersion := 0; packType := 1; packSize := 0; hRes := 72; { This is just a guess!!! } vRes := 72; { This is just a guess!!! } pixelType := 16; pixelSize := 32; cmpCount := 3; cmpSize := 8; planeBytes := 0; pmTable := CTabHandle(0); pmReserved := 0 END; { WZ1 } saveDevice := GetGDevice; SetGDevice( devHandle ); offPort := CGrafPtr( NewPtr( SizeOf( CGrafPtr ) ) ); Debugger; OpenCPort( offPort ); SetGDevice( saveDevice ); The crash occurs at the call to OpenCPort. As you may know, OpenCPort creates a port for the current device. I am setting the current device to one used as an off screen pix map. This may be a wierd device but it is probably not my problem since when I delete the call to SetGDevice ( hence allowing the screen be the device ) I still get a crash? Does anyone have some experience here which could shed some light on this problem? Another question regarding this code segment: what meaning do vRes and hRes have in an off screen pix map? Thanks for your advice.