Customise OpenDialog to include Modal text input box

I’ve created a method InputDeviceSampleRate which opens a modal window for text input. This works fine on it’s own.

Now I need to call that method after the user selects a file from the open/import dialog box:

After selecting a file, then selecting “Open”, the user will see this:

What needs to happen is that if the user selects cancel in the modal window, then it should back out to the open dialog box, otherwise the user enters a number and selects OK and we proceed as normal.

It’s taken me many hours just to get to the point of opening a valid file and evaluating the data. Nevertheless, the text input from the modal window is a must for my program to work. At the moment I’m struggling to work out where to insert the method call. This is my current code:

[code]// IMPORT Files

Dim dlg As OpenDialog
Dim f As FolderItem
dlg = New OpenDialog
dlg.Title = “Import File”
dlg.Filter = FileTypes1.All //Restrict file types

f = dlg.ShowModal

If f <> Nil Then

ReDim tempArray(-1)
cursorFinalPositionX=0
recordedGramsArrayIndex=0

If f.Exists Then
  Dim dataInput As TextInputStream
  
  Try        
    dataInput = TextInputStream.Open(f)
    tempArray() = Split(dataInput.ReadAll,EndOfLine) //(Encodings.ASCII)
    dataInput.Close        
  Catch e As IOException
    MsgBox("Error accessing file.")
  End Try

End If

EvaluateImportedData

End If

cnvGRAPH.SetFocus // if cancelled[/code]

I think that Try/Catch/End Try, is complicating things. I’m not sure if it’s really needed.

What is the user really want to cancel: go out of the Open (Import, Whatever) process ?

Yesfor complicated… but MANDATORY to avoid troubles.

As is, your import code allows you to load png files (and certainly all selected items (excepted directories).

For the “reopen” case you asked for.

Why don’t you put a message telling to your user (s)he cancels the Open / Import… process ?

If it was an error the user just have to choose back the Open / Import, … button, MenuItem, …

[quote=313128:@Emile Schwarz]For the “reopen” case you asked for.

Why don’t you put a message telling to your user (s)he cancels the Open / Import… process ?

If it was an error the user just have to choose back the Open / Import, … button, MenuItem, …[/quote]

Thanks Emile - I’m not exactly sure what you mean.

I’d rather not add another option for the user to have to consider.

These last few hours I’ve fiddled around with it and are able to have the modal box appear in the correct part in the code (I think).

The main thing I’ve noticed is that upon opening of the modal box, the ‘open file dialog’ box disappears and shows the underlying main window.

This needs a lot more thought than I was expecting.

Back to the drawing board ;_;

The user click in Open / Import by error, it will stay there because you want to do that:

You wrote earlier:
“What needs to happen is that if the user selects cancel in the modal window, then it should back out to the open dialog box”

Ok, thanks Emile. My fault for not explaining well enough.

What I was thinking is that when the user selects a file in the open dialog, then clicks the “open” button, a modal window opens asking for input. As per this mockup:

If the user selects cancel then the modal window closes but the open file dialog remains for the user to make another choice. In real life it’s probably not necessary, but more of an aesthetic.

I’ve since realised that it’s not going to happen that way. After the user selects open, the open file dialog closes (as it well should) and then the modal opens, now showing the main window underneath:

It’s not the way I’d like it to look, but it will work fine.