Re: Modal dialog - returning values [message #43169 is a reply to message #43162] |
Mon, 21 March 2005 06:03  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Dave Roberts writes:
> Have read lots of solutions to this problem but none seem to apply? Im
> new so forgive me.
> Here is my code
>
> pro Create_Images, Event
> Image_Create,GROUP_LEADER=Event.top
> end
>
> (Image_Create brings up a modal dialog box that was created using the
> automatic IDL gui generation i.e. I put the buttons on and it wrote the
> Image_Create.pro and Image_Create_eventcb.pro for me)
>
> Ive read I can store a pointer in the top level but have already got
> something stored there - the code below shows what I put there
>
> imagestore=CREATE_STRUCT(imagestore,'invertedsmallarray',inv ertedsmallarray)
> wDraw=WIDGET_INFO(Event.top,FIND_BY_UNAME='Draw')
> WIDGET_CONTROL,wDraw,SET_UVALUE=imagestore
>
> Therefore if I put a pointer in the top level base will I loose
> imagestore?
No, because imagestore is not stored in the the top-level base. It is
stored in the user value of the draw widget.
> I have a modal dialog box that just returns a float so i used a COMMOM
> block (but believe this is not advisable). I cant do this now beacuse
> I want to return an array (structure) generated in the modal dialog.
>
> Also should I be storing stuff as above - it was the only way I found I
> could pass information around my gui program (i.e. between procedures)
No, common blocks are NOT the preferred solution in widget programs,
because by using them you automatically restrict yourself to just one
copy of the program running at any one time.
Generally, information in widget programs is passed around by creating
an "info" or "state" structure containing all the information needed
to run the program. The info structure (or sometimes a pointer to the
info structure) is typically stored in the user value of the top-level
base, but only because this widget is easy to find (event.top always
points to it). You can store it in any convenient location.
You can find some examples of modal dialog widgets on my web page:
http://www.dfanning.com/programs/textbox.pro
http://www.dfanning.com/programs/selectimage.pro
You won't be able to find anything written with the GUI Builder,
however. The best way to write widget programs is to find a good book
on the subject. I know of at least one. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|