Process Messages

Hi.

I have 2 forms.
In form 1 there is a timer that sends data to a graph in the second form.
For those values i calculate the Max, min and average values. (Unit1)

There is a big problem with those values when i move the form2.

Application seems paused. No values are drawn in the graph BUT when i stop moving
the form then ALL the values that happened between 10 or more seconds ... are stacked in 1 second..

Example :

 Second     :   |  1  |  |  2  |  |  3  |  |  4  |  |  5  |  |  6  |  |  7  |  |  8  |
 Value       :   | 15  |  | 40 |  |  4  |  | 28 |  | 35 |   | 5  |   | 18 |  | 19 |  ---> Random Values
--------------------------------------------------------------------------------------
When i move the form :

 Second     :   |  1  |...| 15 |  | 16 |  | 17 |  | 18 |  | 19 | ... --> Move the form for 15 seconds
 Value       :   | 15  |  | 800 |  |  4  | | 28 |  | 35 |   | 5  | ... --> All that happened between 2-14 are in the 15th sec.

I tried to put Application ProcessMessages in several places but nothing.
This doesnt happen when i move form1.

What should i do?
Thanks in advance.
LVL 16
CodedKAsked:
Who is Participating?
 
geobulCommented:
Hi,

I made a simple experiment with just a label on the second form and the following code in form one's timer event:

uses unit2;

var
  count: integer = 0;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if Form2.Visible then begin
    Form2.Label1.Caption := IntToStr(count);
    count := count + 1;
  end;
end;

The result was that the label continued counting while I was moving the form around. So, I suppose your problem might be in that graph component you're using.
What type is it actually?

Regards, Geo
0
 
CodedKAuthor Commented:
Hi Geo. Thanks for your response :)

Well its strange. Seems like a side effect on slow machines.
Recently i've replaced my video card with a very old one.
The problem was fixed when i turned off hardware acceleration.

I've used Teechart, the one that is embedded in Delphi 7.

You could reproduce this side effect like this:
UNIT1 :
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Inc(i);
Flow:=Random(1000);
If Flow>Max then Max:=Flow; // This value will never go above 1000.
Form2.Label1.Caption:='Current Max : '+IntToStr(Max);
Form2.Chart1.SeriesList.Series[0].AddXY(i,Max);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled:=True;
Form2.Show;
end;
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-

Now if you press down and hold the (x) close button without closing the application and after some seconds
remove the mouse from the (x) button (keep the mouse button down)
the graph will stop moving. The value stops giving feedback also..

But the strange thing is that in my other app the form1 is giving feedback from the values BUT the GUI freezes
and when i stop press the (x) close button all the values rise (for example above 1000) !

Anyway since the problem is gone i'm only curious why in my other app the timer keeps going when the whole app is freezed.

I'll close this question soon :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.