open file common dialog box


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: open file common dialog box

  1. #1
    Join Date
    Dec 2005
    Posts
    4

    open file common dialog box

    seeing as how I got such great help last time I needed help, I'm going to ask again

    I'm trying to get my application to open a standard Open File dialog box, I found a little program on this site that had what i wanted, and there was no way I could get it to work... I"m using VB6.. what's the simplest steps in getting the dialog to work..

    again, thanks in advance

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Oct 2005
    Location
    Staffordshire, England
    Posts
    101
    I'm afraid that link is no use to anyone Phil.

    Here's a little app I made to show all 6 functions of the CommonDialog ocx. It uses a RichTextBox so you can save rtf files with colour.
    Attached Files Attached Files
    Last edited by Keithuk; 12-07-2005 at 12:13 PM.
    I've been programming with VB for 15 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

    Martin2k

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    It's a six-page article; did you read all the pages? I think it's quite good, actually.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Oct 2005
    Location
    Staffordshire, England
    Posts
    101
    Sorry Phil, I didn't read all pages.
    I've been programming with VB for 15 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

    Martin2k

  6. #6
    Join Date
    Jan 2006
    Posts
    3
    Hi ..... try the following code ... it worked for me ..

    You need "comdlg32.dll" to call the open file dialog box ... Its info is given on MSDN site .. I don't remember the link .. but its something like this ...

    I hope it helps........

    Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
    "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long

    Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    End Type

    Function SelectFileOpenDialog()
    Dim strTemp, strTemp1, pathStr As String
    Dim i, n, j As Long
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim sFilter As String
    Dim Fname As String

    OpenFile.lStructSize = Len(OpenFile)
    sFilter = "Text Files (*.txt)" & Chr(0) & "*.TXT" & Chr(0)
    OpenFile.lpstrFilter = sFilter
    OpenFile.nFilterIndex = 1
    OpenFile.lpstrFile = String(257, 0)
    OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
    OpenFile.lpstrInitialDir = "C:\"
    OpenFile.lpstrTitle = "Select File"
    OpenFile.flags = 0

    lReturn = GetOpenFileName(OpenFile)

    If lReturn = 0 Then
    MsgBox "You didn't select any file"
    Else
    'MsgBox "The user Chose " & Trim(OpenFile.lpstrFile)

    Fname = Trim$(OpenFile.lpstrFileTitle) ' copy the filename to "Fname"

    n = FileLen(OpenFile.lpstrFile) 'length of the file

    End Function

Similar Threads

  1. Replies: 0
    Last Post: 08-02-2001, 10:37 PM
  2. File uploading / objFile.Write problem
    By Tomer Cagan in forum ASP.NET
    Replies: 1
    Last Post: 07-24-2001, 10:01 AM
  3. Call a common dialog box in a Sub Main procedure
    By Miguel Vieira in forum VB Classic
    Replies: 4
    Last Post: 01-31-2001, 10:32 AM
  4. Call a common dialog box in a Sub Main procedure
    By Miguel Vieira in forum VB Classic
    Replies: 0
    Last Post: 01-30-2001, 02:09 PM
  5. File Dialog Box in Swing
    By Shankar in forum Java
    Replies: 0
    Last Post: 06-24-2000, 05:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center