Solved

VCL component :  don't paint

Posted on 2001-08-30
10
182 Views
Last Modified: 2010-04-06
Hi all,
  I'm writing a component heriting from TStringGrid1.
This component have (with others things) a method that try to detect "bad" records, and select them. The problem is that when I set the Row Property (i.e. Self.Row=X), the TStringGrid allways set itself the Leftcol valut to the first non-fixed col. So I'm doing something like this :

...
I:=Self.LeftCol;
Self.Row:=X;
Self.LeftCol:=I
...

It works but if the user scoll down continuously, the component blinks because it have to paint with after row has changed, ang again once after leftcol is sets to I;

Question is : Just before the instruction "Self.Row:=X" how can I disable the drawing, and enable it juste after Self.leftcol:=I ?

regards

(hope it's clear... :-)  )

Mike
0
Comment
Question by:gklux
10 Comments
 

Expert Comment

by:szjozsef
Comment Utility
I think the ideea is something like this,
you can disable the refresh by rows and columns with this commands.
stringgrid1.rows.BeginUpdate;
stringgrid1.cols.BeginUpdate;
....

stringgrid1.cols.EndUpdate;
stringgrid1.rows.EndUpdate;


Hope this help,
BestRegards,
JSz.


0
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
I have seen this bug before.

My guess is:

LockWindowUpdate(Handle);
try
  I:=Self.LeftCol;
  Self.Row:=X;
  Self.LeftCol:=I
finally
  LockWindowUpdate(0);
end;

LockWindowUpdate locks the painting of the window of the specified handle.

Regards Jacco
0
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Well it still flickers a bit....

Let me think...

Regards Jacco
0
 
LVL 2

Expert Comment

by:PeterLarsen
Comment Utility
I dont get it - i have added a comment to this question, but it's not here. And yet, i still getting mail notification about changes !!??!!
0
 
LVL 10

Accepted Solution

by:
Jacco earned 200 total points
Comment Utility
Hi there,

This is form based code I did not implement it in a component. I had to hack muy way to this solution. In a component the solution would not involve the "hack" because you can access the key method MoveColRow when you are inheriting from TStringGrid. A probhlem I had to figure out was that the goRowSelect option is also causing the LeftCol going back to FixedCol...

Regards Jacco

Here is a way to prevent the flickering:

type
  THack = class(TStringGrid);

procedure TForm1.sg1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
  liCol: Integer;
begin
  if Key = VK_DOWN then
  begin
    sg1.Options := sg1.Options - [goRowSelect];
    try
      THack(sg1).MoveColRow(sg1.LeftCol, sg1.Row + 1, True, True);
      Key := 0;
    finally
      sg1.Options := sg1.Options + [goRowSelect];
    end;
  end;
end;
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Are you still here? Does this work for you?

Regards Jacco
0
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Guess this question is abandoned...
0
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Hello?
0
 

Author Comment

by:gklux
Comment Utility
Hi Jacco !   :-))
Really sorry, I was in holidays....
Based from your answers, il finnaly found an acceptable solution for my component.  Thanks a lot.

regards

Mike
0
 

Author Comment

by:gklux
Comment Utility
thanks a lot, and sorry for the delay.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

14 Experts available now in Live!

Get 1:1 Help Now