How can I Re-use a Dialog with radio button

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
Kreop
Newbie
Posts: 6
Joined: Thu Jun 24, 2010 11:24 am
Location: Denmark

How can I Re-use a Dialog with radio button

Post by Kreop » Thu Jun 24, 2010 11:36 am

I have tried to make a survey fore a customer but when i re-use the same dialog boxes it will not clear the box from the last massages.
I have 4 different Dialogs with 2 to 5 questions.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu Jun 24, 2010 1:12 pm

Here is one way to do it using the older style dialog method.

Code: Select all

Dialog>MyDialog
   Caption=This is my Survey
   Width=364
   Height=294
   Top=146
   Left=66
   Button=Exit Macro,61,224,100,30,2
   RadioGroup=msRadioGroup1,Sex,40,32,113,97,Male%CRLF%Female%CRLF%Other,-1
   Button=Reset Selections,192,224,107,33,4
EndDialog>MyDialog


Label>MainLoop
  Show>MyDialog,result
  If>result=2,End
  If>result=4,ResetSelections
  Wait>0.01
Goto>MainLoop

SRT>ResetSelections
   Let>MyDialog.msRadioGroup1.ItemIndex=-1
END>ResetSelections

Label>End

Kreop
Newbie
Posts: 6
Joined: Thu Jun 24, 2010 11:24 am
Location: Denmark

Post by Kreop » Thu Jun 24, 2010 1:30 pm

Thanks, but I need to be able to change the text inside the radiobuttons when I re-use it. See this

Code: Select all

Let>line1=Male1
Let>line2=Female1
Let>line3=Other1
Let>capline=This is my survey

Dialog>MyDialog
   Caption=%capline%
   Width=364
   Height=294
   Top=146
   Left=66
   Button=Exit Macro,61,224,100,30,2
   RadioGroup=msRadioGroup1,Sex,40,32,113,97,%line1%%CRLF%%line2%%CRLF%%line3%,-1
   Button=Reset Selections,192,224,107,33,4
EndDialog>MyDialog


Label>MainLoop
  Show>MyDialog,result
  If>result=2,End
  If>result=4,ResetSelections
  Wait>0.01
Goto>MainLoop

SRT>ResetSelections
   Let>MyDialog.msRadioGroup1.ItemIndex=-1
END>ResetSelections
ResetDialogAction>MyDialog
Label>End



//second time

Let>line1=Male2
Let>line2=Female2
Let>line3=Other2
Let>capline=This is my survey2

Label>MainLoop2
  Show>MyDialog,result
  If>result=2,End2
  If>result=4,ResetSelections2
  Wait>0.01
Goto>MainLoop2

SRT>ResetSelections2
   Let>MyDialog.msRadioGroup1.ItemIndex=-1
END>ResetSelections2

Label>End2

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Thu Jun 24, 2010 1:45 pm

I don't have version 12 with the new dialogs so I can't test this, however I believe to do what you requested requires version 12 and using the new feature of SetDialogProperty. See below.
SetDialogProperty>DialogName,ObjectName,PropertyName,NewValue

Sets the value of an object's property. To access properties of the dialog itself leave ObjectName blank.

To see a list of available property names edit the dialog in the Dialog Designer and select the control. The property names are displayed in the Properties grid. Where the property type is a list (i.e. can have more than one value), specify each item delimited by commas within square brackes (e.g. [biSystemMenu, biMaximize]). Look at the properties grid in the Dialog Designer to see existing property values for an example. Note that in the properties grid you are presented with a drop down box with checkboxes, indicating that more than one item can be chosen. Some properties can take one of a set number of values. In the Dialog Designer properties grid you will see all available options in a drop down box for the property concerned.

See also: GetDialogProperty

Abbreviation: SDP

Example:

SetDialogProperty>Dialog1,Memo1,Text,Hello World

Kreop
Newbie
Posts: 6
Joined: Thu Jun 24, 2010 11:24 am
Location: Denmark

Post by Kreop » Thu Jun 24, 2010 2:23 pm

Okay, perhaps I should just opgrade then.
I'm at version 11.1.13 and can't find that command in this.

Thank you for the quick response..


adroege wrote:I don't have version 12 with the new dialogs so I can't test this, however I believe to do what you requested requires version 12 and using the new feature of SetDialogProperty. See below.
SetDialogProperty>DialogName,ObjectName,PropertyName,NewValue

Sets the value of an object's property. To access properties of the dialog itself leave ObjectName blank.

To see a list of available property names edit the dialog in the Dialog Designer and select the control. The property names are displayed in the Properties grid. Where the property type is a list (i.e. can have more than one value), specify each item delimited by commas within square brackes (e.g. [biSystemMenu, biMaximize]). Look at the properties grid in the Dialog Designer to see existing property values for an example. Note that in the properties grid you are presented with a drop down box with checkboxes, indicating that more than one item can be chosen. Some properties can take one of a set number of values. In the Dialog Designer properties grid you will see all available options in a drop down box for the property concerned.

See also: GetDialogProperty

Abbreviation: SDP

Example:

SetDialogProperty>Dialog1,Memo1,Text,Hello World

User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jun 24, 2010 3:33 pm

