Solved

which is the Order of execution of events in Delphi

Posted on 2004-09-08
14
187 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 79
error 1.1 400 Bad request idhttp delphi 18 87
Dev Express grid collapse 2 44
creating threads in delphi 1 104
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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