Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: Dialog problems in DA Message-ID: <47695@apple.Apple.COM> Date: 3 Jan 91 03:41:06 GMT References: <4927@tellab5.tellabs.com> Organization: Apple Computer Inc., Cupertino, CA Lines: 36 kenk@sunHd.tellabs.com (Ken Konecki) writes: >I'm having trouble getting dialogs to work inside of a desk accessory. I >keep the item list as an owned resource and do a GetResource() call to get >a handle to it. When I create the dialog, I use NewDialog() and pass the >handle of the item list obtained from GetResource() as the item list >parameter. I do the dialogging and then call CloseDialog() at the end of >the routine. Everything works as I expect it to but only on the first time >I bring up the dialog. The second time I try, I get an address error and >get dropped into Macsbug. Stepping through the routine with Macsbug, I've >found that the call to NewDialog() returns a valid dialog record, but the >control list is NIL. As you would expect, the first time through the >routine, the control list of the dialog window is not NIL. This is of >course why it the routine bombs the second time but not the first. The big >question is: Why is the control list NIL the second time I call >NewDialog()? > >I have enclosed the offending routine at the end of this post. The desk >accessory I'm writing is a simple calendar display. The dialog is used to >set the month and year that is being displayed. I'm using Think C 4.0 on a >Mac SE. > > [code snippet deleted] I guess my first question would be "why aren't you just using a dialog template (DLOG) as well as the item list (DITL)?". You can then just call GetNewDialog() which will return a non-nil pointer if everything is setup OK. I don't know exactly why your way is failing, but this seems a whole lot simpler... steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen | Apple Computer, Inc. | Disclaimer: | 20525 Mariani Ave, MS-81CS | the above may be stevec@apple.com | Cupertino, CA 95014 | a lie...or not.