Under version 11 you could use the SetDialogObjectVisible> function. Just make duplicates of the objects you want to show differently then use SetDialogObjectVisible> to control their visibility and thus their availability. Depending on how large and complex your dialog, it might be easier to simply use multiple dialogs. OR as adroege suggested, upgrade to version 12 and use SetDialogProperty>. Then it gets very easy to make object changes.

Code: Select all

Let>line1=Male1
Let>line2=Female1
Let>line3=Other1
Let>capline=This is my survey

//second time

Let>line11=Male2
Let>line12=Female2
Let>line13=Other2
Let>capline2=This is my survey2

Dialog>MyDialog
   Caption=%capline%
   Width=364
   Height=294
   Top=146
   Left=66
   Button=Exit Macro,61,224,100,30,2
   RadioGroup=msRadioGroup1,Sex,40,32,113,97,%line1%%CRLF%%line2%%CRLF%%line3%,-1
   RadioGroup=msRadioGroup2,Sex,40,32,113,97,%line11%%CRLF%%line12%%CRLF%%line13%,-1
   Button=Reset Selections,192,224,107,33,4
   Button=Reset Selections,192,224,107,33,5
EndDialog>MyDialog

SetDialogObjectVisible>MyDialog,msRadioGroup2,0
SetDialogObjectVisible>MyDialog,msButton3,0


Label>MainLoop
  Show>MyDialog,result
  If>result=2,End
  If>result=4,ResetSelections
  If>result=5,ResetSelections2
  Wait>0.01
Goto>MainLoop

SRT>ResetSelections
   Let>MyDialog.msRadioGroup1.ItemIndex=-1
   SetDialogObjectVisible>MyDialog,msRadioGroup2,1
   SetDialogObjectVisible>MyDialog,msButton3,1
   SetDialogObjectVisible>MyDialog,msRadioGroup1,0
   SetDialogObjectVisible>MyDialog,msButton2,0
   LibFunc>user32,SetWindowTextA,res,MyDialog.Handle,%capline2%
END>ResetSelections

Label>End


SRT>ResetSelections2
   Let>MyDialog.msRadioGroup2.ItemIndex=-1
   SetDialogObjectVisible>MyDialog,msRadioGroup2,0
   SetDialogObjectVisible>MyDialog,msButton3,0
   SetDialogObjectVisible>MyDialog,msRadioGroup1,1
   SetDialogObjectVisible>MyDialog,msButton2,1
   LibFunc>user32,SetWindowTextA,res,MyDialog.Handle,%capline%
END>ResetSelections2



Kreop
Newbie
Posts: 6
Joined: Thu Jun 24, 2010 11:24 am
Location: Denmark

Post by Kreop » Sat Jun 26, 2010 2:16 pm

Thanks everybody, I upgraded to version 12 and it worked.


JRL wrote:Under version 11 you could use the SetDialogObjectVisible> function. Just make duplicates of the objects you want to show differently then use SetDialogObjectVisible> to control their visibility and thus their availability. Depending on how large and complex your dialog, it might be easier to simply use multiple dialogs. OR as adroege suggested, upgrade to version 12 and use SetDialogProperty>. Then it gets very easy to make object changes.

Code: Select all

Let>line1=Male1
Let>line2=Female1
Let>line3=Other1
Let>capline=This is my survey

//second time

Let>line11=Male2
Let>line12=Female2
Let>line13=Other2
Let>capline2=This is my survey2

Dialog>MyDialog
   Caption=%capline%
   Width=364
   Height=294
   Top=146
   Left=66
   Button=Exit Macro,61,224,100,30,2
   RadioGroup=msRadioGroup1,Sex,40,32,113,97,%line1%%CRLF%%line2%%CRLF%%line3%,-1
   RadioGroup=msRadioGroup2,Sex,40,32,113,97,%line11%%CRLF%%line12%%CRLF%%line13%,-1
   Button=Reset Selections,192,224,107,33,4
   Button=Reset Selections,192,224,107,33,5
EndDialog>MyDialog

SetDialogObjectVisible>MyDialog,msRadioGroup2,0
SetDialogObjectVisible>MyDialog,msButton3,0


Label>MainLoop
  Show>MyDialog,result
  If>result=2,End
  If>result=4,ResetSelections
  If>result=5,ResetSelections2
  Wait>0.01
Goto>MainLoop

SRT>ResetSelections
   Let>MyDialog.msRadioGroup1.ItemIndex=-1
   SetDialogObjectVisible>MyDialog,msRadioGroup2,1
   SetDialogObjectVisible>MyDialog,msButton3,1
   SetDialogObjectVisible>MyDialog,msRadioGroup1,0
   SetDialogObjectVisible>MyDialog,msButton2,0
   LibFunc>user32,SetWindowTextA,res,MyDialog.Handle,%capline2%
END>ResetSelections

Label>End


SRT>ResetSelections2
   Let>MyDialog.msRadioGroup2.ItemIndex=-1
   SetDialogObjectVisible>MyDialog,msRadioGroup2,0
   SetDialogObjectVisible>MyDialog,msButton3,0
   SetDialogObjectVisible>MyDialog,msRadioGroup1,1
   SetDialogObjectVisible>MyDialog,msButton2,1
   LibFunc>user32,SetWindowTextA,res,MyDialog.Handle,%capline%
END>ResetSelections2



Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts