[comp.sys.mac.programmer] How to write WDEFs

sdh@flash.bellcore.com (Stephen D Hawley) (03/14/90)

I tried to mail this but it bounced.
Here's what you need to do to write a WDEF:

Create a new THINK C Project, set the project type to be WDEF.
Set the resource number to something nice for you.

The main should look like this:

pascal long main(varCode, theWindow, message, param)
short varCode;
WindowPtr theWindow;
short message;
long param;
{

	/*
	 * This is probably the most straight forward approach
	 * to implement the function.
	 * return a long as appropriate for each part of the
	 * window.
	 */
	switch (message) {
	case wDraw:
		break;
	case wHit:
		break;
	case wCalcRgns:
		break;
	case wNew:
		break;
	case wGrow:
		break;
	case wDrawGIcon:
		break;
	}
}

Fill in the blanks as you need, and compile it into a WDEF with "Build Code
Resource".

To debug, write a small project that creates a bunch of windows (using the
resource number you specified before, allowing for variation codes etc) and
lets you do all the playing with them.  Then make sure you WDEF is put into
a file called whatevermysmallprojectiscalled.rsrc where
"whatevermysmallprojectiscalled" is the name of the small shell application.

When you want to start using it in a real program, use ResEdit to copy it
into your project's resource file, or use the Merge option in Think C to
merge it into your project.

Check out the Think C manual (4.0 p. 84-86) for more details.

Good Luck!
Steve Hawley


A noun's a special kind of word.
It's ev'ry name you ever heard.
I find it quite interesting,
A noun's a person place or thing.

6600pete@ucsbuxa.ucsb.edu (GurgleKat [Pete Gontier]) (03/15/90)

From article <20919@bellcore.bellcore.com>, by sdh@flash.bellcore.com (Stephen D Hawley):
> To debug, write a small project that creates a bunch of windows (using the
> resource number you specified before, allowing for variation codes etc) and
> lets you do all the playing with them.

Heck, I just merge the thing into DA Handler in the System Folder. I just have
to find a DA (or ANY piece of software) that uses altDBoxProc and I'll be
set...
--
             Pete Gontier, Kiwi Software; Kiwi's opinions not presented here
                          Editor, Macker, the Online Mac Programming Journal
InterNet 6600pete@ucsbuxa.ucsb.edu; BitNet 6600pete@ucsbuxa; AppleLink D0862