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. C++ Interface

C++ Interface

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
15 Posts 4 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.
  • A Offline
    A Offline
    Anka_Ame
    wrote on last edited by
    #1

    How can I establish the initial directory and the filter for open file in C++ ? Please help...

    G D 2 Replies Last reply
    0
    • A Anka_Ame

      How can I establish the initial directory and the filter for open file in C++ ? Please help...

      G Offline
      G Offline
      GuyM
      wrote on last edited by
      #2

      If you are talking about the CFileDialog class in MFC then here it is: CFileDialog MyFileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Text Files (*.txt;)|*.txt; |Database Files (*.mdb)|*.mdb; |All Files (*.*)|*.*||");//Filter MyFileDlg.m_ofn.lpstrInitialDir = _T("C:\\MyDirectory"); // Initial Dir. if (MyFileDlg.DoModal() == IDOK) { ... } Hope this helps ... :)

      A 1 Reply Last reply
      0
      • G GuyM

        If you are talking about the CFileDialog class in MFC then here it is: CFileDialog MyFileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Text Files (*.txt;)|*.txt; |Database Files (*.mdb)|*.mdb; |All Files (*.*)|*.*||");//Filter MyFileDlg.m_ofn.lpstrInitialDir = _T("C:\\MyDirectory"); // Initial Dir. if (MyFileDlg.DoModal() == IDOK) { ... } Hope this helps ... :)

        A Offline
        A Offline
        Anka_Ame
        wrote on last edited by
        #3

        I'm talking about the menu items, and I have the interface done in c# and now I want to make it in C++. I didnt succesed to make the filter files appear and the initial directory.

        1 Reply Last reply
        0
        • A Anka_Ame

          How can I establish the initial directory and the filter for open file in C++ ? Please help...

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          You'll need to be more specific as C++ knows nothing of directories or opening of files.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          A 1 Reply Last reply
          0
          • D David Crow

            You'll need to be more specific as C++ knows nothing of directories or opening of files.


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            A Offline
            A Offline
            Anka_Ame
            wrote on last edited by
            #5

            OpenFileDialog^ openf = gcnew OpenFileDialog(); openf->InitialDirectory = ("C:\\"); openf->Filter = "All files (*.*)|*.*|XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt"; It's something like that. I dont have errors, but it does not show me anything like filters and like initial directory.

            D P 2 Replies Last reply
            0
            • A Anka_Ame

              OpenFileDialog^ openf = gcnew OpenFileDialog(); openf->InitialDirectory = ("C:\\"); openf->Filter = "All files (*.*)|*.*|XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt"; It's something like that. I dont have errors, but it does not show me anything like filters and like initial directory.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              What is the value of openf->FilterIndex?


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              A 1 Reply Last reply
              0
              • D David Crow

                What is the value of openf->FilterIndex?


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                A Offline
                A Offline
                Anka_Ame
                wrote on last edited by
                #7

                openf->FilterIndex = 1;

                D 1 Reply Last reply
                0
                • A Anka_Ame

                  openf->FilterIndex = 1;

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Have you tried asking this question in the Managed C++ forum?


                  "A good athlete is the result of a good and worthy opponent." - David Crow

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  1 Reply Last reply
                  0
                  • A Anka_Ame

                    OpenFileDialog^ openf = gcnew OpenFileDialog(); openf->InitialDirectory = ("C:\\"); openf->Filter = "All files (*.*)|*.*|XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt"; It's something like that. I dont have errors, but it does not show me anything like filters and like initial directory.

                    P Offline
                    P Offline
                    prasad_som
                    wrote on last edited by
                    #9

                    I can run this code without any problem. And it behaves as expected. BTW, this question would be asked in C++/CLI forum.


                    Prasad MS MVP -  VC++

                    A 1 Reply Last reply
                    0
                    • P prasad_som

                      I can run this code without any problem. And it behaves as expected. BTW, this question would be asked in C++/CLI forum.


                      Prasad MS MVP -  VC++

                      A Offline
                      A Offline
                      Anka_Ame
                      wrote on last edited by
                      #10

                      It's working now. Thanks a lot for all your help.

                      P 1 Reply Last reply
                      0
                      • A Anka_Ame

                        It's working now. Thanks a lot for all your help.

                        P Offline
                        P Offline
                        prasad_som
                        wrote on last edited by
                        #11

                        :confused: . What change made it working ?


                        Prasad MS MVP -  VC++

                        A 1 Reply Last reply
                        0
                        • P prasad_som

                          :confused: . What change made it working ?


                          Prasad MS MVP -  VC++

                          A Offline
                          A Offline
                          Anka_Ame
                          wrote on last edited by
                          #12

                          I dont know exactly. I declared something else, but it didnt have to do with that function.:doh:

                          D G 2 Replies Last reply
                          0
                          • A Anka_Ame

                            I dont know exactly. I declared something else, but it didnt have to do with that function.:doh:

                            D Offline
                            D Offline
                            David Crow
                            wrote on last edited by
                            #13

                            Anka_Ame wrote:

                            I dont know exactly. I declared something else...

                            And you're satisifed with that resolution? Doesn't that indicate to you that you might have simply masked the problem rather than actually fixed it?


                            "A good athlete is the result of a good and worthy opponent." - David Crow

                            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                            1 Reply Last reply
                            0
                            • A Anka_Ame

                              I dont know exactly. I declared something else, but it didnt have to do with that function.:doh:

                              G Offline
                              G Offline
                              GuyM
                              wrote on last edited by
                              #14

                              What else did you declare? Please don't keep us in suspense ... ;P -- modified at 9:50 Wednesday 25th April, 2007

                              A 1 Reply Last reply
                              0
                              • G GuyM

                                What else did you declare? Please don't keep us in suspense ... ;P -- modified at 9:50 Wednesday 25th April, 2007

                                A Offline
                                A Offline
                                Anka_Ame
                                wrote on last edited by
                                #15

                                This is all the code of my interface in C++ #pragma once namespace Interfatafinala { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::IO; using namespace System::Globalization; using namespace System::Text; using namespace System::Collections::Generic; using namespace System::Data::SqlClient; using namespace System::Drawing; /// /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// /// Clean up any resources being used. /// ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::MenuStrip^ menuStrip1; protected: private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ newToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ openToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator; private: System::Windows::Forms::ToolStripMenuItem^ saveToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ saveAsToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator1; private: System::Windows::Forms::ToolStripMenuItem^ printToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ printPreviewToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator2; private: System::Windows::Forms::ToolStripMenuItem^ exitToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ editToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ undoToolStripMenuItem; private: System::Windows::Forms::ToolStripMenuItem^ redoToolStripMenuItem; private: System::Windows::Forms::ToolStripSeparator^ toolStripSeparator3; pr

                                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