DlgSetPicture - Example

'This example uses the picture control and the DlgSetPicture command to dynamically change the picture.

Dim newPicturePath As String

Sub Main ()

    Begin Dialog myDialog 60, 60, 175, 150,"Test Dialog", .DialogFunc

        Text 10, 10, 50, 50, "Picture test.",0,.Text1

        Picture 60, 10, 75, 75, "d:\temp\test.bmp",0,.Picture1

        CancelButton 10, 85, 40, 12      

        OKButton 10, 100, 40, 12

    End Dialog

    ' Dialog returns -1 For OK, 0 For Cancel

    Dim Dlg1 As myDialog

    button = Dialog(Dlg1)

    If button = 0 Then Exit Sub

    If button = -1 Then

        MsgBox "We'll now change the picture dynamically."

        newPicturePath = inputbox("Type the path to a different .bmp file.")

        MsgBox "Changing picture to " & newPicturePath

        'DlgSetPicture "Picture1", newPath 'DlgSetPicture must called inside the Dialog Function defined by Begin Dialog statement

        Dialog Dlg1

    End If

End Sub

Function DialogFunc( ControlID$, Action%, SuppValue%)

  Select Case Action

    Case 1 ' Dialog box initialization

     If Not newPicturePath = "" Then

        DlgSetPicture "Picture1", newPicturePath,0

     End If

  End Select

  DialogFunc = True 'Do Not Exit the Dialog

End Function