Flexcel grid scroll with vcl styles

Hello Adrian

I am still getting strange things happen to flexcel grid scroll bars when I enable VCL.Styles.

I have tested this using your supplied demo for version 3 of XLSViewer

If I use the default windows style then the grid scroll works perfectly.

However if I enable a style then the grid horizontal bar stops working correctly, the grid movement seems to jump about and even the vertical scroll bar moves down by it self.

Can anybody else reproduce this problem?

Well, I've personally not been able to get any control to work reliably under VCL styles, so if you got the rest of the app to work you are in a better situation than me :)


Now seriously, does this happen with a particular style or with all of them? I've tried a couple and they seem to work fine, but I imagine it might depend on the machine. In mine in particular I access it through remote desktop, so themes look very glitchy, but all the controls. Toolbars don't redraw, etc. But scroll seems fine, both horizontal and vertical. 

About TFlexCelGrid, it is a simple TCustomGrid descendant that on the "ondraw" event draws the contents of the cells, but nothing more. I guess that if there is a bug in it, the bug comes from TCustomGrid, but one can never be sure. Do you get a stringgrid to work reliably with themes?

Also, does setting:
FlexCelGrid.DoubleBuffered := false;

change anything?

Regards,
  Adrian.

Hello Adrian



The scroll problem arises when you load multiple sheets and switch tabs.

 I am loading 20 sheets of data, and the problem can be seen most easily when you switch to the last sheet.



I have tested several styles and they all produce the same problem.



FlexCelGrid.DoubleBuffered := false or true  makes no difference.



I have tested on two development machines, both WIn XP, and tested the compiled app on XP and win7 with same result.



I haven't tested stringgrid with multiple tabs sheet switching as i
don't have a vcl app for that - do you have a demo I can try please?

 

Thanks

I' ve tried it some more, in different machines, with multiple files and multiple sheets and I still can't reproduce the issue. What I have seen is that if the grid is small, then the horizontal scrollbar can get our of sync with the mouse, probably because it can't move smoothly because the grid has to move in discrete steps (from column a to column b, but you can't see half of column  A and half of column B), so the scrollbar has to "jump". Without styles the mouse keeps attached to the scrollbar, with them the mouse moves slower.


As I am not sure if this is what you are seeing, I've recorded a small screencast showing the effect:
http://www.tmssoftware.net/public/flexcel/flexcelgridwiththemes.avi

But well, this is a problem with TCustomGrid (from where we descend). Here you can see the same effect in a stock TStringGrid:
http://www.tmssoftware.net/public/flexcel/stringgridthemes.avi

More interesting, in one of the test machines (where FlexCelGrid worked as in the others) TStringGrid refused to move at all:
http://www.tmssoftware.net/public/flexcel/stringgridthemes2.avi

As you can see, I couldn't drag it, and when I scrolled the grid with the keyboard, it remained fixed.

I am not sure if this is what you are referring to, but even if it isn't, chances are the bug is in TCustomGrid or the Themes implementation, because we don't mess with scroll at all, we only draw inside the canvas, but the scroll behavior is inherited from TCustomGrid. Also as you could see, TStringGrid behaves mostly the same as TFlexCelGrid.

So I think the best solution in this case is just to disable theming for the FlexCelGrid. You won't lose much (since the full grid isn't themed anyway, so it is only the scrollbars), and well, those scrollbars weren't working well anyway. The rest of your app will stay skinned.

To disable theming only for the grid, use the following:
  if Assigned(TStyleManager.Engine) then TStyleManager.Engine.RegisterStyleHook(TFlexCelGrid, TStyleHook);

For your reference, this is the full code for the XlsViewer demo project with skins disabled for TFlexCelGrid:

program XlsViewer;

uses
  Forms,
  UXlsViewer in 'UXlsViewer.pas' {FXlsViewer},
  UFormatDialog in 'UFormatDialog.pas' {FormatDialog},
  UPreview in 'UPreview.pas' {FPreview},
  UFlexCelGrid,
  Vcl.Themes,
  Vcl.Styles;

{$R *.res}

begin
  Application.Initialize;
  if Assigned(TStyleManager.Engine) then TStyleManager.Engine.RegisterStyleHook(TFlexCelGrid, TStyleHook);
  TStyleManager.TrySetStyle('Metro Blue');
  Application.Title := 'FlexCel Viewer';
  Application.CreateForm(TFXlsViewer, FXlsViewer);
  Application.Run;
end.

Hello

Can i just say the support from you Adrian is fantastic!
Yes one of the symptoms was the scroll bar would not move back to the left.
Anyhow disabling the skin for the grid has cured the issue for me too.
Thank you so much.
Regards