goodill_eric@tandem.com (Eric Goodill) (06/29/91)
Hi, My original question was how do user items get redrawn when the dialog manager redraws the rest of a modal dialog. There are two general answers. 1: Install a drawing procedure for the user item. The handle that you pass with setDItem for a user item is in fact a pointer to a drawing routine. IM-1 touches on this briefly, but tech note 34 goes into some detail. The dialog manager calls your routine when it redraws the other parts of the dialog. 2: Use a modal dialog filter proc and handle the update events. If you've got a user item that responds to mouse clicks (such as a list), then you almost for sure have a filter proc. This proc gets all events that the dialog window gets before the dialog manager applies its standard filter proc. Since the dialog is a window, it gets activate and update events. You can respond to the update event by drawing your user item. BTW, user items seem to be a good way to draw the default button ring around the OK button. So much for the summary. I've gotten the code working, but in so doing a few new questions popped up. My user item is a list using Apple's list manager. I noted the following peculiar behavior. If I didn't do a call to getDItem on the list user item, then when I called lUpdate in my filter proc (during an update event and passing dialogPtr^.visRgn), nothing got drawn. I did not have to make a call to setDItem. The getDItem is done even before the showWindow after reading the dialog in. It used to be used when I had a list item drawing routine instead of responding to update events. When I switched from a drawing proc to update events, I had left the drawing proc code in but just commented out the body of the proc. All was well. Then, convinced the new scheme worked, I removed the getDItem, setDItem pair and the drawing proc. Then updates stopped working. The list was just blank always. I put the getDItem, setDItem pair back in and the drawing proc. Then I removed the setDItem. Updates worked again. I then removed the drawing proc (cuz it's not getting called) and it still worked. I removed the getDItem, and updates stopped working. So I'm puzzled. Use Macsbug, I know I was getting the correct activate and update events. The update regions for the dialog window were not empty. There were a simple box enclosing the whole window. I'm using THINK Pascal 3.0. IIci. 6.0.5. Any ideas? Eric Goodill, goodill_eric@tandem.com, Cupertino, California "Sucks Syntax" -- John Haskey
peterc@Sugar.NeoSoft.com (Peter Creath) (06/29/91)
You always have to use GetDItem when you're playing with controls, since Mac needs a ControlHandle -- not a resource ID. GetDItem(dialog,resourceID,&dType,&dItem,&dRect); From then on you use dItem as your ControlHandle. resourceID means nothing to any Toolbox routines except pointing to the item within the resource. But that can't be used directly... --