Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. 2 CFileDialogs

2 CFileDialogs

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Desmo16
    wrote on last edited by
    #1

    Hi all, I do: CFileDialog fd(TRUE, NULL, percorso, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "Dialog Title"; Now i need a CFileDialog that shows only .txt files. I also need another CFileDialog which i use to save a file in which the "file type" field is .txt How can i do that ? Thanx in advance, Desmo16.

    T J 2 Replies Last reply
    0
    • D Desmo16

      Hi all, I do: CFileDialog fd(TRUE, NULL, percorso, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "Dialog Title"; Now i need a CFileDialog that shows only .txt files. I also need another CFileDialog which i use to save a file in which the "file type" field is .txt How can i do that ? Thanx in advance, Desmo16.

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      Look up how to construct Filters for the common file dialog.  The docs for CFileDialog is a good place to start.    Peace!

      -=- James


      If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      DeleteFXPFiles & CheckFavorites (Please rate this post!)

      1 Reply Last reply
      0
      • D Desmo16

        Hi all, I do: CFileDialog fd(TRUE, NULL, percorso, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "Dialog Title"; Now i need a CFileDialog that shows only .txt files. I also need another CFileDialog which i use to save a file in which the "file type" field is .txt How can i do that ? Thanx in advance, Desmo16.

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        set the extensions filter to "Text files (*.txt)|*.txt||"


        You don't know where to start ? ask a good friend

        [VisualCalc 3.0][Flags Beginner's Guide]

        D 1 Reply Last reply
        0
        • T toxcct

          set the extensions filter to "Text files (*.txt)|*.txt||"


          You don't know where to start ? ask a good friend

          [VisualCalc 3.0][Flags Beginner's Guide]

          D Offline
          D Offline
          Desmo16
          wrote on last edited by
          #4

          i tried with CFileDialog fd(TRUE, NULL, percorso, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "load file"; fd.m_pOFN->lpstrDefExt = "txt"; and also with CFileDialog fd(TRUE, NULL, percorso, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "load file"; fd.SetDefExt("txt"); but it doesn't work. Where should i search in the doc exactly ?

          T 1 Reply Last reply
          0
          • D Desmo16

            i tried with CFileDialog fd(TRUE, NULL, percorso, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "load file"; fd.m_pOFN->lpstrDefExt = "txt"; and also with CFileDialog fd(TRUE, NULL, percorso, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "load file"; fd.SetDefExt("txt"); but it doesn't work. Where should i search in the doc exactly ?

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            not what i told you to do. i said assign the string "Text files (*.txt)|*.txt||" into the filter member of the CFileDialog... (see the 5th parameter of the constructor)


            You don't know where to start ? ask a good friend

            [VisualCalc 3.0][Flags Beginner's Guide]

            D 1 Reply Last reply
            0
            • T toxcct

              not what i told you to do. i said assign the string "Text files (*.txt)|*.txt||" into the filter member of the CFileDialog... (see the 5th parameter of the constructor)


              You don't know where to start ? ask a good friend

              [VisualCalc 3.0][Flags Beginner's Guide]

              D Offline
              D Offline
              Desmo16
              wrote on last edited by
              #6

              You are right, now i wrote: CFileDialog fd(TRUE, NULL, "*.txt", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "Carica file di osservazioni"; fd.m_pOFN->lpstrFilter = "Text files (*.txt)"; and it works great ! Thanx !

              T 1 Reply Last reply
              0
              • D Desmo16

                You are right, now i wrote: CFileDialog fd(TRUE, NULL, "*.txt", OFN_FILEMUSTEXIST | OFN_HIDEREADONLY); fd.m_pOFN->lpstrTitle = "Carica file di osservazioni"; fd.m_pOFN->lpstrFilter = "Text files (*.txt)"; and it works great ! Thanx !

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                yes, i modified my previous post ; you could also have done this using the 5th parameter of the constructor... also, don't hesitate to read the MSDN[^]. it's there for you !


                You don't know where to start ? ask a good friend

                [VisualCalc 3.0][Flags Beginner's Guide]

                D 1 Reply Last reply
                0
                • T toxcct

                  yes, i modified my previous post ; you could also have done this using the 5th parameter of the constructor... also, don't hesitate to read the MSDN[^]. it's there for you !


                  You don't know where to start ? ask a good friend

                  [VisualCalc 3.0][Flags Beginner's Guide]

                  D Offline
                  D Offline
                  Desmo16
                  wrote on last edited by
                  #8

                  The CFileDialog has on the bottom-right corner a button labeled as "open". How can i change the label into "save" ? Thanx in advance, Desmo16.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups