Solved

which is the Order of execution of events in Delphi

Posted on 2004-09-08
14
196 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 23

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 23

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 23

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 23

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 23

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month10 days, 5 hours left to enroll

623 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