Ken.Knight@f421.n109.z1.fidonet.org (Ken Knight) (01/10/91)
I'm sorry this is so long, but I'm stuck. This code has 2 problems. The first seems to have just appeared and , of course,I can't figure out what I changed to cause it. #1: A bus error that seems to happen when the filterproc exits. This filterproc LOOKS the same to me as when things seemed to run fine. #2 This dialog contains 4 items: an OK button with its user item outline;a statText field; and another user item that is supposed to be a popup menu. The popup menu shouldcontain a list of all the resources in a already opened res- ource file (like the dialog you get when using Sound Mover to open any file at all).Getting the resource type is easy enough by using Get1IndType (), but that returns a ResType valued param which is, according to the Types.h file (MPW C though I suppose it's the same for Think) an Unsigned long. Just doing the AppendMenu() call I have is producing crud. How do I add the items with the proper names? Thanks, as always, in advance. REMEMBER GET OTHERS TO PROOF YOUR CODE (caps intended) it can save your much agony - I know. ;-) ResType GetResType() { int i;Str255 itemChosen; short itemHit; DialogPtr theDialog;GrafPtr tempPort; ResType tempType;short iT;Handle iH; Rect iR; GetPort(&tempPort); theDialog = GetNewDialog(rResTypeDialog,nil,(WindowPtr) -1); if (theDialog != nil) { .. set up user items.. gResTypeMenu = NewMenu(kResMenu,kResTitle); if (gResTypeMenu != nil) { for (i=1;i<=Count1Types();i++) { Get1IndType(&tempType,i); AppendMenu(gResTypeMenu,(Str255)tempType); } /* for */ MyItems(theDialog,kPopUpItem); ShowWindow(theDialog); do { ModalDialog((ModalFilterProcPtr)ResTypeFilter,&itemHit); } while (itemHit != kOKItem); ....other stuff in function } pascal Boolean ResTypeFilter (DialogPtr theDialog, EventRecord *theEvent, short *itemHit) { Point aPoint; int chosen;short iT, whichItem;Handle iH;Rect iR; aPoint = theEvent->where; GlobalToLocal(&aPoint); whichItem = FindDItem(theDialog,aPoint) + 1; GetDItem(theDialog,kHelpItem, &iT, &iH, &iR); switch (theEvent->what) { case mouseDown: if (whichItem == kPopUpItem) { InsertMenu(gResTypeMenu, -1); chosen = PopUpMenuSelect(gResTypeMenu,iR.top,iR.left, gResTypeChosen); DeleteMenu(kResMenu); if (chosen != 0) { gResTypeChosen = LoWord(chosen); EraseRect(&iR); MyItems(theDialog,kPopUpItem); *itemHit = kPopUpItem; return true; } /* if */ } else return false; break; default: return false; /* default return value */ break; } /* switch on theEvent->what */ } pascal void MyItems(DialogPtr theDialog, short itemHit) /* User item routine. */ { Str255 tempString;short iT;Handle iH;Rect iR; GetDItem(theDialog, itemHit, &iT, &iH, &iR); switch (itemHit) { case kPopUpItem: GetItem(gResTypeMenu,gResTypeChosen,tempString); InsetRect(&iR,-1,-1);FrameRect(&iR); MoveTo(iR.right,iR.top+2);LineTo(iR.right,iR.bottom); LineTo(iR.left+2,iR.bottom); MoveTo(iR.left+leftEdge,iR.bottom-bottomEdge); DrawString(tempString); break; } /* switch on itemHit */ } /* MyResTypeItem */ -- Ken Knight, Ken.Knight@f421.n109.z1.fidonet.org via The Black Cat's Shack's FidoNet<->Usenet Gateway blkcat.fidonet.org and Fidonet 1:109/401