Meldungen sofort anzeigen



  • ich habe ein Programm geschrieben das die Primzahlen ausrechnet.

    status und Primtahlen sind trichedits

    //---------------------------------------------------------------------------
    
    #include <vcl.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    bool fertig;
    bool start;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    
    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
     Primzahlen->Text = "";
    
      Primzahlen->ReadOnly = true;
       Status->Text = "";
      Status->ReadOnly = true;
    
     fertig = false;
     start = true;
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
          TShiftState Shift)
    {
    //Notabschalten mit ESC
    
    if (GetAsyncKeyState(0x1B) < 0)
      {
      fertig = true;
      Start->Caption = "Stopp";
            start = false;
      }
    }
    //---------------------------------------------------------------------------
    
    void __fastcall TForm1::StartClick(TObject *Sender)
    {
    bool pzahl;
    Status->Lines->Add("Startbutton geklickt");
    if (start == true)
    {
    Start->Caption = "Stopp";
    start = false;
    
    fertig = false;
    int Zahl;
    Zahl = StrToInt(Startzahl->Text);
    
    int stoppzahl;
    stoppzahl = StrToInt(Stoppzahl->Text);
    
    Status->Lines->Add("Kurz vor der schleife");
    while (Zahl <= stoppzahl)
    {
    Status->Lines->Add("Erste Schleife erreich");
    
    int i = 2;
    while (i < Zahl)
    {
    pzahl = true;
    
    Status->Lines->Add("Zweite Schleife erreich");
    
    if (Zahl % i == 0)  //Wenn keine Primzahl
    {
    i = Zahl;
    pzahl = false;
    }
    i++;
    }
    
    if (pzahl)
    {
    Primzahlen->Lines->Add(String(Zahl));
    Edit1->Text = String(Zahl);
    Sleep(5);
    }
    
    Zahl ++;
    }
    Status->Lines->Add("hinter der schleife");
    
    }else{
    Start->Caption = "Start";
    start = true;
    }
    
    }
    //---------------------------------------------------------------------------
    

    Die Meldungen bei status werden noch eährend des rechnens angezeigt bei Primzahlen und Edit1 aber nicht .

    Ich habe keinen Schimmer woran das leigt.

    MfG kevka



  • ProcessMessages();


Anmelden zum Antworten