Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VCL component :  don't paint

Posted on 2001-08-30
10
Medium Priority
?
192 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 800 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

721 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