How to disable the close icon of InputBox

How to disable the close icon of InputBox

Anonymous
Not applicable
1,910 Views
13 Replies
Message 1 of 14

How to disable the close icon of InputBox

Anonymous
Not applicable

I want to disable the icon when I use iLogic InputBox, could someone let me know how I can get this function?

0 Likes
Accepted solutions (1)
1,911 Views
13 Replies
Replies (13)
Message 2 of 14

Mark.Lancaster
Consultant
Consultant

@Anonymous

 

Programming questions and needs should be posted in the Inventor Customization forum for best results.  I will have the moderator relocate your posting there to better suit your needs.

 

https://forums.autodesk.com/t5/inventor-customization/bd-p/120

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes
Message 3 of 14

mcgyvr
Consultant
Consultant

Don't think you can..

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 4 of 14

Anonymous
Not applicable

You would need to create your own windows dialog to remove it.

 

However, depending on your reason for wanting to remove it, you can handle what you want to happen when the user clicks 'Cancel' using vbNullString

 

This example doesn't allow user to proceed without clicking OK

While myparam = vbNullString
	myparam = InputBox("Prompt", "Title", "Default Entry")
	If myparam = vbNullString
		MsgBox("no cancelling allowed")
	End If
End While

 

0 Likes
Message 5 of 14

Anonymous
Not applicable

Thanks, Mark

0 Likes
Message 6 of 14

Anonymous
Not applicable

Thanks Craig.

In fact, I used similar to catch this issue, but not successful. I can catch "Cancel" button.

I noticed following MessageBox commands could disable the "X" icon. If InputBox has similar, it will solve my problem.

