Warum kann ich auf eigene Methode nicht zugreifen?



  • Hallo, ich habe folgenden Quelltext mit dem Designer erstellt.

    #pragma once
    #include "dlgEvent.h"
    #include "Manager.h"
    
    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 CDAnalysis {
    	public ref class dlgCirculation : public System::Windows::Forms::Form
    	{
    	public:
    		dlgCirculation(void)
    		{
    			InitializeComponent();
    		}
    
    	protected:
    		~dlgCirculation()
    		{
    			if (components)
    			{
    				delete components;
    			}
    		}
    
        private: System::ComponentModel::IContainer^  components;
        private: System::Windows::Forms::ContextMenuStrip^  Menu;
        private: System::Windows::Forms::ToolStripMenuItem^  MenuSave;
        private: System::Windows::Forms::ToolStripMenuItem^  MenuCopy;
        private: System::Windows::Forms::Panel^  panelMenu;
        private: System::Windows::Forms::Button^  buttonSolution;
        private: System::Windows::Forms::Button^  buttonPrint;
        private: System::Windows::Forms::Button^  buttonSave;
        private: System::Windows::Forms::Panel^  panelImage;
        private: System::Windows::Forms::PictureBox^  Image;
    
        private:
            manager Manager;
    
        public:
            dlgEvent dlgEvents;
    
            bool Initialize(dlgEvent mydlgEvent, short Tension, short Current, short Resistor)
            {            
                return Manager.Initialize(Tension, Current, Resistor);
            }
    
    #pragma region Windows Form Designer generated code
    		void InitializeComponent(void)
    		{
                this->components = (gcnew System::ComponentModel::Container());
                System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(dlgCirculation::typeid));
                this->Menu = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
                this->MenuSave = (gcnew System::Windows::Forms::ToolStripMenuItem());
                this->MenuCopy = (gcnew System::Windows::Forms::ToolStripMenuItem());
                this->panelMenu = (gcnew System::Windows::Forms::Panel());
                this->buttonSolution = (gcnew System::Windows::Forms::Button());
                this->buttonPrint = (gcnew System::Windows::Forms::Button());
                this->buttonSave = (gcnew System::Windows::Forms::Button());
                this->panelImage = (gcnew System::Windows::Forms::Panel());
                this->Image = (gcnew System::Windows::Forms::PictureBox());
                this->Menu->SuspendLayout();
                this->panelMenu->SuspendLayout();
                this->panelImage->SuspendLayout();
                (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->Image))->BeginInit();
                this->SuspendLayout();
                // 
                // Menu
                // 
                this->Menu->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->MenuSave, this->MenuCopy});
                this->Menu->Name = L"Menu";
                this->Menu->RenderMode = System::Windows::Forms::ToolStripRenderMode::System;
                this->Menu->Size = System::Drawing::Size(133, 48);
                // 
                // MenuSave
                // 
                this->MenuSave->Name = L"MenuSave";
                this->MenuSave->Size = System::Drawing::Size(132, 22);
                this->MenuSave->Text = L"Save Image";
                // 
                // MenuCopy
                // 
                this->MenuCopy->Name = L"MenuCopy";
                this->MenuCopy->Size = System::Drawing::Size(132, 22);
                this->MenuCopy->Text = L"Copy Image";
                // 
                // panelMenu
                // 
                this->panelMenu->AutoScroll = true;
                this->panelMenu->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
                this->panelMenu->Controls->Add(this->buttonSolution);
                this->panelMenu->Controls->Add(this->buttonPrint);
                this->panelMenu->Controls->Add(this->buttonSave);
                this->panelMenu->Dock = System::Windows::Forms::DockStyle::Top;
                this->panelMenu->Location = System::Drawing::Point(5, 5);
                this->panelMenu->Name = L"panelMenu";
                this->panelMenu->Size = System::Drawing::Size(432, 33);
                this->panelMenu->TabIndex = 1;
                // 
                // buttonSolution
                // 
                this->buttonSolution->Location = System::Drawing::Point(165, 3);
                this->buttonSolution->Name = L"buttonSolution";
                this->buttonSolution->Size = System::Drawing::Size(75, 23);
                this->buttonSolution->TabIndex = 2;
                this->buttonSolution->Text = L"Solution";
                this->buttonSolution->UseVisualStyleBackColor = true;
                this->buttonSolution->Click += gcnew System::EventHandler(this, &dlgCirculation::buttonSolution_Click);
                // 
                // buttonPrint
                // 
                this->buttonPrint->Location = System::Drawing::Point(84, 3);
                this->buttonPrint->Name = L"buttonPrint";
                this->buttonPrint->Size = System::Drawing::Size(75, 23);
                this->buttonPrint->TabIndex = 1;
                this->buttonPrint->Text = L"Print";
                this->buttonPrint->UseVisualStyleBackColor = true;
                this->buttonPrint->Click += gcnew System::EventHandler(this, &dlgCirculation::buttonPrint_Click);
                // 
                // buttonSave
                // 
                this->buttonSave->Location = System::Drawing::Point(3, 3);
                this->buttonSave->Name = L"buttonSave";
                this->buttonSave->Size = System::Drawing::Size(75, 23);
                this->buttonSave->TabIndex = 0;
                this->buttonSave->Text = L"Save";
                this->buttonSave->UseVisualStyleBackColor = true;
                this->buttonSave->Click += gcnew System::EventHandler(this, &dlgCirculation::buttonSave_Click);
                // 
                // panelImage
                // 
                this->panelImage->AutoScroll = true;
                this->panelImage->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
                this->panelImage->Controls->Add(this->Image);
                this->panelImage->Dock = System::Windows::Forms::DockStyle::Fill;
                this->panelImage->Location = System::Drawing::Point(5, 38);
                this->panelImage->Name = L"panelImage";
                this->panelImage->Padding = System::Windows::Forms::Padding(5);
                this->panelImage->Size = System::Drawing::Size(432, 173);
                this->panelImage->TabIndex = 2;
                // 
                // Image
                // 
                this->Image->Dock = System::Windows::Forms::DockStyle::Fill;
                this->Image->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"Image.Image")));
                this->Image->Location = System::Drawing::Point(5, 5);
                this->Image->Name = L"Image";
                this->Image->Size = System::Drawing::Size(418, 159);
                this->Image->SizeMode = System::Windows::Forms::PictureBoxSizeMode::CenterImage;
                this->Image->TabIndex = 0;
                this->Image->TabStop = false;
                // 
                // dlgCirculation
                // 
                this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
                this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
                this->AutoScroll = true;
                this->ClientSize = System::Drawing::Size(442, 216);
                this->Controls->Add(this->panelImage);
                this->Controls->Add(this->panelMenu);
                this->MinimumSize = System::Drawing::Size(264, 250);
                this->Name = L"dlgCirculation";
                this->Padding = System::Windows::Forms::Padding(5);
                this->Text = L"Circulation Analysis";
                this->Menu->ResumeLayout(false);
                this->panelMenu->ResumeLayout(false);
                this->panelImage->ResumeLayout(false);
                (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->Image))->EndInit();
                this->ResumeLayout(false);
    
            }
    #pragma endregion
    private: System::Void buttonSave_Click(System::Object^  sender, System::EventArgs^  e)
             {
                 //
                 // Bild speichern
                 //
             }
    private: System::Void buttonPrint_Click(System::Object^  sender, System::EventArgs^  e) 
             {
                 //
                 // Bild drucken
                 //
             }
    private: System::Void buttonSolution_Click(System::Object^  sender, System::EventArgs^  e)
             {
                 //
                 // Fenser für Lösungsweg öffnen
                 //
             }
    };
    }
    

    Desweiteren habe ich unter "public:" ziehmlich weit oben eine eigene Methode "Initialize" eingebaut. Ich kann aber aus einer anderen Datei nicht auf diese Methode zugreifen. Warum nicht?

    Vielen Dank im voraus

    lg Baseball


    Anmelden zum Antworten
     


  • Wie ist denn die Fehlermeldung ?



  • Es gibt eigentlich keine Fehlermeldung. Ich versuche meine Methode so aufzurufen, wie ich auch die anderen aufrufe.

    private: System::Void MenuFileNew_Click(System::Object^  sender, System::EventArgs^  e)
             {
                 dlgNew mydlgNew;
                 mydlgNew.ShowDialog();
    
                 if (mydlgNew.radioCirculation->Checked == true)
                 {
                     Form^ mydlgCirculation = gcnew dlgCirculation;
    
                     mydlgCirculation->MdiParent = this;
    
                     // an dieser Stelle möchte ich meine
                     // Methode "Initialize();" aufrufen
    
                     mydlgCirculation->Initialize();
                     mydlgCirculation->Show();
                 }
             }
    

    Vielleicht ist das aber auch schon mein Fehler? Das Problem ist, dass der Compiler sie überhaupt nicht kennt bzw. akzeptiert.

    lg Baseball



  • Eigentlich keine Fehlermeldung? Das heisst das Programm compiliert? Na, dann ist doch alles ok.



  • Vielleicht taucht die Methode nur nicht in IntelliSense auf. Für manche Leute bricht da eine Welt zusammen.



  • Nein, so leicht ist es dann doch nicht. Der Fehler lautet :

    error C2039: 'Initialize' : is not a member of 'System::Windows::Forms::Form'

    Hat vielleicht noch jemand einen Vorschlag?

    lg Baseball



  • Du solltest vielleicht:

    Form^ mydlgCirculation = gcnew dlgCirculation;
    

    durch

    dlgCirculation^ mydlgCirculation = gcnew dlgCirculation;
    

    ersetzen...


Anmelden zum Antworten