Solved

which is the Order of execution of events in Delphi

Posted on 2004-09-08
14
190 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
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

861 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