Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialog box control question 1

Status
Not open for further replies.

finitesimian

Programmer
Feb 11, 2006
29
US
I was wondering if it was possible to create a dialog box that creates controls based on a variable?

I am trying to write a macro that
1. Reads data from an Area Object
2. Generates multiple checkboxes based on the data

In this example, I've made a script that reads the screen vertically to see how many rows have something written on them, and ignores blank rows:
Code:
        Dim input1 as object
        set input1 = Sess.screen.area(9,2,21,2)
        Dim input2 As String
        input2 = rtrim(input1)
        Dim numberofrows As Integer
        numberofrows =  len(input2)

After it returns numberofrows, I want to to make a dialog box with a matching number of checkboxes.


BTW- the easy way to do this is to use a listbox control/array, but the problem here is that I need to be able to select more than one choice.

Thanks in advance.


 
This should point you in the right direction.
Code:
Dim iChkers
Function FileDlgFunc(identifier$, action, suppvalue)
    Select Case action
    Case 1
        For i = DlgControlID("Chk1") to DlgControlID("Chk12")
            j = j + 1
            If j > iChkers Then DlgVisible i,0
        Next

    Case 2

    End Select
End Function

Sub Main
    iChkers = 7
    Begin Dialog ChkDlg 100, 120, "Checkboxes", .FileDlgFunc
        CheckBox 5, 5, 40, 12, "Box 1", .Chk1
        CheckBox 5, 20, 40, 12, "Box 2", .Chk2
        CheckBox 5, 35, 40, 12, "Box 3", .Chk3
        CheckBox 5, 50, 40, 12, "Box 4", .Chk4
        CheckBox 5, 65, 40, 12, "Box 5", .Chk5
        CheckBox 5, 80, 40, 12, "Box 6", .Chk6
        CheckBox 55, 5, 40, 12, "Box 7", .Chk7
        CheckBox 55, 20, 40, 12, "Box 8", .Chk8
        CheckBox 55, 35, 40, 12, "Box 9", .Chk9
        CheckBox 55, 50, 40, 12, "Box 10", .Chk10
        CheckBox 55, 65, 40, 12, "Box 11", .Chk11
        CheckBox 55, 80, 40, 12, "Box 12", .Chk12
        PushButton  5, 95, 40, 12, "OK", .ButOK
        CancelButton  55, 95, 40, 12, .ButCcl
    End Dialog

    Dim MyDlg as ChkDlg
    On Error Resume Next
    Dialog MyDlg
End Sub
 
I have one more question about textbox controls in dialog boxes.

Is it possible to place a default line of text in a textbox control?


One example of this would be a password box that retains the last user's name (and possibly password). When the user executes the macro a second time, the name is already written in the appropriate textbox.

I know how to store the string/variable-- I just need to know (if possible) to display it within the textbox control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top