franco@bbn.com (Frank A. Lonigro) (04/15/88)
OK! I give up!! Thanks to all who responded to my initial plea for info on how to drag icon's in a window. I was given the suggestion to use DragGreyRgn() to drag an icon. Well I got that to work and I have it down pat, but now I want to be able to "limit" where the Icon can be draged to using the limitRect and slopeRect parameters of DragGreyRgn. According to the documentation for DragGreyRgn(), the slopeRect should totaly encompus the limitRect. If while draging the region the mouse moves out of limitRect(but inside of slopeRect) the grey outline becomes pinned to the edge of limitRect. I can't get this to work! And, if the mouse moves outside of slopeRect, the grey outline disapears and if the mouse button is let up at this point a value of 0x8000 is returned by DragGreyRgn(), so if you test for that return value and it occurs, then you should not move the region. Well, I test for this and my Icon always disapears. Following is some sample code to show you what I am doing, what could be wrong???????????? >>>>>>> Please remember what's to follow is just some code fragments <<<<<<<< Rect limitR, slopeR, windowR; Handle icon; RgnHandle iconRgn; Rect iconR; MakeIcon() { HideCursor(); iconRgn = NewRgn(); OpenRgn(); SetRect(&iconR, 100, 100, 132, 132); FrameRect(&iconR); CloseRgn(iconRgn); icon = GetIcon(0); PlotIcon(&iconR, icon); ShowCursor(); } /* MakeIcon() */ DragRgn(region) RgnHandle region; { RgnHandle tmpRgn; long upMouse; int dv, dh; tmpRgn = NewRgn(); CopyRgn(region, tmpRgn); upMouse = DragGrayRgn(region, theEvent.where, &limitR, &slopeR, 0, NIL); if (upMouse != 0x8000L) { dv = HiWord(upMouse); dh = LoWord(upMouse); EraseRect(&iconR); OffsetRgn(tmpRgn, dh, dv); OffsetRect(&iconR, dh, dv); PlotIcon(&iconR, icon); } CopyRgn(tmpRgn, region); DisposeRgn(tmpRgn); } /* DragRgn() */ /* check the mouse down event */ case inContent : /* hilite window */ HiliteWindow(whichWindow, TRUE); if (PtInRgn(theEvent.where, iconRgn)) DragRgn(iconRgn); break; /* initialize the main window and limiting rectangles */ SetRect(&windowR, 10, 45, 502, 342); theWindow = NewWindow(&theWindowRec, &windowR, "\07Hi Mom!", TRUE, noGrowDocProc, (WindowPtr) -1, TRUE, 0); SetRect(&slopeR, 45, 65, 311, 331); SetRect(&limitR, 50, 70, 306, 326); FrameRect(&limitR); >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Any and all help would be greatly appreciated!!! Thanks, -franco franco@bbn.com franco%bbn.com@relay.cs.net ...!harvard!bbn!franco