MessageBox.Show("Message",'"Title", MessageBoxButtons.Ignore)
MessageBox.Show("Message",'"Title", MessageBoxButtons.YesNo)

 

0 Likes
Message 7 of 14

Anonymous
Not applicable

Not sure I follow you. The code I provided stops the user from exiting the InputBox if they either:

  1. Click 'Cancel'
  2. Click 'X" (Close)
  3. Don't enter anything

In your case you may be better using an InputListBox to restrict the selection to a predefined list since you only have 2 choices.

 

Try this code:

Dim doc = ThisDoc.Document

Dim params As Parameters = doc.ComponentDefinition.Parameters

Dim matcode As Parameter

Try
	MultiValue.SetList("Material_Code", "A", "D")
Catch
	matcode = params.UserParameters.AddByValue("Material_Code", "", "Text")
	MultiValue.SetList("Material_Code", "A", "D")
End Try

Dim myparam As String

While myparam = vbNullString
	myparam = InputListBox("Please Select Material Code:" & vbLf & "A = Aluminium" & vbLf & "D = Ductile Iron", MultiValue.List("Material_Code"), Material_Code, Title := "Material Code", ListName := "List")
End While

params.UserParameters.Item("Material_Code").Delete

MsgBox(myparam)

 I've attached an .ipt also for your reference

0 Likes
Message 8 of 14

Anonymous
Not applicable

Hello Craig,

Thanks lot for your reply. Maybe I did not express my requirement very clear.

I have a *.iam & *.ipt which include iLogic code to generate different model depend on input.

I do not want user to edit my code. So I want when user use "Cance" button or "X" icon, the application to be auto closed. Of course, I have a code to check is the user is myself, I cannot continue.

The issue is: when other user to use my iLogic model, "CanceL" button works fine which could let application to be closed, but when use push "X" icon, Inventor asks user whether save the file as attached picture. In this windows, if user push "Cancel" button, user can edit my code now.

I want to block this backdoor.

 

0 Likes
Message 9 of 14

Anonymous
Not applicable

Does someone have other ideas? And I just found I had some misinput in previous reply. 

 

I have a *.iam & *.ipt which include iLogic code to generate different models which will depend on input.

I do not want user to edit my code. So I want when user pushs "Cancel" button or ""X" icon (Close), the application to be automatically closed. Of course, I have a code to check if the user is myself, the application will be still open so I can continue.

The issue is: when other user uses my iLogic model, if he push "Cancel" button in InputBox window, it works fine which could let application to be closed immediately, but when user pushes "X" icon (Close) in InputBox, Inventor asks user whether save the file. In this windows, if user push "Cancel" button or "X" icon, the application still open and he can edit my code which is not what I want.

 

I would like put my code here in order someone could help me find solution.

 

SyntaxEditor Code Snippet

	Do 
		ControlCode = UCase(InputBox("Please Input Control Code:" _
		& vbLf & "A" _
		& vbLf & "B" _
		& vbLf & "C" _
		& vbLf & "D" _
		& vbLf & "E" _
		& vbLf & "F" _
		& vbLf & "G", Title, "A"))

		If ControlCode = "" Then
			iLogicVb.RunRule("Check Edit Permission")
			Exit Sub
		End If

	Loop While ControlCode <> MultiValue.FindValue(MultiValue.List("ControlCode"), "=", ControlCode)

 

My Rule "Check Edit Permission" as below

SyntaxEditor Code Snippet

	oUsername = Environ("Username")
	If oUsername <> MultiValue.FindValue(MultiValue.List("oCreator"), "=", oUsername) Then
		ThisApplication.Quit
		Exit Sub
	End If 

When user push "Cancel" button in InputBox Window, "Check Edit Permission" works fine.

But if user push "X" icon in InputBox Window,  Inventor will pop-up a window ask User whether he wants to Save or Cancel. In this window, if user pushes "X" icon again, the applicaiton will not quit and he can edit my code now which is not what I want.

0 Likes
Message 10 of 14

Anonymous
Not applicable
Accepted solution

I found a temporary solution which although is not what I want, but user cannot do anything now. Thanks lot for everyone's brainstorm.

Still, if anyone have better ideas, it will be much appreciated.

I would like put my  "Check Edit Permission" Snippet as below:

 

	oUsername = Environ("Username")
	If oUsername <> MultiValue.FindValue(MultiValue.List("oCreator"), "=", oUsername) Then
ThisApplication.UserInterfaceManager.UserInteractionDisabled = True
ThisApplication.Quit Exit Sub End If 

 

0 Likes
Message 11 of 14

Maxim-CADman77
Advisor
Advisor

I see the thread is pretty old ... but ... with all the respect ... I wouldn't call previous message a "solution" at all.
Try this "backdoor sequence":
 1. Disable iLogic Add-In autostart.
 2. Restart Inventor.
 3. Open "protected" document.
 4. Start iLogic Add-In.

... and get access to all internal rules.


PS: I really would like to know whether it is possible to distinguish vbNullString and "" within the iLogic.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 12 of 14

Zach.Stauffer
Advocate
Advocate

Using String.Equals will differentiate between the two:

Dim isNothing as String = vbNullString
Dim isEmpty As String = ""

Logger.Debug(isEmpty = isNothing)                   'this displays true
Logger.Debug(String.Equals(isEmpty, isNothing))     'this displays false
0 Likes
Message 13 of 14

Maxim-CADman77
Advisor
Advisor

Thank you.

Seems like my expectations were wrong and InputBox just never return vbNullString.
Just in case: this conclusion was done after playing around with below iLogic code:

Dim UserString As String = InputBox("Enter the SubString to search")
Dim isNothing as String = vbNullString
Dim isEmpty As String = ""

If String.Equals(UserString, isNothing)
	logger.debug("Close/Cancel/Esc")
Else If String.Equals(UserString, isEmpty)
	logger.debug("Empty string")
Else
	logger.debug(UserString)
End If

Pressing Cancel, closing with upper-right cross or Esc ... all three return "Empty string".

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 14 of 14

Zach.Stauffer
Advocate
Advocate

Yeah if it's using the same one as VBA, a cancel returns an empty string "".

 

https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/inputbox-function 

0 Likes