How do you make an open file dialog?

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
plushiefire





Posts: 618
Joined: Thu Nov 23, 2006 12:10 pm
Location: Canada

How do you make an open file dialog?

Post by plushiefire »

Sorry but i really need to know. Im trying to make a resigner.
Come check out Team 3volved.
Image
User avatar
Tural




Conceptionist Acolyte Bloodhound Recreator
Socialist Connoisseur Droplet Scorched Earth
Grunge

Posts: 15628
Joined: Thu Jun 16, 2005 3:44 pm
Location: Lincoln, NE
Contact:

Post by Tural »

Language?
User avatar
Dagger13





Posts: 370
Joined: Wed Nov 22, 2006 12:37 pm

Post by Dagger13 »

you want to make your own??
Image(An Old one.)
User avatar
jebmodillion
Readers Club





Posts: 41
Joined: Sun Apr 08, 2007 9:43 pm

Post 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.
stevo3463





Posts: 4
Joined: Thu Oct 19, 2006 1:59 pm

Post 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.
                    }
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post 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.
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Post 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
Image
User avatar
Patrickh




Wordewatician 500

Posts: 1173
Joined: Wed Mar 14, 2007 4:53 pm

Post 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
Image
conure says: or i could jsut incase my shoes in papar mache, followed by my dog
|||Lethargy||| Mr. Mohawk|||
|||feel free to contact me via PMs, AIM, MSNM, or Xfire if you have any questions|||
User avatar
halo0001





Posts: 853
Joined: Tue Aug 22, 2006 7:59 pm
Location: USA

Post 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...
Image
User avatar
LuxuriousMeat





Posts: 824
Joined: Thu Nov 03, 2005 6:43 pm
Location: zzzzzzzzzzzzzzzz
Contact:

Post 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.
Image
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post 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
    }
}
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post 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.
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post 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)
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
OwnZ joO




Articulatist 500

Posts: 980
Joined: Thu Nov 10, 2005 4:24 pm

Post by OwnZ joO »

K that's what would make sense, just wanted to make sure.
Post Reply