hexagon logo

Dialog Box

I am making dialog boxes with Cypress Enable. Is there any way to insert a picture into a dialog box?

I'm looking to do something similar to what Marked Sets does, where I have a picture that is a button for the operator to click on. Is this even possible to do in Cypress Enable?
Parents
  • Is it me, or is the fileName variable never dim'd?

    Try dim it in the beginning of the script - not inside another sub, by dim'ing it 'outside' the subs it will make it 'global' - valid through the entire script:

    ' Bitmap sample using the Dir Function
    '=========================================================
    Sub DrawBitmapSample
    
    [COLOR="Red"]Dim MyFilename as string[/COLOR]
    
    Dim Filepath As String
    Dim ShortFilepath As String
    Dim results As String
    ShortFilepath = "C:\Windows\"
    Filepath = Shortfilepath + "*.bmp"
    
    
    Dim MyList()
      Begin Dialog BitmapDlg 60, 60, 290, 220, "Enable bitmap sample", .DlgFunc
        ListBox 10, 10, 80, 180, MyList(), .List1, 2
        Picture 100, 10, 180, 180, "Forest.bmp", 0, .Picture1
        CancelButton 42, 198, 40, 12
        OKButton 90, 198, 40, 12
      End Dialog
    
    Dim frame As BitmapDlg
    ' Show the bitmap dialog
    Dialog frame
    
    
    results = bitmapDlg.List1
    MsgBox results
    MsgBox fileName
    
    End Sub
    
    Function DlgFunc( controlID As String, action As Integer, suppValue As Integer)
      'DlgFunc = 1 ' Keep dialog active
      Select Case action
      	Case 1 ' Initialize
        	temp = Dir( "C:\Windows\*.bmp" )
        	count = 0
        	While temp <> ""
          		count = count + 1
          		temp = Dir
        	Wend
    
    		Dim x() As String
    		ReDim x(count)
    		x(0) = Dir( "C:\Windows\*.bmp" )
    
    		For i = 1 To count
      			x(i) = Dir
      		Next i
    
    		DlgListBoxArray "List1", x()
    		'results = fileName
     	 Case 2 ' Click
      		fileName = ShortFilepath & DlgText("List1")
    
    [COLOR="red"]MyFilename = filename[/COLOR]
    [COLOR="red"]MsgBox MyFilename ' for debugging[/COLOR]
    
      		DlgSetPicture "Picture1", fileName
      		results = fileName
      	
    	End Select
    End Function 
    
Reply
  • Is it me, or is the fileName variable never dim'd?

    Try dim it in the beginning of the script - not inside another sub, by dim'ing it 'outside' the subs it will make it 'global' - valid through the entire script:

    ' Bitmap sample using the Dir Function
    '=========================================================
    Sub DrawBitmapSample
    
    [COLOR="Red"]Dim MyFilename as string[/COLOR]
    
    Dim Filepath As String
    Dim ShortFilepath As String
    Dim results As String
    ShortFilepath = "C:\Windows\"
    Filepath = Shortfilepath + "*.bmp"
    
    
    Dim MyList()
      Begin Dialog BitmapDlg 60, 60, 290, 220, "Enable bitmap sample", .DlgFunc
        ListBox 10, 10, 80, 180, MyList(), .List1, 2
        Picture 100, 10, 180, 180, "Forest.bmp", 0, .Picture1
        CancelButton 42, 198, 40, 12
        OKButton 90, 198, 40, 12
      End Dialog
    
    Dim frame As BitmapDlg
    ' Show the bitmap dialog
    Dialog frame
    
    
    results = bitmapDlg.List1
    MsgBox results
    MsgBox fileName
    
    End Sub
    
    Function DlgFunc( controlID As String, action As Integer, suppValue As Integer)
      'DlgFunc = 1 ' Keep dialog active
      Select Case action
      	Case 1 ' Initialize
        	temp = Dir( "C:\Windows\*.bmp" )
        	count = 0
        	While temp <> ""
          		count = count + 1
          		temp = Dir
        	Wend
    
    		Dim x() As String
    		ReDim x(count)
    		x(0) = Dir( "C:\Windows\*.bmp" )
    
    		For i = 1 To count
      			x(i) = Dir
      		Next i
    
    		DlgListBoxArray "List1", x()
    		'results = fileName
     	 Case 2 ' Click
      		fileName = ShortFilepath & DlgText("List1")
    
    [COLOR="red"]MyFilename = filename[/COLOR]
    [COLOR="red"]MsgBox MyFilename ' for debugging[/COLOR]
    
      		DlgSetPicture "Picture1", fileName
      		results = fileName
      	
    	End Select
    End Function 
    
Children
No Data