Frame --> Exception



  • hehe code

    void __fastcall TForm13::Button2Click(TObject *Sender)
    {
    Frame2->Show();
    }
    

    Und Fehler:

    EAccessViolation
    Zugriffsverletzung bei Adresse 401067C4 in Modul vcl60.bpl. Lesen von Adresse 00000030.

    Mehr weiß ich auch nicht!



  • probier das mal :

    Irgendwo ist doch sicher die Zeile

    TFrame *Frame2=new TFrame(Application);
    

    füg dort bitte mal

    Frame2->Parent=Form1; (BZW den Namen deiner Form.)
    

    Wenn Du die erste Zeile oben nicht hast, ist das der Grund 🙂



  • Na ich erzeuge den Frame ja zur Entwicklungszeit...wo müsste das denn stehen, beim Frame oder in der Form wo Frame aufgerufen wird...konnte noch nix finden!



  • void __fastcall TForm1::Button1Click(TObject *Sender)
    {
      TFrame *frame2=new TFrame(Application);
      frame2->Color=0;
      frame2->Left=10;
      frame2->Top=10;
      frame2->Parent=Form1;
      frame2->Show();
    }
    

    Also ich habe das mal getestet, das funzt.

    Wenn Du den Frame schon zur entwicklungszeit erzeugst musst Du

    TFrame *frame2=new TFrame(Application);

    einfach weglassen.



  • Hmm...geht immer noch nicht....!



  • Ich habe das nochmal getestet...
    Du erzeugst ein Frame zur Entwicklungs Zeit, das heisst Du bindest eine neue UNIT ein z.B. Unit2.h.
    Du musst also dein Frame trotzdem mit new erzeugen, so wie oben beschrieben.



  • Unit1.cpp
    [cpp]
    //---------------------------------------------------------------------------

    #include <vcl.h>
    #pragma hdrstop

    #include "Unit1.h"
    #include "Unit2.h" <-- !!!
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent
    Owner)
    : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------

    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    TFrame2 *Frame2=new TFrame2(Application);
    Frame2->Color=0;
    Frame2->Left=10;
    Frame2->Top=10;
    Frame2->Parent=Form1;
    Frame2->Show();
    }
    //---------------------------------------------------------------------------
    [/cpp]

    Unit2.h

    #ifndef Unit2H
    #define Unit2H
    //---------------------------------------------------------------------------
    #include <Classes.hpp>
    #include <Controls.hpp>
    #include <StdCtrls.hpp>
    #include <Forms.hpp>
    //---------------------------------------------------------------------------
    class TFrame2 : public TFrame
    {
    __published:	// Von der IDE verwaltete Komponenten
            TButton *Button1;
            TCheckBox *CheckBox1;
    private:	// Anwender-Deklarationen
    public:		// Anwender-Deklarationen
            __fastcall TFrame2(TComponent* Owner);
    };
    //---------------------------------------------------------------------------
    extern PACKAGE TFrame2 *Frame2;
    //---------------------------------------------------------------------------
    #endif
    


  • Heißt das jetzt es Funzt ? 😕



  • Mom...ich konnte noch nich testen...keine angst ich halt dich auf dem laufenden!



  • Ja also es geht schonmal, bringt keinen Exception mehr und Frame zeigt er mir auch an =)!

    Danke erstmal!


Anmelden zum Antworten