[comp.sys.mac.programmer] Set/GetDItem

dawyd@gargoyle.uchicago.edu (David Walton) (08/21/89)

In article <58078@tut.cis.ohio-state.edu> Scott Sutherland <sas@cis.ohio-state.edu> writes:

>The problem with this is that SetDItem (which places the item in the given
>dialog's item list) pre-supposes that the item is NOT already in the list.
>Unless I am misunderstanding you, you already have the item in your list, 
>if not at first then at least when it is time to move the TE field offscreen.
>
>Also see the note on IM I page 422 (just below the description of SetDItem)
>that says "Do not use SetDItem...to change or move a control."  

Ummmm...I'm confused.  Actually, Scott, I think you are. :-)  Get/SetDItem
presupposes that the item in question IS in the list, because they use the
index of the item in the list (the item number) to access it (this is
how GetDItem is able to return a handle to the item).  Perhaps I'm
misunderstanding what you wrote, but it sounds like what you're saying
is that SetDItem installs a new item in the item list.

As to changing or moving controls: IM I-422 says to not change or move
the SETTING of a control (i.e., dials, stuff like that).  What that
means is that you should use the Control Manager calls to change the
settings of controls (by coercing the itemhandles returned by GetDItem
to controlhandles).  And editText and statText items, I believe,are
not technically controls.  Anyway, I used Get/SetDItem to hide two
editText items before I noticed HideDItem and had no problems.  (Of
course, maybe the other bugs in the code were so much more obvious
that I just didn't notice...;-)

David
-- 

David Walton		Internet: dawyd@tartarus.UChicago.EDU
U. Chicago Computer	{  Any opinions are my own, not those	}
Science Macintosh Lab	{  of my employers (or anybody else). 	}

zben@umd5.umd.edu (Ben Cranston) (08/22/89)

In article <456@gargoyle.uchicago.edu> dawyd@gargoyle.uchicago.edu.UUCP (David Walton) writes:

> As to changing or moving controls: IM I-422 says to not change or move
> the SETTING of a control (i.e., dials, stuff like that).  What that
> means is that you should use the Control Manager calls to change the
> settings of controls (by coercing the itemhandles returned by GetDItem
> to controlhandles)...

I believe some complex controls (like scroll bars) have precomputed regions
associated with them (like the thumb region).  If so, it would not be a good
idea to try to move the control by using SetDItem to change the control's
rectangle.  I always tested for the control bit and called MoveControl.
I would quote some code but when I went back to look at that app I evidently
dropped my own code in favor of using the HideDItem/ShowDItem suite...

> ...And editText and statText items, I believe,are not technically controls.

As I read IM, this are correct, so the original poster's problem must have
been something else.
-- 
Sig     DS.L    ('ZBen')       ; Ben Cranston <zben@umd2.UMD.EDU>
* Computer Science Center Network Infrastructures Group
* University of Maryland at College Park