C++ Interface
-
How can I establish the initial directory and the filter for open file in C++ ? Please help...
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 ... :)
-
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 ... :)
-
How can I establish the initial directory and the filter for open file in C++ ? Please help...
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
-
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
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.
-
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.
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
-
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
-
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
-
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.
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++
-
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++
-
:confused: . What change made it working ?
Prasad MS MVP - VC++
-
:confused: . What change made it working ?
Prasad MS MVP - VC++
-
I dont know exactly. I declared something else, but it didnt have to do with that function.:doh:
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
-
I dont know exactly. I declared something else, but it didnt have to do with that function.:doh:
-
What else did you declare? Please don't keep us in suspense ... ;P -- modified at 9:50 Wednesday 25th April, 2007
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