Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!sas From: sas@tut.cis.ohio-state.edu (Scott Sutherland) Newsgroups: comp.sys.mac.programmer Subject: Re: Moving a Textedit field in a modal dialog Message-ID: <58078@tut.cis.ohio-state.edu> Date: 21 Aug 89 15:07:02 GMT References: <15088@dartvax.Dartmouth.EDU> <21428@cup.portal.com> Reply-To: Scott Sutherland Organization: Ohio State University Computer and Information Science Lines: 53 In article <21428@cup.portal.com> ts@cup.portal.com (Tim W Smith) writes: >I've got a modal dialog that sometimes needs a textedit field. >So I made a textedit field that was offscreen. When it was time >to use it I GetDItem'ed it and SetDItem'ed it to the place I wanted >it to appear. 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." >That worked fine. It showed up and could be used. All was well >in the land. > >Then I wanted to move it away. I GetDItem'ed it and SetDItem'ed it >to Siberia ( actually, somewhere off to the left of the screen ). Luckily there is a really easy way to do this. Simply call HideDItem. (see IM IV page 59) This will move the item offscreen, deactivate it, erase the items rect and add the rect to the update region. When you want it back, call ShowDItem. You might try starting with the TE item in place and the dialog initially invisible. Then if you want the item offscreen initially, simply cHideDItem before you call ShowWindow. >It did not go away. Does anyone have any idea why I can't move it >around like this? I also can't move it to other places on the screen. > >For the curious, when confronted with this, I said "intercourse >SetDItem" and switched to using a filter function in the dialog. >When text needs to be edited, I just TENew the record myself >where I want it, and handle it all myself from the filter function. >When I'm done, I dispose of it. This seems to work great. > >Is there anything wrong with this approach? While this approach will work, it really makes life harder for you in the longrun. In general, I try not to do anything in my filterProc that I can do in the body of my code. Handling things in the filter often adds alot of unneeded complexity to your code making it harder to debug and update. Hope this helps. I think I spent the better part of a week trying to figure this stuff out before I stumbled over HideDItem and ShowDItem in IM IV. Oh well :-} --- Scott Sutherland sas@cis.ohio-state.edu Staff Software Developer The Ohio State University, Department of Dance