comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: how to exchange variable between modal dialog and the main window?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: how to exchange variable between modal dialog and the main window? [message #48065 is a reply to message #48064] Tue, 21 March 2006 06:40 Go to previous message
Ricardo Bugalho is currently offline  Ricardo Bugalho
Messages: 22
Registered: March 2005
Junior Member
Hello,
I'm not familiar with the GUI builder but you need to use each widget's
UVALUE to keep a reference to the information you want to keep arround.
Let's assume your dialog reads a number and a string. I could do it like
this:

PRO OnPress,event
MyVars = { name: "", number: 0 }
; This dynamic variable will hold all the field
; I care about the dialog
MyVarsPtr = PTR_NEW(MyVars)
DlgGUI, MyVarsPtr, group_leader=event.top
; Now the data is acessible
IF (*MyVarsPtr).name EQ "John Smith" THEN ...
END

PRO DlgGUI, varsPtr, GROUP_LEADER=gl
dlgTLB = WIDGET_BASE(GROUP_LEADER=gl, /MODAL)
...
nameField = WIDGET_TEXT(dlgTlb, $
UVALUE=varsPtr, $
EVENT_PRO="dlggui_name")
...
numberField = WIDGET_TEXT(dlgTlb, $
UVALUE=varsPtr, $
EVENT_PRO="dlggui_number")
...
WIDGET_CONTROL, dlgTlb, /REALIZE
END

PRO dlggui_name, event
; Update the name field
WIDGET_CONTROL, event.id, GET_VALUE=name
WIDGET_CONTROL, event.id, GET_UVALUE=ptr
(*ptr).name = name
END

PRO dlggui_number,event
; Update the numnber field
WIDGET_CONTROL, event.id, GET_VALUE=numberStr
WIDGET_CONTROL, event.id, GET_UVALUE=ptr
number = 0
READS, numberStr, number
(*ptr).number = number
END


A better way to do it is to wrap it in a class, like this:

PRO OnPress,event
dlg = OBJ_NEW('DLGGUI', GROUP_LEADER=event.top)
myVars = dlg->getVars()
OBJ_DESTROY,dlg
END

FUNCTION DLGGUI::INIT,GROUP_LEADER=gl
self.tlb = WIDGET_BASE(GROUP_LEADER=gl, /MODAL)
...
nameWidget = WIDGET_TEXT(self.tlb, $
UVALUE={object:self, method:'onNameEvent})
...
numberWidget = CW_FIELD(self.tlb, /INTEGER, $
UVALUE={object:self, method:'onNumberEvent})
...
WIDGET_CONTROL,self.tlb,/REALIZE
RETURN,1
END

PRO DLGGUI::onNameEvent,event
WIDGET_CONTROL,event.id, GET_VALUE=name
self.name = name
END

PRO DLGGUI::onNameEvent,event
WIDGET_CONTROL,event.id, GET_VALUE=name
self.name = name
END

PRO DLGGUI::onNumberEvent,event
WIDGET_CONTROL, event.id, GET_VALUE=number
self.number = number
END

FUNCTION DLGGUI::GetVars
RETURN,{name:self.name, number:self.number}
END

PRO DLGGUI__DEFINE
strcut = { DLGGUI, $
tlb: 0L, $
name: "", $
number: 0 $
}
END

PRO EVENT_HANDLER, event
; Event dispatcher for all my widgets
Widget_Control, event.id, GET_UVALUE=msg
IF event.top EQ 0 THEN top = event.id ELSE top = event.top
CALL_METHOD, msg.method, msg.object, event
END


On Mon, 2006-03-20 at 23:52 -0800, lindows wrote:
> I'm doing a project,about image processing.But I don't know how to how
> to exchange variable between modal dialog and the main window.I can't
> find more material about the message exchanging in IDL windows.Could
> someone can help me?
> Now I use the GUIBuilder,in main window,put a button and make a
> procedure like this:
>
> pro OnPress,event
> dlggui,group_leader=event.top
> end
>
> dlggui is another procedure,with
> files:dlggui.pro,dlggui_event.pro,dlg_gui.prc.
>
> I don't know how I can transfer a variable or point A from main window
> to dlggui,I want to change the value of dlggui,in main program.
>
> thanks.
>
[Message index]
 
Read Message
Read Message
Previous Topic: Re: How do I reduce active memory used by program?
Next Topic: Re: How to debug seg fault.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 09:26:07 PDT 2025

Total time taken to generate the page: 0.24057 seconds