Page 1 of 1

How do you make an open file dialog?

Posted: Sat May 26, 2007 6:34 pm
by plushiefire
Sorry but i really need to know. Im trying to make a resigner.

Posted: Sat May 26, 2007 6:38 pm
by Tural
Language?

Posted: Sat May 26, 2007 7:22 pm
by Dagger13
you want to make your own??

Posted: Sun May 27, 2007 2:21 am
by jebmodillion
Ok well if you are looking to make your own resigner the go to the following link:

http://forums.halomods.com/viewtopic.php?t=60019

About the open file dialog:

I am assuming you are using visual basic

so do this

Go to the tool box in Visual baisc (with project open) then go to dialogs catagory in the tool box after that drag and drop it on the design form of your resigner. It wont appear on your resigner disign it will be located right below it you will see OpenFileDialog1 click it once then go to the propertys window(usualy located to the lower right) and find the tag named(name) then change it to ofd.

If you need further help PM me and I will teach you to the best of my knowledge.

Posted: Mon Jul 02, 2007 12:01 pm
by stevo3463
assuming you know C#

1.) Drag over an open file dialog from containers and menus in the toolbatr in C#.
2.) Double click your open event and copy n paste this code to open a .map file.

Code: Select all

                    OpenFileDialog OFD = new OpenFileDialog();
                    OFD.Filter = "Map(*.map)|*.map";
                    OFD.FilterIndex = 1;
                    if (OFD.ShowDialog() == DialogResult.OK)
                    {
                        // Load the contents of the .map file here.
                    }

Posted: Mon Jul 02, 2007 7:48 pm
by Patrickh
VB: It opens an image (you can change it to something else) and when you open it it shows it's location in a textbox.

Code: Select all

Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        ' Show the open file dialogue box.
        If ofdSelectPicture.ShowDialog = Windows.Forms.DialogResult.OK Then
            ' Load the picture in the picture box.
            picShowPicture.Image = Image.FromFile(ofdSelectPicture.FileName)
            ' show the name of the file's location in a text box
            txtDestination.Text = "" & ofdSelectPicture.FileName


        End If
    End Sub


Short answer:

Code: Select all

Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
 ' Show the open file dialogue box.
        If ofdSelectPicture.ShowDialog = Windows.Forms.DialogResult.OK 
End Sub
ofdSelectPicture is the name of your ofd.

Posted: Fri Jul 06, 2007 8:58 am
by LuxuriousMeat
Why are giving him unfinished code?
To make it easy just use this:

Code: Select all

Dim ofd As New OpenFileDialog
ofd.Filter = "Halo 2 Maps|*.map"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
    'code for pressing ok here
End If

Posted: Sun Jul 08, 2007 11:35 pm
by Patrickh
LuxuriousMeat wrote:Why are giving him unfinished code?
To make it easy just use this:

Code: Select all

Dim ofd As New OpenFileDialog
ofd.Filter = "Halo 2 Maps|*.map"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
    'code for pressing ok here
End If
sorry if it was unfinished, but I copied that from my app where it worked fine

Posted: Mon Jul 09, 2007 1:24 am
by halo0001
Patrickh wrote:
LuxuriousMeat wrote:Why are giving him unfinished code?
To make it easy just use this:

Code: Select all

Dim ofd As New OpenFileDialog
ofd.Filter = "Halo 2 Maps|*.map"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
    'code for pressing ok here
End If
sorry if it was unfinished, but I copied that from my app where it worked fine
that is finished...

Posted: Wed Jul 11, 2007 12:50 pm
by LuxuriousMeat
halo0001 wrote:
Patrickh wrote:
LuxuriousMeat wrote:Why are giving him unfinished code?
To make it easy just use this:

Code: Select all

Dim ofd As New OpenFileDialog
ofd.Filter = "Halo 2 Maps|*.map"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
    'code for pressing ok here
End If
sorry if it was unfinished, but I copied that from my app where it worked fine
that is finished...
Thats the code I posted, he had no End If.

Posted: Sat Jul 14, 2007 3:02 am
by Prey
If your going to create an openfiledialog on the fly, you might as well in-close it in a using statement.

Code: Select all

/* Once the using statement has finished, the garbage
 * collector knows to dispose of the ofd straight away */
using (OpenFileDialog o = new OpenFileDialog())
{
    //Set some properties
    o.Title = "Open File Dialog";
    o.Filter = "All Files (*.*)|*.*";

    if (o.ShowDialog() != DialogResult.Cancel)
    {
        // The user has selected a file
    }
    else
    {
        // Cancel was pressed
    }
}

Posted: Sat Jul 14, 2007 7:54 am
by OwnZ joO
Prey wrote:If your going to create an openfiledialog on the fly, you might as well in-close it in a using statement.

Code: Select all

/* Once the using statement has finished, the garbage
 * collector knows to dispose of the ofd straight away */
using (OpenFileDialog o = new OpenFileDialog())
{
    //Set some properties
    o.Title = "Open File Dialog";
    o.Filter = "All Files (*.*)|*.*";

    if (o.ShowDialog() != DialogResult.Cancel)
    {
        // The user has selected a file
    }
    else
    {
        // Cancel was pressed
    }
}
I understand that all, but what does that do, just dispose it when you're finished or what? I used to use it when I used vb.net, but stopped.

Posted: Sat Jul 14, 2007 8:09 am
by Prey
The using statement makes sure the object is disposed of as soon as the statement is over, otherwise the object will just be floating around in mem. until the GC realizes it's no longer needed. (true that'll probably be as soon as the method ends, but it's still good practice - also you can be sure it'll be disposed of asap)

Posted: Sat Jul 14, 2007 8:35 am
by OwnZ joO
K that's what would make sense, just wanted to make sure.