OpenFileDialog ???
-
Ok, das ist mein aktueller Stand:
[cpp] #pragma once namespace P8_ASG { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; using namespace Eplan::EplApi::System; using namespace Eplan::EplApi::ApplicationFramework; using namespace Eplan::EplApi::Base; using namespace Eplan::EplApi::DataModel; using namespace Eplan::EplApi::HEServices; // using namespace Microsoft::Office::Interop; //Das geht auch nicht ! //using namespace Microsoft::Office::Interop::Excel; //Das geht auch nicht ! //using namespace System::Reflection; //Das geht auch nicht ! //Erstes Fenster erstellen public ref class MainFrame : public System::Windows::Forms::Form { //Eplan Variablen private: EplApplication ^oApp; private: LockingStep ^ oLockingStep; //Setup-Variablen private: String ^ strMacroProject; private: String ^ strDestinationProject; private: String ^ strLeftPlaceHolder; private: String ^ strRightPlaceHolder; private: String ^ strFirstRow; private: String ^ strFirstCol; private: String ^ strMacroRow; private: String ^ strMacroPath; private: String ^ strProjectTemplate; //Excel-Variablen private: Microsoft::Office::Interop::Excel::Application ^ oXL; private: Microsoft::Office::Interop::Excel::Workbook ^ xlWorkbook; private: Microsoft::Office::Interop::Excel::Worksheet ^ xlWorksheetSetup; private: Microsoft::Office::Interop::Excel::Worksheet ^ xlWorksheetGenerate; //Form-Variablen private: System::Windows::Forms::OpenFileDialog^ openFileDialog1; private: System::Windows::Forms::Label^ lblGenTable; private: System::Windows::Forms::TextBox^ txtGenTable; public: MainFrame(void) { InitializeComponent(); //P8 Framework initialisieren oApp = gcnew EplApplication(); oApp->Init(""); //"LockingStep"-Objekt erzeugen oLockingStep = gcnew LockingStep(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~MainFrame() { if (components) { delete components; } } private: System::Windows::Forms::Button^ btnGenTable; protected: protected: private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->btnGenTable = (gcnew System::Windows::Forms::Button()); this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog()); this->lblGenTable = (gcnew System::Windows::Forms::Label()); this->txtGenTable = (gcnew System::Windows::Forms::TextBox()); this->SuspendLayout(); // // btnGenTable // this->btnGenTable->Location = System::Drawing::Point(804, 29); this->btnGenTable->Name = L"btnGenTable"; this->btnGenTable->Size = System::Drawing::Size(88, 21); this->btnGenTable->TabIndex = 0; this->btnGenTable->Text = L"&Öffnen"; this->btnGenTable->UseVisualStyleBackColor = true; this->btnGenTable->Click += gcnew System::EventHandler(this, &MainFrame::btnGenTable_click); // // openFileDialog1 // this->openFileDialog1->FileName = L"openFileDialog1"; // // lblGenTable // this->lblGenTable->AutoSize = true; this->lblGenTable->Location = System::Drawing::Point(12, 9); this->lblGenTable->Name = L"lblGenTable"; this->lblGenTable->Size = System::Drawing::Size(85, 13); this->lblGenTable->TabIndex = 1; this->lblGenTable->Text = L"Generatortabelle"; // // txtGenTable // this->txtGenTable->Location = System::Drawing::Point(17, 30); this->txtGenTable->Name = L"txtGenTable"; this->txtGenTable->Size = System::Drawing::Size(781, 20); this->txtGenTable->TabIndex = 2; // // MainFrame // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(904, 607); this->Controls->Add(this->txtGenTable); this->Controls->Add(this->lblGenTable); this->Controls->Add(this->btnGenTable); this->Name = L"MainFrame"; this->Text = L"Generator by DDT GmbH"; this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &MainFrame::MainFrame_FormClosing); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void MainFrame_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e) { //Sperrschritt löschen delete oLockingStep; //Eplan-API-Framework deinitialisieren oApp->Exit(); } private: System::Void btnGenTable_click(System::Object^ sender, System::EventArgs^ e) //Generatortabelle auswählen { System::IO::Stream ^ myStream; //Wenn Pfad im Textfeld existiert, vorbelegen if(txtGenTable->Text !="") { if (Directory::Exists(Path::GetDirectoryName( txtGenTable->Text))) {openFileDialog1->InitialDirectory = Path::GetDirectoryName( txtGenTable->Text);} else {openFileDialog1->InitialDirectory = "c:\\";} //Wenn Datei im Textfeld existiert, vorbelegen if (File::Exists( txtGenTable->Text)) {openFileDialog1->FileName = Path::GetFileName( txtGenTable->Text);} else {openFileDialog1->FileName = "";} } else { openFileDialog1->FileName = ""; } openFileDialog1->Filter = "Excel (*.xls)|*.xls|Alle Dateien (*.*)|*.*"; openFileDialog1->FilterIndex = 1; openFileDialog1->RestoreDirectory = true; if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK ) { if ( (myStream = openFileDialog1->OpenFile()) != nullptr ) { // Dateiname in Textbox eintragen. txtGenTable->Text=openFileDialog1->FileName; // prüfen ob Setup-Sheet existiert. //Anwendung starten oXL = gcnew Microsoft::Office::Interop::Excel::Application(); oXL->Visible=true; //Workbook öffnen xlWorkbook = oXL->Workbooks->Open(txtGenTable->Text, Type::Missing,Type::Missing,Type::Missing, Type::Missing,Type::Missing,Type::Missing, Type::Missing,Type::Missing,Type::Missing, Type::Missing,Type::Missing,Type::Missing, Type::Missing,Type::Missing); for(int i;i<=xlWorkbook->Worksheets->Count;i++) { //KEINE AHNUNG WIE ICH DIE NAMEN DER SHEETS ERMITTLE /*xlWorksheetGenerate = xlWorkbook->Worksheets; MessageBox::Show(Convert::ToString(i));*/ } //xlWorkbook = oXL.Workbooks.Open(txtGenTable->Text, 0, true, 5,"", "", true, Excel.XlPlatform.xlWindows, "\t", true, false, 0, true); // MessageBox::Show(openFileDialog1->FileName,"Meldung"); // Excel schließen oXL->Quit; myStream->Close(); } } } }; } [/cpp]
Unten ist noch etwas Excel-Mist vom Probieren drin.
Gruss Carsten
-
Wenn Du den Thread mal komplett durchliest, findest Du sogar die Frage nach der Beilage für den Entenbraten von LordJaxom geklärt vor.
-
::DialogResult sagt aus, dass DialogResult auf globaler Namespace-Ebene zu stehen habe. Das ist aber nur der Fall, wenn Du den Namespace, der DialogResult enthält, auf globaler Namespace-Ebene importierst.
@Knuddelbär...
Jau, gelesen hab ich das...
Aber wie importiere ich den entsprechenden Namespace auf globaler Namespace-Ebene ?
-
Das war auf Dough_HH bezogen, das mit der Ente ;o)
Dough_HH hat aber auch das Beispiel dafür geliefert:
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; using namespace Eplan::EplApi::System; using namespace Eplan::EplApi::ApplicationFramework; using namespace Eplan::EplApi::Base; using namespace Eplan::EplApi::DataModel; using namespace Eplan::EplApi::HEServices; namespace P8_ASG {
Das using namespace xyz; muss außerhalb aller Namespaces stehen - eben Global. Dann kannst Du mit :: auch Global referenzieren. Alternativ das was Lord schrieb, P8_ASG::<blablubb>
-
Jau
und wenn Du den Threat mal komplett gelesen hättest, hättest Du auch gelesen, dass genau das auch nicht gefunzt hat
...sonst müsste Intellisense mir das ja auch anbieten.
Tut es aber nicht.Keine Ahnung, wo es hakt...
Aber was solls, schreib ichs halt aus.Danke für Deine Mühe.
-
Würdest Du gescheit Posten wäre Dir aufgefallen das ein "Geht nicht" keine Fehlermeldung ist.
#pragma once using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace test { public ref class Form1 : public System::Windows::Forms::Form { System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { OpenFileDialog ^ dlg = gcnew OpenFileDialog(); if(dlg->ShowDialog() == ::DialogResult::OK) return; } }; }
Funktioniert ohne jegliche Fehler oder Fehlermeldungen genauso wie ein
#pragma once namespace test { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { OpenFileDialog ^ dlg = gcnew OpenFileDialog(); if(dlg->ShowDialog() == test::DialogResult::OK) return; } }; }
...sonst müsste Intellisense mir das ja auch anbieten.
Die Begründung ist einfach Klasse und klärt doch einige ungestellte Fragen ;o)
-
Dass Intellisense dialogResult nicht anbietet war eine Feststellung!
Ich war davon ausgegangen, dass VS mit dem Namespace auch automatisch Intellisense aktualisiert. Da war ich wohl zu optimistisch und bin davon ausgegangen, wenn nix im Angebot, geht's auch nicht.
Naja, wundern tut mich bei dieser Programmierumgebung jetzt auf jeden Fall nichts mehr.
Ich nehme hiermit meinen vorigen Threat zurück und behaupte das Gegenteil
-
Hallo,
vorweg, ich muss unsere alte Eplan 5.x EXF-Anwendungen auf P8 umstellen. Kann mir jemand mit Beispielen für die Anbindung bzw. für den Zugriff auf Eplan P8-Projekte helfen. Ich habe keine Beschreibung. Im Netz habe ich nichts gefunden.
Danke
Thomas
-
Globetrotter schrieb:
vorweg, ich muss unsere alte Eplan 5.x EXF-Anwendungen auf P8 umstellen. Kann mir jemand mit Beispielen für die Anbindung bzw. für den Zugriff auf Eplan P8-Projekte helfen. Ich habe keine Beschreibung. Im Netz habe ich nichts gefunden.
Vorweg, wie kommst Du darauf, dass diese Frage auf Seite drei eines über einen Jahr alten Threads mit völlig anderem Thema gut aufgehöben wäre?
-
Eigentlich, weil ich keine bessere Stelle gefunden habe, wo ich mir etwas Hilfe holen konnte.