[Fehler] Aus einem sichtbaren Fenster kann kein modales gemacht werden *Hilfe*
-
Hi!
Ich bekomm zurzeit diese Fehlermeldung, und verzweifle regelrecht daran.
Er kommt wenn ich ein zweites mal auf Hinzufügen klcike (Symptom.cpp -> TForm1::SystemHinzufuegenClick)
Seht ih den Fehler?Symptom.cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Symptom.h" #include "Hinzufuegen.h" #include "Inhaltsstoffe.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; int n; AnsiString *inhaltsstoffe; int m_ArrayInhaltsstoffeLength; bool ianzeigen; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { Liste->Cells[0][0] = "Essen"; Liste->Cells[1][0] = "Symptome"; Liste->Cells[2][0] = "Datum"; Liste->ColWidths[0] = 190; Liste->ColWidths[1] = 210; Liste->ColWidths[2] = 112; n = 0; inhaltsstoffe = new AnsiString[1]; m_ArrayInhaltsstoffeLength = 1; ianzeigen = false; Form3->setMenuItem(OptionenInhaltsstoffe, &ianzeigen); } //--------------------------------------------------------------------------- void __fastcall TForm1::DateiBeendenClick(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::SystemHinzufuegenClick(TObject *Sender) { Form2->updateDatum(); Form2->Caption = "Hinzufügen"; Form2->ShowModal(); bool abbruch = Form2->getAbbruch(); if(abbruch) { Form2->Essen->Text = ""; Form2->Symptome->Text = ""; Form2->Datum->Text = ""; Form2->Inhaltsstoffe->Text = ""; Form2->Enabled = false; Form2->AnAus->Checked = false; return; } Liste->Enabled = true; AnsiString essen = Form2->Essen->Text; AnsiString symptome = Form2->Symptome->Text; AnsiString datum = Form2->Datum->Text; if(n == m_ArrayInhaltsstoffeLength) { extendInhaltsstoffeArray(); } inhaltsstoffe[n] = Form2->Inhaltsstoffe->Text; if(n == 0) { Liste->Cells[0][1] = essen; Liste->Cells[1][1] = symptome; Liste->Cells[2][1] = datum; }else{ Liste->RowCount = n+2; Liste->Cells[0][n+1] = essen; Liste->Cells[1][n+1] = symptome; Liste->Cells[2][n+1] = datum; } n ++; Form2->Essen->Text = ""; Form2->Symptome->Text = ""; Form2->Datum->Text = ""; Form2->Inhaltsstoffe->Text = ""; Form2->Enabled = false; Form2->AnAus->Checked = false; } //--------------------------------------------------------------------------- void TForm1::extendInhaltsstoffeArray() { if(n == 0) { return; } AnsiString *dummy = new AnsiString[m_ArrayInhaltsstoffeLength+1]; for(int i = 0; i < m_ArrayInhaltsstoffeLength; i ++) { dummy[i] = inhaltsstoffe[i]; } inhaltsstoffe = new AnsiString[m_ArrayInhaltsstoffeLength+1]; for(int i = 0; i < m_ArrayInhaltsstoffeLength; i ++) { inhaltsstoffe[i] = dummy[i]; } m_ArrayInhaltsstoffeLength ++; } //--------------------------------------------------------------------------- void TForm1::reduceInhaltsstoffeArray(int stelle) { if(m_ArrayInhaltsstoffeLength == 1) { return; } AnsiString *dummy = new AnsiString[m_ArrayInhaltsstoffeLength-1]; for(int i = 0; i < stelle; i ++) { dummy[i] = inhaltsstoffe[i]; } for(int i = stelle; i < m_ArrayInhaltsstoffeLength-1; i ++) { dummy[i] = inhaltsstoffe[i+1]; } inhaltsstoffe = new AnsiString[m_ArrayInhaltsstoffeLength-1]; for(int i = 0; i < m_ArrayInhaltsstoffeLength-1; i ++) { inhaltsstoffe[i] = dummy[i]; } m_ArrayInhaltsstoffeLength --; } //--------------------------------------------------------------------------- void __fastcall TForm1::OptionenInhaltsstoffeClick(TObject *Sender) { OptionenInhaltsstoffe->Checked = !OptionenInhaltsstoffe->Checked; ianzeigen = OptionenInhaltsstoffe->Checked; if(!ianzeigen) { Form3->Close(); }else{ Form3->Show(); } } //--------------------------------------------------------------------------- void __fastcall TForm1::ListeClick(TObject *Sender) { if(ianzeigen) { int auswahl = Liste->Row; auswahl --; Form3->Inhaltsstoffe->Text = inhaltsstoffe[auswahl]; } } //--------------------------------------------------------------------------- void __fastcall TForm1::SystemAendernClick(TObject *Sender) { int auswahl = Liste->Row; auswahl --; Form2->Caption = "Ändern"; Form2->Essen->Text = Liste->Cells[0][auswahl+1]; Form2->Symptome->Text = Liste->Cells[1][auswahl+1]; Form2->Inhaltsstoffe->Text = inhaltsstoffe[auswahl]; Form2->Datum->Text = Liste->Cells[2][auswahl+1]; Form2->ShowModal(); bool abbruch = Form2->getAbbruch(); if(abbruch) { Form2->Essen->Text = ""; Form2->Symptome->Text = ""; Form2->Datum->Text = ""; Form2->Inhaltsstoffe->Text = ""; Form2->Enabled = false; Form2->AnAus->Checked = false; return; } Liste->Cells[0][auswahl+1] = Form2->Essen->Text; Liste->Cells[1][auswahl+1] = Form2->Symptome->Text; inhaltsstoffe[auswahl] = Form2->Inhaltsstoffe->Text; Liste->Cells[2][auswahl+1] = Form2->Datum->Text; Form2->Essen->Text = ""; Form2->Symptome->Text = ""; Form2->Datum->Text = ""; Form2->Inhaltsstoffe->Text = ""; Form2->Enabled = false; Form2->AnAus->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TForm1::SystemLoeschenClick(TObject *Sender) { int auswahl = Liste->Row; int anzahl = Liste->RowCount; if(Liste->RowCount == 2) { Liste->Cells[0][1] = ""; Liste->Cells[1][1] = ""; Liste->Cells[2][1] = ""; Liste->Enabled = true; }else{ for(int i = auswahl; i <= Liste->RowCount; i ++) { Liste->Cells[0][i] = Liste->Cells[0][i+1]; Liste->Cells[1][i] = Liste->Cells[1][i+1]; Liste->Cells[2][i] = Liste->Cells[2][i+1]; Liste->RowCount = anzahl - 1; } } reduceInhaltsstoffeArray(auswahl-1); n --; } //---------------------------------------------------------------------------Hinzufügen.cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Hinzufuegen.h" #include "time.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm2 *Form2; bool abbruch; //--------------------------------------------------------------------------- __fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner) { abbruch = true; TDateTime DateTime = Time(); AnsiString zeit = TimeToStr(DateTime.CurrentTime()); AnsiString datum = DateToStr(DateTime.CurrentDate()); Datum->Text = datum + ", " + zeit; } //--------------------------------------------------------------------------- void __fastcall TForm2::AbbrechenClick(TObject *Sender) { abbruch = true; Close(); } //--------------------------------------------------------------------------- void __fastcall TForm2::SpeichernClick(TObject *Sender) { abbruch = false; Close(); } //--------------------------------------------------------------------------- void __fastcall TForm2::AnAusClick(TObject *Sender) { bool checked = AnAus->Checked; if(checked) { Datum->Enabled = true; }else{ Datum->Enabled = false; } } //--------------------------------------------------------------------------- void TForm2::updateDatum() { abbruch = true; TDateTime DateTime = Time(); AnsiString zeit = TimeToStr(DateTime.CurrentTime()); AnsiString datum = DateToStr(DateTime.CurrentDate()); Datum->Text = datum + ", " + zeit; } //--------------------------------------------------------------------------- bool TForm2::getAbbruch() { return abbruch; } //---------------------------------------------------------------------------Inhaltsstoffe.cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Inhaltsstoffe.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm3 *Form3; TMenuItem *tmi; bool ia; //--------------------------------------------------------------------------- __fastcall TForm3::TForm3(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void TForm3::setMenuItem(TMenuItem *t, bool *b) { tmi = t; } void __fastcall TForm3::OnClose(TObject *Sender, TCloseAction &Action) { tmi->Checked = false; ia = false; } //---------------------------------------------------------------------------thx
-
Hallo
Dieser Fehler kommt wenn ein Fenster bereits angezeigt wird (durch Show, Visible ist true) und ohne das dieses Fenster geschlossen wird für dieses Form ShowModal aufgerufen wird. Ich hab beim Überfliegen deines Codes keine solche Stelle finden können, aber vermutlich ergibt sich der Fehler in zusammenhang mit dem Code aus den anderen Forms. Benutzt den Debuger um den Programmablauf bei dir zu verfolgen und den Status der Forms zu prüfen.
bis bald
akari
-
Hab den Fehler gefunden.
Habe was vergessen.

-> Form2->Enabled = false;
sollte Form2->Datum->Enabled = false;
heißen.
THX
