Solved

VCL component :  don't paint

Posted on 2001-08-30
10
184 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
ID: 6443811
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
ID: 6445835
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
ID: 6445884
Well it still flickers a bit....

Let me think...

Regards Jacco
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 2

Expert Comment

by:PeterLarsen
ID: 6445930
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
ID: 6445932
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
 
LVL 10

Expert Comment

by:Jacco
ID: 6455683
Are you still here? Does this work for you?

Regards Jacco
0
 
LVL 10

Expert Comment

by:Jacco
ID: 6470873
Guess this question is abandoned...
0
 
LVL 10

Expert Comment

by:Jacco
ID: 6484454
Hello?
0
 

Author Comment

by:gklux
ID: 6496636
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
ID: 6496651
thanks a lot, and sorry for the delay.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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