Dialog pre-populate bizarre occurance

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

Dialog pre-populate bizarre occurance

Post by zabros2020 » Fri Nov 06, 2009 6:07 am

Hi Guys,

More from me about dialogs, the help in this forum has been so good in terms of achieving so much with dialogs.

I am now trying to prepopulate en edit box with a variable Let>number=123456789.

However this is affecting my combo box. It is quite bizzare.

Here is my code. Run it, see how the edit box does not pre-populate.
Then uncomment the one line and see how the edit box is pre-populated but the combo box changes.

PLease help, i am at your mercy.

Code: Select all

Let>Number=123456789
Dialog>TestDialog
   Caption=Activation Details
   Width=313
   Height=274
   Top=120
   Left=493
   Max=0
   Min=0
   Close=0
   Resize=0
   RadioGroup=msRadioGroup1,msRadioGroup1,12,5,285,172,,-1
   CheckBox=CB1,Check Box 1,18,29,114,True
   CheckBox=CB3,Check Box 3,18,70,114,True
   CheckBox=CB2,Check Box 2,168,29,158,True
   ComboBox=ComboBox1,18,125,111,1000%CRLF%2000%CRLF%3000%CRLF%4000
   Label=Label 1,19,111,true
   Button=&Cancel,68,197,75,25,3
   Button=&Next,168,197,75,25,1
   Edit=msEdit1,168,88,121,
   Edit=MyEdit,5,22,230
   Label=Label 2,168,70,true
EndDialog>TestDialog
OnEvent>DIALOG_CHANGE,TestDialog,CB3,CB3SRT
SRT>CB3SRT
    GetDialogAction>TestDialog,r

    If>%TestDialog.CB3%=False
        Let>TestDialog.CB3.itemindex=3
        ResetDialogAction>TestDialog
        LibFunc>user32,EnableWindow,lfres,TestDialog.ComboBox1.HANDLE,0
    Else
        Let>TestDialog.CB3.itemindex=0
        ResetDialogAction>TestDialog
        LibFunc>user32,EnableWindow,lfres,TestDialog.ComboBox1.HANDLE,1
    EndIf
END>CB3SRT

//Activation Information Dialog
Show>TestDialog
Let>TestDialog.msEdit1=%Number%

Remark>IF you comment out the line below, the combo box works fine but the text field is not
Remark>prepopulated with 123456789 (%Number%)
Remark>If you Uncomment this line, the field is populated but something strange happens
Remark>to the combo box

//THIS IS THE LINE
//ResetDialogAction>TestDialog

Label>TestDialog_ActionLoop
    GetDialogAction>TestDialog,r

    If>r=1
        MDL>Go to the next screen
        GoTo>TestDialog_Exit
    EndIf
    If>{(%r%=2) OR (%r%=3)}
        Goto>Final_Exit
    EndIf
    Wait>0.3
Goto>TestDialog_ActionLoop

Label>TestDialog_Exit
CloseDialog>TestDialog
Label>Final_Exit


Loving MS's Capabilities!!!

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

Post by JRL » Sat Nov 07, 2009 3:05 am

See the remarks.

Code: Select all

Let>Number=123456789
Dialog>TestDialog
   Caption=Activation Details
   Width=313
   Height=274
   Top=0
   Left=493
   Max=0
   Min=0
   Close=0
   Resize=0
   RadioGroup=msRadioGroup1,msRadioGroup1,12,5,285,172,,-1
   CheckBox=CB1,Check Box 1,18,29,114,True
   CheckBox=CB3,Check Box 3,18,70,114,True
   CheckBox=CB2,Check Box 2,168,29,158,True
   ComboBox=ComboBox1,18,125,111,1000%CRLF%2000%CRLF%3000%CRLF%4000
   Label=Label 1,19,111,true
   Button=&Cancel,68,197,75,25,3
   Button=&Next,168,197,75,25,1
   Edit=msEdit1,168,88,121,
   Edit=MyEdit,5,22,230,
   Label=Label 2,168,70,true
EndDialog>TestDialog
OnEvent>DIALOG_CHANGE,TestDialog,CB3,CB3SRT
SRT>CB3SRT
    GetDialogAction>TestDialog,r

    If>%TestDialog.CB3%=False
        Let>TestDialog.CB3.itemindex=3
        ResetDialogAction>TestDialog
        LibFunc>user32,EnableWindow,lfres,TestDialog.ComboBox1.HANDLE,0
    Else
        Let>TestDialog.CB3.itemindex=0
        ResetDialogAction>TestDialog
        LibFunc>user32,EnableWindow,lfres,TestDialog.ComboBox1.HANDLE,1
    EndIf
END>CB3SRT

//Activation Information Dialog
Show>TestDialog

Remark>IF you comment out the line below, the combo box works fine but the text field is not
Remark>prepopulated with 123456789 (%Number%)
Remark>If you Uncomment this line, the field is populated but something strange happens
Remark>to the combo box

//THIS IS THE LINE
//Its all about timing.  GetDialogAction> sets the dialog variables
//as you had this you were resetting the dialog variables before
//their values were established.
//1st
GetDialogAction>TestDialog,r
//2nd
Let>TestDialog.msEdit1=%Number%
//3rd
ResetDialogAction>TestDialog

Label>TestDialog_ActionLoop
    GetDialogAction>TestDialog,r

    If>r=1
        MDL>Go to the next screen
        GoTo>TestDialog_Exit
    EndIf
    If>{(%r%=2) OR (%r%=3)}
        Goto>Final_Exit
    EndIf
    Wait>0.3
Goto>TestDialog_ActionLoop

Label>TestDialog_Exit
CloseDialog>TestDialog
Label>Final_Exit




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