Disable Options-Button in customized dialog

Disable Options-Button in customized dialog

Ralf_Krieg
Advisor Advisor
445 Views
1 Reply
Message 1 of 2

Disable Options-Button in customized dialog

Ralf_Krieg
Advisor
Advisor

Hello

 

I've created a customized Open-Dialog using thisapplication.createfiledialog. When the user selects a file (e.g a STEP-file), the Options-Button stays enabled. In the original Open-Dialog, this button is disabled when selecting a filetype without options for open.

Is there a way to disable this button according to the selected filetype?


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Accepted solutions (1)
446 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

No. Unfortunately, the Options button is specified to either be on or off when you specify the FileDialog, and selection of a file doesn't happen until after the dialog has been specified and launched.  However, whether you choose to have it visible or not, it will only contain options for which ever type of file you select, while the dialog is open.  For instance, when I the dialog is first launched, if I haven't one specific file type yet, clicking the visible Options button doesn't do anything.  It will only show something when you have a specific file single file type selected, then it will show you the options available for that type of file.  And the Options button is usually still visible, but just greyed out, when you specify it to not be available.  So if you have specified it to not be available, it will be greyed out and you can't use it, even after you have selected a file.

   Here's the iLogic code I use to launch an Inventor.FileDialog for opening Inventor files.

 

Dim oFileName As String
Dim oFileDialog As Inventor.FileDialog
ThisApplication.CreateFileDialog(oFileDialog)
oFileDialog.DialogTitle = "Browse To And Select A File."
oFileDialog.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
oFileDialog.Filter = "Inventor Files (*.iam;*.dwg;*.idw;*.ipt:*.ipn;*.ide) | *.iam;*.dwg;*.idw;*ipt;*.ipn;*.ide | All files (*.*)|*.*"
oFileDialog.MultiSelectEnabled = False
oFileDialog.OptionsEnabled = False
oFileDialog.CancelError = True
oFileDialog.InsertMode = False
On Error Resume Next
oFileDialog.ShowOpen
If Err.Number <> 0 Then
	MsgBox("Dialog was canceled. Exiting.", vbOKOnly, "CANCELED")
Else	
	If oFileDialog.FileName <> vbNullString Then
		oFileName = oFileDialog.FileName
		ThisApplication.Documents.Open(oFileName,True)
	Else
		MsgBox("No file was selected. Exiting.", vbOKOnly + vbExclamation, "FILE NOT SELECTED")
	End If
End If

 

It's very similar with a regular Windows Forms OpenFileDialog too, but it, obviously, doesn't know about the Options button, because its outside of Inventor.  But you can just change its filter settings to open any other type of files.

Here's the Windows forms version of the code:

 

Dim oFileName As String
Dim oOpenDlg As New System.Windows.Forms.OpenFileDialog
oOpenDlg.Title = "Browse To And Select A File."
oOpenDlg.InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath
oOpenDlg.Filter = "Autodesk Inventor Files (*.iam;*.dwg;*.idw;*.ipt:*.ipn;*.ide) | *.iam;*.dwg;*.idw;*ipt;*.ipn;*.ide | All files (*.*)|*.*"
oOpenDlg.Multiselect = False
oOpenDlg.RestoreDirectory = False
Dim oResult = oOpenDlg.ShowDialog
If oResult = vbOK Then
	If oOpenDlg.FileName <> vbNullString Then
		oFileName = oOpenDlg.FileName
	Else
		MsgBox("No file was selected. Exiting.", vbOKOnly + vbExclamation, "FILE NOT SELECTED")
	End If
ElseIf oResult = vbCancel Then
	MsgBox("The dialog was Canceled. Exiting.", vbOKOnly + vbInformation, "CANCELED")
End If

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes