Solved

VCL component :  don't paint

Posted on 2001-08-30
10
183 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

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…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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