Announcement

Collapse
No announcement yet.

API Call OpenFileDialog

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dave Biggs
    replied
    OpenFileDialog() is actually a wrapper for the API function GetOpenFilename(). Code in ComDlg32.inc
    takes care of filling the appropriate structures for you. Here's another example..
    Code:
    '[ code ]       ' use w/out spaces before code block to format in forum posts
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "ComDlg32.INC"
     
    FUNCTION PBMAIN () AS LONG
     DIM sFileSpec AS String
     DIM Res       AS LONG
     
      OpenFileDialog (0, _                                  ' parent window
                      "OpenFile", _                         ' caption
                      sFileSpec, _                          ' filename   <- gets set to user selection
                      CurDir$, _                            ' start directory
                      "Basic Files|*.bas|All Files|*.*", _  ' filename filter
                      "bas", _                              ' default extension
                      0 _                                   ' flags
                     ) To Res
     
      If Res <> 0 Then                                      ' Res nonzero = Not cancelled, No error
        ? PathName$(NAMEX, sFileSpec) & " - - - " & PathName$(PATH, sFileSpec)
      End If
     WAITKEY$
    END FUNCTION 
    '[ /code ]      ' use w/out spaces after code block to format in forum posts

    Leave a comment:


  • Mel Bishop
    replied
    Try this format. It returns full path/filename in one string.
    Code:
    #INCLUDE "comdlg32.inc"
        FUNCTION PBMAIN
        LOCAL result AS LONG
        LOCAL f      AS STRING
        LOCAL STYLE  AS DWORD
        LOCAL PATH   AS STRING
    
        Result = OpenFileDialog(0, "Open File", f, "", "All Files|*.*|All Files|*.*", "txt", STYLE)
        CLS
        PRINT;result
        PRINT;f
        WAITKEY$
        END FUNCTION

    Leave a comment:


  • Charles Perry
    started a topic API Call OpenFileDialog

    API Call OpenFileDialog

    Using PBCC 5 with ComDlg32.INC
    The following is the test code.

    The question is how do I get the File name/path from the API call?
    The Function stores the File name and path at string pointer in ofn.lpstrFile, but ofn is declared local.
    The Function return a fail/nofail status only.

    #COMPILE EXE
    #DIM ALL
    #INCLUDE "ComDlg32.INC"
    FUNCTION PBMAIN () AS LONG
    DIM FileName AS OpenFileName5 'Declare structure
    PRINT OpenFileDialog ( ASC($NUL), _ ' parent window
    "", _ ' caption
    "test.bas", _ ' filename
    "", _ ' start directory
    "", _ ' filename filter
    "bas", _ ' default extension
    0 _ ' flags
    )
    END FUNCTION
Working...
X