CompuServe Thread

#List in Dialog

5 messages in this thread
#7179From: Darren WilliamsJul 19, 1993 10:35 PM
To Technical support I am having difficulty creating a list box in a modal dialog box using THINK C. According to the THINK reference example a call is made to SetDItem with a handle to a user procedure. From this user procedure a call is made to setup the list box and a final call is made to SetDItem with a handle to the List. After a call to ModalDialog the dialog box is drawn correctly but is unstable. If the dialog box is moved (ie. movable modal dialog) the program crashes with a type 3 error. If another dialog is opened over the existing one a similar error results. Close inspection with the debugger reports an illegal instruction. SetDItem appears to cause the problem. According to THINK reference it appears to be related to a pointer problem but everything seems to be in order. Has anybody got any ideas what the problem might be, I have run out of ideas? Any Help appreciated, Darren Williams.
#7195From: Steve StockmanJul 20, 1993 4:01 AM
Darren: I think the example in Think Ref is bad. In main(), item 3 is set to be a userItem with draw procedure UserProc. In UserProc(), the list is built and drawn into the rectangle properly, and then item 3 is set to be a userItem with draw procedure theList (???). But theList is a ListHandle! Your crash is occurring when the dialog is moved or obscured because the Dialog Mgr tries to update it, including calling the userItem procedure, which happens not to be a procedure in this case. Illegal instruction is not a surprise. Instead, when creating the dialog, go ahead and build the list right then, saving the ListHandle in a global, and set the item to userItem with a draw procedure that does nothing but GetDItem() / FrameRect() / LUpdate(). If the item rect is fixed or in a global, you don't even need the GetDItem. The first call to ModalDialog will force the update, and the list will be drawn properly and remain stable. Steve
#7311From: Darren WilliamsJul 21, 1993 4:37 PM
Thanks, Steve, That seemed to solve the problem. Darren
#7237From: Spec BowersJul 20, 1993 7:00 PM
Darren, Even if the instructions in THINK Reference were correct, it's only half the solution. You need a user draw procedure (the easy part). You also need a dialog filter proc (ther harder part). (The following is a commercial announcement…) The fastest and easiest way to implement a list in a dialog is to use AppMaker. You just point and click to design your dialog with a list, a popup menu, or any of the standard dialog elements. AppMaker creates the appropriate resources, then generates excellent source code to implement your design. You can read the code to learn Mac programming techniques. A demo version of AppMaker is in MacDev, Lib 13, keywords "AppMaker" and "Demo". Spec Bowers Bowers Development (developers of AppMaker)
#7312From: Darren WilliamsJul 21, 1993 4:38 PM
Thanks, Spec I'll have a look at AppMaker. Darren