Solved

which is the Order of execution of events in Delphi

Posted on 2004-09-08
14
184 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now