Solved

VCL component :  don't paint

Posted on 2001-08-30
10
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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 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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month4 days, 15 hours left to enroll

635 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