Recent

Author Topic: worksheetgrid and 'use manifest resource'  (Read 2814 times)

kjteng

  • Sr. Member
  • ****
  • Posts: 259
worksheetgrid and 'use manifest resource'
« on: October 13, 2019, 11:01:24 am »
I have two exe files with the same source code. First file (proj1.exe) was compiled with project options > application > use manifest resource (checked) and the second file (proj2.exe) was compiled without 'use manifest' (unchecked).

I noticed that the worksheetgrid in the seond file (Proj2.exe) flickers when I scroll the grid but this does not occurs in proj1.exe.  I did not change the doublebuffer property  i.e.  it is default to False.
May I know what is the reason for ths ?
(Source file and xlsx file attached .... Perhaps this is not a problem of the grid but the rendering of graphics ?)
 

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: worksheetgrid and 'use manifest resource'
« Reply #1 on: October 13, 2019, 12:47:44 pm »
What is your OS? I am on Win10, and don't see any flicker, even when I turn theme-support off in your demo.

I fixed a flickering issue some time ago, probably r6191. This was caused by unnecessary repaints of the entire grid. I don't know ATM whether this fix is contained in any released version already. To make sure you should use trunk from svn, or you could replace "TsCustomWorksheetGrid.MouseMove" in fpspreadsheetgrid.pas by the following code (of course, make a backup copy of the modified file):

Code: Pascal  [Select][+][-]
  1. procedure TsCustomWorksheetGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
  2. {
  3.   --- wp: removed this for testing: why does the entire grid be repainted when the
  4.           mouse moved to another cell?
  5. var
  6.   prevMouseCell: TPoint;
  7. }
  8. begin
  9.   if Worksheet = nil then
  10.     exit;
  11.  
  12. {  --- wp
  13.   prevMouseCell := GCache.MouseCell;
  14. }
  15.  
  16.   inherited;
  17.  
  18.   if MouseOnHeader(X,Y) then
  19.     exit;
  20.  
  21. { --- wp
  22.   if FTextOverflow and
  23.      ((prevMouseCell.X <> GCache.MouseCell.X) or (prevMouseCell.Y <> GCache.MouseCell.Y))
  24.   then
  25.     InvalidateGrid;
  26. }
  27.  
  28.   if Assigned(Dragmanager) and DragManager.IsDragging then
  29.   begin;
  30.     Cursor := crDefault;
  31.   end else
  32.   begin
  33.     if FHyperlinkTimer.Enabled and (ssLeft in Shift) then
  34.       FHyperlinkTimer.Enabled := false;
  35.  
  36.     if MouseOnCellBorder(Point(X, Y), Selection) then
  37.       Cursor := crSize
  38.     else
  39.       Cursor := crDefault;
  40.   end;
  41. end;

kjteng

  • Sr. Member
  • ****
  • Posts: 259
Re: worksheetgrid and 'use manifest resource'
« Reply #2 on: October 13, 2019, 03:44:21 pm »
I am using window 7.

I checked my version of fpspread, and found that the code is slightly different from the above (see the line with ended '//<<<<<<<' ). I changed 'FDragTimer.Enabled := true' to  'Cursor := crSize'...Still the same.

from svn 7148:
Code: Pascal  [Select][+][-]
  1. procedure TsCustomWorksheetGrid.MouseMove(Shift: TShiftState; X, Y: Integer);
  2. begin
  3.   if Worksheet = nil then
  4.     exit;
  5.  
  6.   inherited;
  7.  
  8.   if MouseOnHeader(X,Y) then
  9.     exit;
  10.  
  11.   if Assigned(Dragmanager) and DragManager.IsDragging then
  12.   begin
  13.     Cursor := crDefault;
  14.   end else
  15.   begin
  16.     if FHyperlinkTimer.Enabled and (ssLeft in Shift) then
  17.       FHyperlinkTimer.Enabled := false;
  18.  
  19.     if MouseOnCellBorder(Point(X, Y), Selection) then
  20.       FDragTimer.Enabled := true                                      //<<<<<<<
  21.       Cursor := crDefault;
  22.   end;
  23. end;  

kjteng

  • Sr. Member
  • ****
  • Posts: 259
Re: worksheetgrid and 'use manifest resource'
« Reply #3 on: October 13, 2019, 03:56:40 pm »
I copied the exe files to another notebook with windows 10 to test. Proj2 still has the flickering problem.

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: worksheetgrid and 'use manifest resource'
« Reply #4 on: October 13, 2019, 09:14:46 pm »
Your code is the most recent one, the code that I posted is the immediate change by r6191.

What EXACTLY are you doing when the grid flickers? What does "drag" mean to you? Drag the scrollbars? Drag a cell at its border? Drag the form size? Drag the mouse with button pressed to increase/decrease the selection rectangle? Just move the mouse over the grid, no mouse button pressed?

My computer only uses the built-in graphics processor, no dedicated graphics card. So, it certainly is not the fastest.


kjteng

  • Sr. Member
  • ****
  • Posts: 259
Re: worksheetgrid and 'use manifest resource'
« Reply #5 on: October 14, 2019, 05:56:02 am »
...
What EXACTLY are you doing when the grid flickers? What does "drag" mean to you? Drag the scrollbars? Drag a cell at its border? Drag the form size? Drag the mouse with button pressed to increase/decrease the selection rectangle? Just move the mouse over the grid, no mouse button pressed?
...
No. I did not mentioned 'Drag'.  Just select a cell or click on a cell in the grid, the grid will blink.
The video clip below shows how the grid flickers:
https://www.dropbox.com/preview/Public/grid.mpg

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: worksheetgrid and 'use manifest resource'
« Reply #6 on: October 14, 2019, 10:23:29 am »
The link to the video does not work for me.

I tried your demo in a VM with Win7, no flicker when clicking into the grid, no flicker when dragging the scrollbars.

What is your Lazarus version? I know that there was some flickering-related rework maybe a year ago; for some time, doublebuffered had to be switched on to reduce flickering.

Sorry for the "drag". I know that you had written "scroll", but typed "drag". Getting old...

kjteng

  • Sr. Member
  • ****
  • Posts: 259
Re: worksheetgrid and 'use manifest resource'
« Reply #7 on: October 14, 2019, 02:21:34 pm »
The link to the video does not work for me....
What can I do to make it work (should I convert it into other format)? 
Basically when I click select a cell the whole grid would be repainted.
I am using lazarus 1.8.4


wp

  • Hero Member
  • *****
  • Posts: 11854
Re: worksheetgrid and 'use manifest resource'
« Reply #8 on: October 14, 2019, 05:48:00 pm »
OK, with Laz 1.8.4 I do see an indication of flicker. It is not strong here but I can imagine that it can be an issue on other (slower or faster - I don't know) computers.

I do not see the flicker on Laz 2.0.4 any more - so maybe a motivation for you to upgrade? But if you want to stick with 1.8.4 you can also add a "WorksheetGrid.DoubleBuffered := true" to the OnCreate event of the form and the flicker will be gone.

kjteng

  • Sr. Member
  • ****
  • Posts: 259
Re: worksheetgrid and 'use manifest resource'
« Reply #9 on: October 15, 2019, 01:51:26 am »
Thanks for your reply.
Since Laz 2.0.6 is coming soon, I think I will wait for the new release.

 

TinyPortal © 2005-2018