Announcement

Collapse
No announcement yet.

Open File Dialog - Hook Procedure - Question...

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

  • Open File Dialog - Hook Procedure - Question...

    I have a need to allow users to browse for certain files, but would like to change what they see in the listview on screen from what the actual filename is for various reasons.

    I'm curious - is it possible to change the text of the listview on the common dialog box?

    If so - does this adversely affect the filename returned, or is that handled outside of what is displayed on screen?

    I'm expecting to write my own browse window - but I'm hoping there might be other possibilities...
    Adam Drake
    Drake Software

  • #2
    Well, you can either....

    Play with Hook Procedures :Explorer-Style hook Procedures for OpenFileDialog and SaveFileDialog 3-31-07

    There is the CDN_SELCHANGE notification, but that doesn't happen until the files are on the screen. Maybe you'll need to 'do something' with the CDN_INCLUDEITEM notification, which occurs BEFORE the item is displayed. What I don't know, but all the controls of the Common Dialog are numbered (I cannot find the IDs but I know they are somewhere in the COMDLG.H file), so I'd think you should be able to do something with the display.

    (Maybe you'll want to intercept and process the WM_NOTIFY/NM_CUSTOMDRAW notification to the listview control?)

    Or, you can write your own screen. DIR$ gets you a list of files; for that matter, if you can use a listBOX instead of a listVIEW control, the LB_DIR message will return files in the subject directory.

    Sounds like a fun project.

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

    Comment


    • #3
      That example has a serious lack towards beginners.
      You did not set the parenthwnd in this example.
      Newcomers won't understand, should be:

      Call OpenFileDialogHook (CbHndl...
      hellobasic

      Comment


      • #4
        I found this in my on-disk SDK under the subject " Explorer-Style Control Identifiers"

        The Platform SDK provides the default dialog box template for the old-style dialog boxes, but does not include the default template for the Explorer-style dialog boxes. This is because the Explorer-style dialog boxes allow you to add your own controls but do not support modifying the template for the standard controls. However, in some cases, you may need to know the control identifiers used in the default templates. For example, the CDM_HIDECONTROL and CDM_SETCONTROLTEXT messages require a control identifier.

        The following table shows the identifiers of the standard controls in the Explorer-style Open and Save As dialog boxes. The identifiers are constants defined in Dlgs.h and Winuser.h.

        Control identifier Control description
        chx1 The read-only check box
        cmb1 Drop-down combo box that displays the list of file type filters
        stc2 Label for the cmb1 combo box
        cmb2 Drop-down combo box that displays the current drive or folder, and that allows the user to select a drive or folder to open
        stc4 Label for the cmb2 combo box
        cmb13 Drop-down combo box that displays the name of the current file, allows the user to type the name of a file to open, and select a file that has been opened or saved recently. This is for earlier Explorer-compatible applications without hook or dialog template. Compare with edt1.
        edt1 Edit control that displays the name of the current file, or allows the user to type the name of the file to open. Compare with cmb13.
        stc3 Label for the cmb13 combo box and the edt1 edit control
        lst1 List box that displays the contents of the current drive or folder
        stc1 Label for the lst1 list box
        IDOK The OK command button (push button)
        IDCANCEL The Cancel command button (push button)
        pshHelp The Help command button (push button)
        finding the values may not be fun, but it's a start.

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

        Comment


        • #5
          >That example has a serious lack towards beginners

          You mean my demo? I've never had a complaint about it not working, and it works terrific for me.

          >You did not set the parenthwnd in this example.

          I didn't have to.

          >Newcomers won't understand, should be:

          Well, if you think we need a demo for newcomers, why don't you write one and post it?

          If using hook procedures is too complex, there's always the "write your own" approach. But here's another demo which might be a really good start for that, considering I wrote it as a replacement for GetOpenFileName and it already includes the NM_CUSTOMDRAW code in all the right places......

          Listview: User-Friendly replacement for GetOpenFileName March 02, 2002

          Too bad you are not a Yank like me, Edwin: then I could hit you with a little colloquialism suggesting the inadvisability of performing a dental examination of an equine provided as a present.

          MCM
          Last edited by Michael Mattias; 1 Nov 2009, 10:40 AM.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            1)
            It must be fall, you just turned like a leaf in the wind.
            Everyone needs to be precise yet not yourself??

            2)
            >Too bad you are not a Yank like me, Edwin: then I could hit you with a little colloquialism suggesting the inadvisability of performing a dental examination of an equine provided as a present.

            You really think some average foreigner like me knows that this means?
            To me it is just a bunch of words, you don't need the parenthwnd, i don't need that kind of skills in language.
            hellobasic

            Comment


            • #7
              Originally posted by Adam J. Drake View Post
              I have a need to allow users to browse for certain files, but would like to change what they see in the listview on screen from what the actual filename is for various reasons.

              I'm curious - is it possible to change the text of the listview on the common dialog box?

              If so - does this adversely affect the filename returned, or is that handled outside of what is displayed on screen?

              I'm expecting to write my own browse window - but I'm hoping there might be other possibilities...
              Geez, I've (re)read this a dozen times. It seems to me two arrays would do the job: Psuedo_Name_to_Show$(Number_of_Files) & The_Real_Thing$(Number_of_Files).

              I suppose though, I'm assuming too simple of a problem. That's too simple a solution . Simply speaking that is.

              =======================================
              "Success usually comes to those
              who are too busy to be looking for it"
              Henry David Thoreau (1817-1862)
              =======================================
              It's a pretty day. I hope you enjoy it.

              Gösta

              JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
              LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

              Comment


              • #8
                Geez, I've (re)read this a dozen times. It seems to me two arrays would do the job: Psuedo_Name_to_Show$(Number_of_Files) & The_Real_Thing$(Number_of_Files).
                Were you writing your own "GetOpenFileName" screen, that would absolutely be the easiest way to keep the information straight.

                However, I believe the problem as stated is to avoid the requirement to reinvent that particular wheel, possibly by tapping into 'hook' or other interface facilities provided by the Microsoft Common Dialog for same.

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

                Comment


                • #9
                  Just as another thought....

                  I wonder if there might not be a COM interface available using the shell namespace object; something with a little more power than the common dialog's 'hook' interface?

                  I've posted before one of my reasons for wanting to learn how to use the COM client facilities in the compiler is today so many Microsoft APIs utilize the COM interface.

                  It's a thought.

                  Come to think of it, ShBrowseForFolder() offers an option to include files, and the hook procedure for that .... let me look...... nah, that does not appear to offer a "change display text" option. But I could be missing something, so it couldn't hurt for a fresh set of eyes to take a peek.

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

                  Comment


                  • #10
                    A COM version of the file dialogs was introduced with Vista, I think.

                    Comment


                    • #11
                      I believe the problem as stated is to avoid the requirement to reinvent that particular wheel
                      Michael, You are correct - however it appears that re-invention of that wheel is the only option.

                      To all, thanks for the replies.
                      Adam Drake
                      Drake Software

                      Comment


                      • #12
                        If people didn't re-invent the wheel every once in a while we'd still be on iron treads.

                        =================================
                        "He would make a lovely corpse."
                        Charles Dickens (1812-1870)
                        =================================
                        It's a pretty day. I hope you enjoy it.

                        Gösta

                        JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                        LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                        Comment


                        • #13
                          Wait a minute.....

                          When you say....

                          " I have a need to allow users to browse for certain files," How many files?

                          There just happens to yet another demo which may be of interest here ......

                          Add a 'Favorite Files' menu to your application 10-25-07
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment

                          Working...
                          X