Frame in Dialogs and other Dialog things

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

Frame in Dialogs and other Dialog things

Post by zabros2020 » Fri Oct 23, 2009 5:13 am

Hi Guys,

Firstly thank you so much for a very helpful forum. My previous two queries were answered brilliantly as well as promptly. Marcus even updated the blog page with what seemed to be a much discussed topic.
Furthermore, my current issue has had at least 75% of it resolved through posts on this forum already.

Now, onto my current issue (if you don't mind)

I have build Dialog boxes that listen to events, and blank out fields depending on other fields and hide and show... the works so thank you.
2 things i cannot do yet are:

1. I am unable to have a frame. A frame to encapsulate certain things on my dialog. At the moment one very dodgy work around i have is to put a radio group, leave the caption section blank and then put my contents on top of it, but I am not comfortable with this solution and would love some suggestions to others.

2. When i put a radio group with multi buttons, they always appear vertically i.e.
option 1
option 2
option 3
etc....

How can i get them to appear side by side? i.e.
option 1 option2 option3 etc...

Thanks guys!

P.S. this is what I am trying to replicate
Image

Also, using the code below, I am able to grey out a field depending on another field. But MS seems to only grey out the text. So when there is no text in the fie3ld tha is being greyed out, it is not visible that a field is greying out. Another facinitating thing i fould was once i clicked on the greyed out field, the area which triggers the greying out, automatically changes to allow editing.. Its great but i am not sure how it works

Code: Select all


Dialog>ApplicantDetailOneDialog
   Caption=Personal Information
   Width=296
   Height=391
   Top=130
   Left=257
   RadioGroup=rgExitingCust,Existing Customer,16,15,217,82,No%CRLF%Yes,0
   Label=ID,144,40,true
   Edit=txtboxID,101,58,121,
   Label=Title,16,128,true
   ComboBox=cbTitle,96,128,145,Mr%CRLF%Mrs%CRLF%Miss%CRLF%Ms%CRLF%Dr
   Label=First Name,16,172,true
   Edit=txtboxFirstName,96,173,121,
   Label=Middle Name,16,200,true
   Edit=txtboxMiddleName,96,204,121,
   Label=Surname,16,236,true
   Edit=txtboxSurname,96,237,121,
   Label=DOB,16,264,true
   ComboBox=cbDOBday,96,272,41,DD%CRLF%1%CRLF%2%CRLF%3%CRLF%4%CRLF%5%CRLF%6%CRLF%7%CRLF%8%CRLF%9%CRLF%10%CRLF%11%CRLF%12%CRLF%13%CRLF%14%CRLF%15%CRLF%16%CRLF%17%CRLF%18%CRLF%19%CRLF%20%CRLF%21%CRLF%22%CRLF%23%CRLF%24%CRLF%25%CRLF%26%CRLF%27%CRLF%28%CRLF%29%CRLF%30%CRLF%31
   ComboBox=cbDOBmonth,144,272,41,MM%CRLF%1%CRLF%2%CRLF%3%CRLF%4%CRLF%5%CRLF%6%CRLF%7%CRLF%8%CRLF%9%CRLF%10%CRLF%11%CRLF%12
   ComboBox=cbDOByear,192,272,85,YYYY%CRLF%2009%CRLF%2008%CRLF%2007%CRLF%2006%CRLF%2005%CRLF%2004%CRLF%2003%CRLF%2002%CRLF%2001%CRLF%2000%CRLF%1999%CRLF%1998%CRLF%1997%CRLF%1996%CRLF%1995%CRLF%1994%CRLF%1993%CRLF%1992%CRLF%1991%CRLF%1990%CRLF%1989%CRLF%1988%CRLF%1987%CRLF%1986%CRLF%1985%CRLF%1984%CRLF%1983%CRLF%1982%CRLF%1981%CRLF%1980%CRLF%1979%CRLF%1978%CRLF%1977%CRLF%1976%CRLF%1975%CRLF%1974%CRLF%1973%CRLF%1972%CRLF%1971%CRLF%1970%CRLF%1969%CRLF%1968%CRLF%1967%CRLF%1966%CRLF%1965%CRLF%1964%CRLF%1963%CRLF%1962%CRLF%1961%CRLF%1960
   Button=&Cancel,16,313,75,25,3
   Button=&Next,132,312,75,25,1
EndDialog>ApplicantDetailOneDialog

OnEvent>DIALOG_CHANGE,ApplicantDetailOneDialog,rgExitingCust,rgExitingCustSRT

SRT>rgExitingCustSRT
     GetDialogAction>ApplicantDetailOneDialog,r
     If>%ApplicantDetailOneDialog.rgExitingCust%=Yes
        LibFunc>user32,EnableWindow,lfres,ApplicantDetailOneDialog.txtboxID.HANDLE,1
     Else
        LibFunc>user32,EnableWindow,lfres,ApplicantDetailOneDialog.txtboxID.HANDLE,0
     EndIf
END>rgExitingCustSRT
//Non-Modal Dialog
Show>ApplicantDetailOneDialog
Label>ActionLoop
    GetDialogAction>ApplicantDetailOneDialog,r
    If>{(%r%=2) OR (%r%=3)},Exit
    If>r=1,NextSRT
    Wait>0.3
Goto>ActionLoop
Label>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 Oct 24, 2009 4:44 am

See the remarks. Hope this is more or less what you're looking for.

Code: Select all

Dialog>ApplicantDetailOneDialog
   Caption=Personal Information
   Width=298
   Height=391
   Top=152
   Left=18
   RadioGroup=rgExitingCust,Existing Customer,48,23,185,90,,-1
   Label=ID,176,48,true
   Edit=txtboxID,77,74,121,
   Label=Title,16,144,true
   ComboBox=cbTitle,96,144,145,Mr%CRLF%Mrs%CRLF%Miss%CRLF%Ms%CRLF%Dr
   Label=First Name,16,188,true
   Edit=txtboxFirstName,96,189,121,
   Label=Middle Name,16,216,true
   Edit=txtboxMiddleName,96,220,121,
   Label=Surname,16,252,true
   Edit=txtboxSurname,96,253,121,
   Label=DOB,16,280,true
   ComboBox=cbDOBday,96,288,41,DD%CRLF%1%CRLF%2%CRLF%3%CRLF%4%CRLF%5%CRLF%6%CRLF%7%CRLF%8%CRLF%9%CRLF%10%CRLF%11%CRLF%12%CRLF%13%CRLF%14%CRLF%15%CRLF%16%CRLF%17%CRLF%18%CRLF%19%CRLF%20%CRLF%21%CRLF%22%CRLF%23%CRLF%24%CRLF%25%CRLF%26%CRLF%27%CRLF%28%CRLF%29%CRLF%30%CRLF%31
   ComboBox=cbDOBmonth,144,288,41,MM%CRLF%1%CRLF%2%CRLF%3%CRLF%4%CRLF%5%CRLF%6%CRLF%7%CRLF%8%CRLF%9%CRLF%10%CRLF%11%CRLF%12
   ComboBox=cbDOByear,192,288,85,YYYY%CRLF%2009%CRLF%2008%CRLF%2007%CRLF%2006%CRLF%2005%CRLF%2004%CRLF%2003%CRLF%2002%CRLF%2001%CRLF%2000%CRLF%1999%CRLF%1998%CRLF%1997%CRLF%1996%CRLF%1995%CRLF%1994%CRLF%1993%CRLF%1992%CRLF%1991%CRLF%1990%CRLF%1989%CRLF%1988%CRLF%1987%CRLF%1986%CRLF%1985%CRLF%1984%CRLF%1983%CRLF%1982%CRLF%1981%CRLF%1980%CRLF%1979%CRLF%1978%CRLF%1977%CRLF%1976%CRLF%1975%CRLF%1974%CRLF%1973%CRLF%1972%CRLF%1971%CRLF%1970%CRLF%1969%CRLF%1968%CRLF%1967%CRLF%1966%CRLF%1965%CRLF%1964%CRLF%1963%CRLF%1962%CRLF%1961%CRLF%1960
   Button=&Cancel,16,329,75,25,3
   Button=&Next,132,328,75,25,1
   CheckBox=msCheckBox1,No,84,48,48,True
   CheckBox=msCheckBox2,Yes,161,48,48,False
   ProgressBar=msProgressBar1,40,23,201,3,0
   ProgressBar=msProgressBar2,40,118,201,3,0
   ProgressBar=msProgressBar3,40,23,3,97,0
   ProgressBar=msProgressBar4,238,23,3,97,0
EndDialog>ApplicantDetailOneDialog

//Can't use the next line if using the Manage Checkbox function because 
//it uses the same Dialog_Change OnEvent.
//OnEvent>DIALOG_CHANGE,ApplicantDetailOneDialog,rgExitingCust,rgExitingCustSRT

SRT>rgExitingCustSRT
     GetDialogAction>ApplicantDetailOneDialog,r
     If>%ApplicantDetailOneDialog.msCheckBox2%=True
        LibFunc>user32,EnableWindow,lfres,ApplicantDetailOneDialog.txtboxID.HANDLE,1
        SetDialogObjectColor>ApplicantDetailOneDialog,txtboxid,16777215
       SetDialogObjectFocus>ApplicantDetailOneDialog,txtboxid
     Else
        LibFunc>user32,EnableWindow,lfres,ApplicantDetailOneDialog.txtboxID.HANDLE,0
        SetDialogObjectColor>ApplicantDetailOneDialog,txtboxid,13882323
        Let>ApplicantDetailOneDialog.msCheckBox1=True
        ResetDialogAction>ApplicantDetailOneDialog
     EndIf
END>rgExitingCustSRT

//Non-Modal Dialog
Show>ApplicantDetailOneDialog

//Using a radiogroup for a frame border is perfectly fine,  I've also
//used progress bars and below is a DrawLine sub that I've posted before.
//A caveate for using drawline is that the lines can be erased by minimising
//the dialog or moving it off screen or placing another window over the
//top of the dialog.  This can be fixed by taking a screen shot of the dialog
//and then replacing the drawn lines with the resulting image. 
GoSub>DrawLine,ApplicantDetailOneDialog.handle,4,0,35,18,246,18
GoSub>DrawLine,ApplicantDetailOneDialog.handle,4,0,35,123,246,123
GoSub>DrawLine,ApplicantDetailOneDialog.handle,4,0,35,18,35,123
GoSub>DrawLine,ApplicantDetailOneDialog.handle,4,0,246,18,246,123

//Run going in to set the edit box color to gray if the "No" checkbox
//is defaulted to "True"
GoSub>rgExitingCustSRT

//Replaced the radio group "Yes/No" with checkboxes.  The following sub
//executes a function created to prevent more than one checkbox at a time
//in a specified group from being checked.
GoSub>ManageCheckBox,1,2,ApplicantDetailOneDialog,msCheckBox

Label>ActionLoop
    GetDialogAction>ApplicantDetailOneDialog,r
    If>{(%r%=2) OR (%r%=3)},Exit
    If>r=1,NextSRT
    //Next line required for Manage Checkbox function
    GoSub>MouseClickFlagTimer1
    Wait>0.03
Goto>ActionLoop
Label>Exit

/*
Usage
GoSub>ManageCheckBox,FirstCheckBox number,LastCheckBox number,DialogName,CheckBoxName
e.g. GoSub>ManageCheckBox,3,6,Dialog1,msCheckBox
Add a line GoSub>MouseClickFlagTimer3 to the main idle loop
for each set of check boxes being managed
*/
SRT>ManageCheckBox
  Let>WriteCounter=%ManageCheckBox_var_1%-1
  Let>EraseCounter=%ManageCheckBox_var_1%-1
  Let>MFile=%temp_dir%ManageCheckBoxes%ManageCheckBox_var_1%~.scp

  Let>IFile=MFile
  Let>MouseClickFlag%ManageCheckBox_var_1%=0

  IfFileExists>MFile
    DeleteFile>MFile
  EndIf

  WriteLn>MFile,wres,Let>MouseClickFlag%ManageCheckBox_var_1%=0
  Repeat>WriteCounter
    Add>WriteCounter,1
      WriteLn>MFile,wres,OnEvent>DIALOG_CHANGE,%ManageCheckBox_var_3%,%ManageCheckBox_var_4%%WriteCounter%,ManageCheckBox%WriteCounter%
      WriteLn>MFile,wres,SRT>ManageCheckBox%WriteCounter%
        WriteLn>MFile,wres,  If>MouseClickFlag%ManageCheckBox_var_1%=0
        WriteLn>MFile,wres,    GetDialogAction>%ManageCheckBox_var_3%,res1
        WriteLn>MFile,wres,    Let>tempvalue=%ManageCheckBox_var_3%.%ManageCheckBox_var_4%%WriteCounter%
        WriteLn>MFile,wres,    Let>MCBkk%WriteCounter%=%EraseCounter%
        WriteLn>MFile,wres,    Repeat>MCBkk%WriteCounter%
        WriteLn>MFile,wres,    Let>testval=MCBkk%WriteCounter%
        WriteLn>MFile,wres,      Add>MCBkk%WriteCounter%,1
        WriteLn>MFile,wres,      Let>MCBkkk=MCBkk%WriteCounter%
        WriteLn>MFile,wres,      Let>%ManageCheckBox_var_3%.%ManageCheckBox_var_4%%MCBkkk%=False
        WriteLn>MFile,wres,    Until>MCBkk%WriteCounter%,%ManageCheckBox_var_2%
        WriteLn>MFile,wres,    Let>%ManageCheckBox_var_3%.%ManageCheckBox_var_4%%WriteCounter%=%tempvalue%
        WriteLn>MFile,wres,    ResetDialogAction>%ManageCheckBox_var_3%
        WriteLn>MFile,wres,    Let>MouseClickFlag%ManageCheckBox_var_1%=1
        WriteLn>MFile,wres,  EndIf
        WriteLn>MFile,wres,  GoSub>rgExitingCustSRT
      WriteLn>MFile,wres,END>ManageCheckBox%WriteCounter%
      WriteLn>MFile,wres,
  Until>WriteCounter,%ManageCheckBox_var_2%
  WriteLn>MFile,wres,SRT>MouseClickFlagTimer%ManageCheckBox_var_1%
  WriteLn>MFile,wres,  If>MouseClickFlag%ManageCheckBox_var_1%>0
  WriteLn>MFile,wres,    Add>MouseClickFlag%ManageCheckBox_var_1%,1
  WriteLn>MFile,wres,    If>MouseClickFlag%ManageCheckBox_var_1%>10
  WriteLn>MFile,wres,      Let>MouseClickFlag%ManageCheckBox_var_1%=0
  WriteLn>MFile,wres,    EndIF
  WriteLn>MFile,wres,  EndIf
  WriteLn>MFile,wres,END>MouseClickFlagTimer%ManageCheckBox_var_1%
  Wait>0.1
  Include>%MFile%
END>ManageCheckBox

//DrawLine Usage:
//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd
SRT>DrawLine
  LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
  LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
  LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
  Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
  LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
  LibFunc>gdi32,DeleteObject,DOres,Penres
  LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine

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