Announcement

Collapse
No announcement yet.

open dialog - how?

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

  • open dialog - how?

    Fellows,

    Does someone of your have a piece of sample code that creates a dialog to select files from the directory-structure?
    Much appreciated!

    ------------------
    mailto:[email protected]ru.com[email protected]</A>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    common dialog control you mean?

    Code:
    #Include "C:\PBDLL60\Winapi\commctrl.inc"
    
          Local RetVal As Long
             RetVal = SaveFileDialog(hfrmFileCopy&, "Copy File to...", sDestination, "C:\", "*.*", "*.*",0
    ------------------

    Paul Dwyer
    Network Engineer
    Aussie in Tokyo
    (Paul282 at VB-World)

    Comment


    • #3
      Look in the samples directory of pbdll6: file pbnote.bas

      Code:
      CASE %IDM_OPEN
                Path     = CURDIR$
                f        = "*.TXT"
                Style    = %OFN_FILEMUSTEXIST OR %OFN_HIDEREADONLY OR %OFN_LONGNAMES
                IF OpenFileDialog(hWndMain, "Open File", f, Path, _
                                  "Text Files|*.TXT|All Files|*.*", "TXT", byval Style) THEN
                  hMdi = CreateMdiChild("PBNOTE32", hWndClient, f, 0)
                  ShowWindow hMdi, %SW_SHOW
                END IF
      Just one of the examples.

      Cheers,
      Cecil

      ------------------

      Comment


      • #4
        Paul,

        Perhaps I'm missing something, but I don't know how to use this.

        Cecil,

        PBNote does not work. "OpenFileDialog" generates a parameter mismatch error.

        ------------------
        mailto:[email protected][email protected]</A>
        www.basicguru.com/zijlema/

        Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
        http://zijlema.basicguru.eu
        *** Opinions expressed here are not necessarily untrue ***

        Comment


        • #5
          Check out the GetOpenFileName() API function in WIN32.HLP or MSDN.
          http://msdn.microsoft.com/library/ps...mdlg3_3cbp.htm


          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            Egbert,

            You need to just try it, and take a look through the inc file that is included.

            When you call this API function a "Common Dialog" is displayed (which will vary in appearance depending on your os and IE version) and you can choose a file or whatever then click OK.
            when you do the name and path of the file that was chosen is written to the param you passed, in my example it's "sDestination".
            then if you use this string variable in a File Open situation you can open a file. The common dialog is just a method of displaying an OS standard GUI for returning a filename! (or printer, colour etc).

            Try using my code in a pbmain exe and add "MsgBox sDestination" on the next line. The message box should display the name and path of the selected file.



            ------------------

            Paul Dwyer
            Network Engineer
            Aussie in Tokyo
            (Paul282 at VB-World)

            Comment


            • #7
              Egbert, the reason compiling PBnote produces error is because of
              a change in COMDLG32.INC. In PBnote code, change the declaration
              of Style in WndProc from LONG to DWORD, and it will work. Same in
              SaveFile procedure. Should look like:
              Code:
              SUB SaveFile(BYVAL Ask AS LONG)
                LOCAL zText AS ASCIIZ * 255
                LOCAL Path  AS STRING, f AS STRING, Buffer AS STRING
                LOCAL Style AS DWORD
                LOCAL hFile AS LONG
               
                GetWindowText MdiGetActive(hWndClient), zText, SIZEOF(zText)
                IF zText = "Untitled" THEN
                  Path = CURDIR$
                  f    = ""
                  Ask  = %TRUE
                ELSE
                  Path = FilePath(zText)
                  f    = FileNam(zText)
                END IF
                Style = %OFN_HIDEREADONLY OR %OFN_LONGNAMES
               
                IF ISTRUE(Ask) THEN
                  IF ISFALSE(SaveFileDialog(hWndMain, "Save File", f, Path, _
                             "Text Files|*.txt|All Files|*.*", "txt", Style)) THEN
                    EXIT SUB
                  END IF
                END IF
              '
              '8<-- etc..
              ------------------

              Comment


              • #8
                Borje,

                I forgot about that change. Ran across that sometime ago and
                made the type change to match COMDLG32.INC.

                Thanx,
                Cecil

                ------------------

                Comment

                Working...
                X