Announcement

Collapse
No announcement yet.

Navarro's PBDLL encapsulations - Open/Save file?

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

  • Navarro's PBDLL encapsulations - Open/Save file?

    Thanks, Dave, for those encapsulations posted
    on the Source Code forum for list boxes, edit boxes, etc. Is there something similar out there for the open/save file common controls?


  • #2
    Terry,

    Yes! They included already in one of the include files.

    Here is the same thing but with a hook to center the dialog.

    Code:
    '---------------------------------------------------------
    ' File: CENTDLG.BAS   Center the Open/Save Dialog Box
    '
    '
    '---------------------------------------------------------
     
    'Notifications for Open dialog control
    %CDN_INITDONE       = (%CDN_FIRST - 0000 )
    %CDN_SELCHANGE      = (%CDN_FIRST - 0001 )
    %CDN_FOLDERCHANGE   = (%CDN_FIRST - 0002 )
    %CDN_SHAREVIOLATION = (%CDN_FIRST - 0003 )
    %CDN_HELP           = (%CDN_FIRST - 0004 )
    %CDN_FILEOK         = (%CDN_FIRST - 0005 )
    %CDN_TYPECHANGE     = (%CDN_FIRST - 0006 )
    '%CDM_FIRST          = (%WM_USER + 100 )
    '%CDM_LAST           = (%WM_USER + 200 )
     
    '---
    Type TAGOFNOTIFY
        hdr     As NMHDR
    End Type
     
    '---
    Function OpenCommDlg_Proc(ByVal hWnd As LONG, ByVal wMsg As LONG, ByVal wParam As LONG, ByVal lParam As LONG ) EXPORT As LONG
        DIM X As Long
        DIM Y As Long
        DIM R As RECT
        Dim tNOTIFY As TAGOFNOTIFY PTR
        Select Case wMsg
        Case %WM_NOTIFY
            tNOTIFY = lParam
            If @tNOTIFY.hdr.Code = %CDN_INITDONE Then
                GetWindowRect GetParent( hWnd ), R
                X = GetSystemMetrics ( %SM_CXSCREEN )
                Y = GetSystemMetrics ( %SM_CYSCREEN )
                X = ( X - ( R.nRight   - R.nLeft ) ) \ 2
                Y = ( Y - ( R.nBottom  - R.nTop  ) ) \ 2
                SetWindowPos GetParent( hWnd ), %NULL, X, Y, 0, 0, %SWP_NOSIZE OR %SWP_NOZORDER
            End If
        End Select
    End Function
    
     
    '---
    FUNCTION OpenFileCenterDlg(BYVAL hWnd AS LONG, _                ' parent window
                          BYVAL Caption AS STRING, _           ' caption
                          Filespec AS STRING, _                ' filename
                          BYVAL InitialDir AS STRING, _        ' start directory
                          BYVAL Filter AS STRING, _            ' filename filter
                          BYVAL DefExtension AS STRING, _      ' default extension
                          Flags AS LONG) AS LONG               ' flags
     
      LOCAL Ofn           AS OPENFILENAME
      LOCAL zFile         AS ASCIIZ * 256
      LOCAL zFileTitle    AS ASCIIZ * 256
      LOCAL zFilter       AS ASCIIZ * 256
      LOCAL zInitialDir   AS ASCIIZ * 256
      LOCAL zTitle        AS ASCIIZ * 256
      LOCAL zDefExt       AS ASCIIZ * 10
     
      REPLACE "|" WITH CHR$(0) IN Filter
     
      IF LEN(InitialDir) = 0 THEN
        InitialDir = CURDIR$
      END IF
     
      zFilter     = Filter + CHR$(0)
      zInitialDir = InitialDir + CHR$(0)
      zFile       = Filespec + CHR$(0)
      zDefExt     = DefExtension + CHR$(0)
      zTitle      = Caption + CHR$(0)
     
      ofn.lStructSize       = SIZEOF(ofn)
      ofn.hWndOwner         = hWnd
      ofn.lpstrFilter       = VARPTR(zFilter)
      ofn.nFilterIndex      = 1
      ofn.lpstrFile         = VARPTR(zFile)
      ofn.nMaxFile          = SIZEOF(zFile)
      ofn.lpstrFileTitle    = VARPTR(zFileTitle)
      ofn.nMaxFileTitle     = SIZEOF(zFileTitle)
      ofn.lpstrInitialDir   = VARPTR(zInitialDir)
     
      IF LEN(zTitle) THEN
        ofn.lpstrTitle        = VARPTR(zTitle)
      END IF
     
      ofn.Flags             = Flags OR %OFN_ENABLEHOOK OR %OFN_EXPLORER
      ofn.lpstrDefExt       = VARPTR(zDefExt)
      ofn.lpfnHook          = CODEPTR(openCommDlg_Proc)
     
      FUNCTION = GetOpenFilename(ofn)
     
      Filespec = zFile
      Flags    = ofn.Flags
     
    END FUNCTION
     
     
    '---
    FUNCTION SaveFileCenterDlg(BYVAL hWnd AS LONG, _          ' parent window
                            BYVAL Caption AS STRING, _      ' caption
                            Filespec AS STRING, _           ' filename
                            BYVAL InitialDir AS STRING, _   ' start directory
                            BYVAL Filter AS STRING, _       ' filename filter
                            DefExtension AS STRING, _       ' default extension
                            Flags AS LONG) AS LONG          ' flags
     
      LOCAL Ofn           AS OPENFILENAME
      LOCAL zFile         AS ASCIIZ * 256
      LOCAL zFileTitle    AS ASCIIZ * 256
      LOCAL zFilter       AS ASCIIZ * 256
      LOCAL zInitialDir   AS ASCIIZ * 256
      LOCAL zTitle        AS ASCIIZ * 256
      LOCAL zDefExt       AS ASCIIZ * 10
     
      REPLACE "|" WITH CHR$(0) IN Filter
     
      IF LEN(InitialDir) = 0 THEN
        InitialDir = CURDIR$
      END IF
     
      zFilter     = Filter + CHR$(0)
      zInitialDir = InitialDir + CHR$(0)
      zFile       = Filespec + CHR$(0)
      zDefExt     = DefExtension + CHR$(0)
      zTitle      = Caption + CHR$(0)
     
      ofn.lStructSize       = SIZEOF(ofn)
      ofn.hWndOwner         = hWnd
      ofn.lpstrFilter       = VARPTR(zFilter)
      ofn.nFilterIndex      = 1
      ofn.lpstrFile         = VARPTR(zFile)
      ofn.nMaxFile          = SIZEOF(zFile)
      ofn.lpstrFileTitle    = VARPTR(zFileTitle)
      ofn.nMaxFileTitle     = SIZEOF(zFileTitle)
      ofn.lpstrInitialDir   = VARPTR(zInitialDir)
     
      IF LEN(zTitle) THEN
        ofn.lpstrTitle        = VARPTR(zTitle)
      END IF
     
      ofn.Flags             = Flags OR %OFN_ENABLEHOOK OR %OFN_EXPLORER
      ofn.lpstrDefExt       = VARPTR(zDefExt)
      ofn.lpfnHook          = CODEPTR(openCommDlg_Proc)
     
      FUNCTION = GetSaveFilename(ofn)
     
      Filespec = zFile
      Flags    = ofn.Flags
     
    END FUNCTION
     
    '--------------------*       End         *----------------
    Regards, Jules

    Best regards
    Jules
    www.rpmarchildon.com

    Comment


    • #3
      If you have down loaded the latest API, all
      of Dave's wrappers are in the 'commctl.inc'
      file. No need for yet another *.inc directive
      in your code. Good job Dave!!!

      Cecil

      Comment


      • #4
        Thanks! It's still a work in progress. I plan to include code for all of controls in Windows eventually.

        So much to do, so little time...

        --Dave


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

        Home of the BASIC Gurus
        www.basicguru.com

        Comment


        • #5
          I feel really foolish - but I can't find anywhere on
          this site to download the lastest API! (such as the commctl.inc)
          The "PBDLL API Directory" under Files only has 3 choices -
          encap32, excel32api, and obdc30 - no commclt.inc

          Originally posted by Cecil Williams:
          If you have down loaded the latest API, all
          of Dave's wrappers are in the 'commctl.inc'
          file. No need for yet another *.inc directive
          in your code. Good job Dave!!!

          Cecil


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

          Comment


          • #6
            http://www.powerbasic.com/files/pub/pbwin/win32api.zip

            They are all zipped into this one file.

            ------------------
            mailto:[email protected][email protected]</A>
            :-)

            Comment


            • #7
              Terry,

              Sorry for not clarifing the Win32API location. Just follow
              Kevin's ftp IP address and you'll be there. BTW, the open and save dlgs are in comdlg32.inc file.

              You need to get familiar with the Win32API files. Powerbasic also updates these files so you need to check every so often to get the latest files. Thanx to Kevin for the IP address.

              Cheers,
              Cecil

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

              Comment


              • #8
                Just one thing would make those encapsulations mucho better: If there were DECLARE statements for them. Better still, if all the "non-Windows" stuff were in it's own #INCLUDE file.

                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment

                Working...
                X