hexiaoyao 在
IDL中自定义类和自定义组件 日志中写到:
IDL主要着重于数据处理方面,在界面方面不是很恰如人意,因此很多东西需要自己去写。用IDL开发多了,觉得有些东西还是做成类或者组件比较方便。
1、在自定义组件时通过函数调用,即程序一般以Function开头,编程和一般的窗体界面没什么大区别,主要是设置为有阻拦程序,同时具有函数返回值,在函数内部传递参数用指针比较方便,但是要注意指针的释放。
以下为一个我做得InputDialog的例子,
Pro IDLInputDialog_event,sEvent
widget_control,sEvent.top,get_uvalue=psState
widget_control,sEvent.id,get_uvalue=uval
case uval
of
'OK':begin
widget_control,(*psState).wInputText,get_value=strInput
if strlen(strtrim(strInput)) eq 0 then begin
re=dialog_message('输入文本不能为空',/information,title='注意')
widget_control,sEvent.top,set_uvalue=psState
return
endif
(*psState).strInput=strtrim(strInput)
widget_control,sEvent.top,set_uvalue=psState
widget_control,sEvent.top,/destroy
return
end
'Cancel':begin
widget_control,sEvent.top,set_uvalue=psState
widget_control,sEvent.top,/destroy
return
end
endcase
widget_control,sEvent.top,set_uvalue=psState
end
Function IDLInputDialog,group_leader=group_leader
if not
keyword_set(group_leader) then begin
wBase=widget_base(title='输入对话框',tlb_frame_attr=3,/column)
endif else
begin