🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #23255

Question about WDEF routines.

#23255
From: Michael Domino
Date: Sat, 02 Jan 1988 23:10
68 lines
2452 bytes
In volume 2 of The Complete MacTutor, page 287 there is an article about
creating WDEF routines.  I would like to be able to do that, so I came
up with the following code that doesn't work, using the article as a
guide.  If I fill in the ProcID field in ResEdit with one of the standard
WDEFs, and comment out everything but the call to GetNewWindow,I get a
window just fine.

Can someone tell me what's wrong, please?  This is all in Lightspeed C.

main()
{
  WindowPtr w;

    ...usual init stuff...
        
        /* The window is created invisible. */          
        w = GetNewWindow(windowID, NULL, (WindowPtr)(-1L));
        (WindowPeek)w->windowDefProc = NewHandle(0L);
        *((WindowPeek)w->windowDefProc) = (Ptr)WindowDef;
        ShowWindow(w);  

     ...event loop stuff...
}

/* I just want a simple window def right now, one that just draws a frame. */
pascal long WindowDef(varCode, theWindow, message, param)
int varCode, message;
WindowPtr theWindow;
long param;
{
  Rect r;
                 
   switch(message)
  {
         case wDraw:
           r = (**((WindowPeek)theWindow->strucRgn)).rgnBBox;
           PenNormal();
           FrameRect(&r);
           InsetRect(&r, 1, 1);
           EraseRect(&r);
           break;
         case wHit:
           break;
         case wCalcRgns:
           break;
         case wNew:
           break;
         case wDispose:
           break;
         case wGrow:
           break;
         case wDrawGIcon:
           break;          
   }       
   return 0L;
}

And while we're on the subject, it says in Inside Mac that the window
definition id passed as a parameter to NewWindow (or set with ResEdit
for GetNewWindow) has the resource id of the WDEF in the upper 12 bits
and a variation code in the lower 4 bits.  This does not seem to jive
with the ids of the standard windows given on page 273 of IM, vol 1,
which are all very small numbers.  What's going on here?


Michael Domino @ SUNY/Buffalo

internet: domino@cs.buffalo.edu
Technical Details
Message-ID: <7595@sunybcs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!hao!boulder!sunybcs!domino

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!hao!boulder!sunybcs!domino
From: domino@sunybcs (Michael Domino)
Newsgroups: comp.sys.mac
Subject: Question about WDEF routines.
Message-ID: <7595@sunybcs.UUCP>
Date: 2 Jan 88 23:10:49 GMT
Sender: nobody@sunybcs.UUCP
Reply-To: domino@sunybcs.UUCP (Michael Domino)
Distribution: na
Organization: SUNY/Buffalo Computer Science
Lines: 68