delphi - How to create a dialog at runtime and get a return value? -


i want create dialog current form class, , expect value dialog.

this sample coding.

with tformclass(findclass('tf_dialog_partner')).create(application)   try     showmodal;     value := dialogpublicvar;   except     free;    end; 

dialogpublicvar public variable of tf_dialog_partner (tform's descendant) class, right in coding current class doesn't use tf_dialog_partner's unit in uses clause, use findclass function, can create new form fine.

this coding error because current class not aware of tf_dialog_partner's attributes, doesn't recognize dialogpublicvar.

please help, how make current class aware of dialogpublicvar.

thanks everyone.

if value being returned integer, simple option have showmodal() return value. when dialog ready close, can set modalresult property desired value, , showmodal() return value.

otherwise, can change variable published property of class, , use rtti access via functions available in typinfo.pas unit.

another option define interface in shared unit form class implements, interface declares method form overrides retrieve value. rest of code can query dialog interface via supports() function , call exposed method.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -