Autor Beitrag
Flamefire
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Mo 08.01.07 12:28 
Ich habe eine Funktion, die ausgeführt wird, wenn man auf einen Button klickt...
Diese dauert aber sehr lange, sodass ich einen Status dazu anzeigen will...
Jetzt ist aber das Problem, dass das Programm solange komplett ausgelastet ist, dass Anzeigen, neue Eingaben etc. erst gemacht werden, wenn die Funktion fertig ist
Kann ich den Ablauf i-wie in den "Hintergrund bringen"? also so, dass alles weiterabläuft und die Funktion die Stati in ein Label o.ä. ausgibt?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 08.01.07 13:09 
Moin und :welcome: im Forum!

Entweder du fügst Application.ProcessMessages; in deine Rechenschleife ein (aber nicht zu oft aufrufen, kostet sonst noch mehr Rechenzeit) oder du machst die Berechnung ein einem Suche in: Delphi-Forum, Delphi-Library THREAD.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Pille
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 105

Windows 7
DelphiXE Prof.
BeitragVerfasst: Mo 08.01.07 13:10 
Füge in die Fnktionsschleife ein
ausblenden Delphi-Quelltext
1:
Application.ProcessMessages					

ein.

mfg Pille
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Mo 08.01.07 15:09 
ok mit processmessages wirds schon gehen...
es gibt ja in delphi den fortschrittsbalken. ist der update des balkens bei processmessages dabei?
freedy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 403
Erhaltene Danke: 1

Winows 7
Delphi XE
BeitragVerfasst: Mo 08.01.07 15:13 
Wenn du einen neuen Wert in der Progressbar einstellst, wird diese beim nächsten Aufruf von ProcessMessages neugezeichnet. Aber vorsicht: nicht in jedem Zyklus neuzeichen. Die Progressbar verbraucht relativ viel Resourcen. Lieber ungefähr sowas:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
  for I := 0 to 1000 do 
  begin
    if (I mod 5 = 0then
    begin
      Application.ProcessMessages;
      // vielleicht noch was
    end;
    
    // blabla
  end;