Solved

which is the Order of execution of events in Delphi

Posted on 2004-09-08
14
195 Views
Last Modified: 2010-04-05
Hi there!!!

I wonder where i can found the order of execution of events of a TStringGrid,
i mean what happens after OnDrawCell because i need to use a value given on this event
but after it happens....
Because if i use the value inside of it, i get many times the value.....

 
0
Comment
Question by:BaTy_GiRl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 6

Expert Comment

by:bpana
ID: 12007946
put an ShowMessage in each event and you'll find the order
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12007959
Ther's not a specified order in this case....
DrawCell is called for every cell on every grid paint...repaint...refresh and so on
What do you need exactly?
0
 

Author Comment

by:BaTy_GiRl
ID: 12008014
i use a flag=true when any of the cells are red,
then i need to use this flag for send a message, but if i put the message inside the event
logical it paints the message for each cell
 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 12008049
guess,
the red coloring of the cell depends on a value,
why not send your message, when you set the value?
0
 

Author Comment

by:BaTy_GiRl
ID: 12008073
because i want to get only one message if any of them is red
look at this:


procedure Tfrm_results2.sg_statusDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var treq, tav:double;
    a,c:integer;
    tr,ta,aux,aux2:string;
    cl:Tcolor;
begin
  if (ACol>3) and (ARow > lb_phantomnpens.Items.Count+2) then
  begin
    if (IsSeries(ACol)) and (sg_status.Cells[ACol,ARow]<>'') then
     begin
       aux:=sg_status.cells[ACol,lb_phantomnpens.Items.Count+3];
       a:=pos(':',aux);
       tr:=MidStr(aux,a+1,length(aux));
       treq:= strtofloat(tr);
       aux2:= sg_status.cells[ACol+1,lb_phantomnpens.Items.Count+3];
       a:=pos(':',aux2);
       ta:=MidStr(aux2,a+1,length(aux2));
       tav:= strtofloat(ta);
       if treq>tav then
       begin
         cl:=clRed;
         AreAnyRed:=True;
       end
       else cl:=clGreen;
       sg_status.Canvas.Brush.Color:=cl;
       sg_status.Canvas.FillRect(Rect);
       sg_status.Canvas.TextOut(Rect.Left+2,Rect.Top+2,sg_status.Cells[ACol, ARow]);
     end;
  end;
  if (AreAnyRed=True) then showmessage('Existen dias que no pueden satisfacer la demanda!!!, porfavor de click en los recuadros de color para hacer los cambios necesarios'); //i m just tryng to get only one message
end;
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12008075
Guessing that the flag is used by the message itself, btw as you already have it use it like

If cell is red and not flag = true then begin
   flag = true;
   sendmessage(with flag)
end
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12008144
Or test when the painting cell is the last one
if (AreAnyRed=True) and (acol = sg_status.colcount-1) and (arow = sg_status.rowcount-1) then...
0
 

Author Comment

by:BaTy_GiRl
ID: 12008168
hmmmmm let me test !!!!
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 50 total points
ID: 12008190
Or add another boolean var like Found and do
if AreAnyRed and not found then begin
   found := True;
   showmessage('Existen dias que no pueden satisfacer la demanda!!!, porfavor de click en los recuadros de color para hacer los cambios necesarios'); //i m just tryng to get only one message
   end;

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 12008194
>because i want to get only one message if any of them is red
>look at this:

but if this red cell is out of view, it will never be painted -> a message will never send, even it should

what about to simple iterate through the value and check the values,
if comes one/more cells to the red-condition, send your message

just as suggestion

meikl ;-)
0
 

Author Comment

by:BaTy_GiRl
ID: 12008224

ok =) the last one was a great idea!!!!, thank you very much my friend....

Greetings
B@ty
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 12008246
Glad to have helped you :)

F68 ;-)
0
 

Author Comment

by:BaTy_GiRl
ID: 12008261
hey i made a mistake with the aceppted answer
because th good one was :

>Ferruccio68 Said:

>Or test when the painting cell is the last one
>if (AreAnyRed=True) and (acol = sg_status.colcount-1) and (arow = sg_status.rowcount-1) then...

so anyway  thanks to all
=)
0
 

Author Comment

by:BaTy_GiRl
ID: 12008549
well both of them was usefull, but finaly i decided to use

>Or add another boolean var like Found and do
>if AreAnyRed and not found then begin
>   found := True;
>   showmessage('Existen dias que no pueden satisfacer la demanda!!!, porfavor de click en los recuadros de color >para hacer los cambios necesarios'); //i m just tryng to get only one message
>   end;

because the idea of "check if the painting cell are the last", made the execution a little slow....

=)-
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question