[comp.sys.mac.programmer] *** What's wrong with this WDEF

hja@rhi.hi.is (Hjalti Kristgeirsson) (06/05/91)

Hello again,

I am having problem getting the colors to work right in my WDEF.
Included is the routine which is called when the draw message is received
by the WDEF. 
The question is why won't the colors work right in the part marked
!!!!!!!!!!!! why is this color wrong.

Any suggestions whould be fine.

void	DrawFrame(register short varCode, WindowPeek macWindow) {
	... other declarations
	RGBColor		dark={17476,17476,17476}, white={65535,65535,65535}, black={0,0,0},focolor, bacolor;
	short			color = isColor();
	CTabHandle		colors;
	GrafPtr			port;
	CGrafPtr		cport;
			
	GetPenState(&savePen);				/* Save the current pen state		*/

	if (color) {
		GetWMgrPort(&port);
		GetCWMgrPort(&cport);
		SetPort((GrafPtr)cport);
		BackPat(&port->bkPat);
		PenPat (&port->pnPat);
		cport->pnLoc	= port->pnLoc;
		cport->pnSize	= port->pnSize;
		cport->pnMode	= port->pnMode;
		cport->pnVis	= port->pnVis;
		cport->txFont	= port->txFont;
		cport->txFace	= port->txFace;
		cport->txMode	= port->txMode;
		cport->txSize	= port->txSize;
		GetForeColor(&focolor);
		GetBackColor(&bacolor);
	}

	... other drawing stuff

	GetDragBar(varCode, macWindow, &dragBar);
	PenSize(1, 1);						
	r = dragBar; 
	if (color)
		RGBBackColor(&dark);			
		InsetRect(&r, 2, 2);
		EraseRect(&r);		!!!!!!!!!!!! why is this color wrong
	}