Custom DataSource and GetValue

Posted by: ironmanuk on 8 September 2017, 12:58 pm EST

  • Posted 8 September 2017, 12:58 pm EST


    Hi,


    I am implementing a custom data source derived from ISheetDataModel, and have been struggling with some performance issues. It transpires that this is down to the GetValue method being called continuously when the mouse is hovering over a cell in the grid, and called once for each cell that is visible when a cell is clicked. With a bit of trial and error, I've noticed that if a cell is clicked and is in edit mode, this continuous calling stops, unless the cursor is moved over another cell, in which case it is then continuously called for the cell under the cursor (whilst the original cell is being edited and still has keyboard focus).


    I wondered whether this feature was by design, whether it's a bug, or happening because I am not doing something (implementing a different interface perhaps)?


    Any help greatly appreciated.


    Thanks.



    Chris


     


     

  • Replied 8 September 2017, 12:58 pm EST

    Hi Scott,


    thanks for the update... that makes sense for when the cursor is moving, but if the cursor is static, it is continually being called, which gets expensive if you leave the cursor over the grid whilst doing something else. To give you a context for my concern, our users have multiple screens, up to 8 in some cases, and have lots of applications open that are dependent on real time market information, so performance is a critical concern.


    Thanks,


    Chris

  • Replied 8 September 2017, 12:58 pm EST

    Chris,


    These are both expected behavior. When moving your mouse around a cell, the IEditor's IsReservedLocation method is called to determine the pointer to display based on the location in the cell. However, since the value of the cell is one of the parameters of this method, the GetValue method has to be called.


    When you click on a cell in the Spread, the Spread control invalidates. Part of the code that gets processed when invalidating is to repaint all the visible cells, which is calling GetValue on each of the visible cells.

  • Replied 8 September 2017, 12:58 pm EST

    I had a similar thought before making the original post, to sanity check what I was seeing I created a new project, dropped a spread control onto a blank form with no code in the form at all, set the Models.Data and Models.ColumnHeaderData to the ISheetDataModel derived objects, and this behaviour was exhibited.


     


     


     

  • Replied 8 September 2017, 12:58 pm EST

    Chris,


    There must be something on the form that is causing the controls (including the Spread) to invalidate, which will cause the GetValue method to call.

  • Replied 8 September 2017, 12:58 pm EST

    2) remove Spread from the clipboard chain


    How would I acheive this?

  • Replied 8 September 2017, 12:58 pm EST

    is there a way to stop spread listening to the clibboard chain? There's nothing coming in that we are interested in.

  • Replied 8 September 2017, 12:58 pm EST

    Hello,


    From what I have read on the utilities I listed in the previous post, there is a way using their utilities to remove objects from the Clipboard Chain.

  • Replied 8 September 2017, 12:58 pm EST

    Hello,


    I finally was able to reproduce this issue. When debugging the issue, I see the GetValue method is being called in response to a WM_MOUSEMOVE, which it is suppose to do. But I was trying to find out why a mouse move was happening.


    I found the cause to be in an object of Spread called a ClipboardChangeNotifier object. In order to be notified of changes made to the Clipboard object, you need to register this window in the Clipboard Viewer Chain. Many applications register their own object, so they can catch messages to the Clipboard as well. What is suppose to happen is to catch the messages and pass most messages to the base class WndProc for your window. There are a couple of message that need to be known by all windows that register to this Chain and you need to call a SendMessage to send those messages (usually only WM_CHANGECBCHAIN and WM_DRAWCLIPBOARD messages). However, it looks like one or more of your other applications is passing the WM_MOUSEMOVE to the chain and since Spread is attached to this chain it gets the message. If the mouse os over a cell, the Spread needs to requery the value of that cell to determine if a new mouse pointer is needed.


    So, the issue is not in the Spread control, but in one or more of your other application(s) running where it is erroneously calling a SendMessage on the WM_MOUSEMOVE message.

  • Replied 8 September 2017, 12:58 pm EST

    Hi,


    am not sure that I fully understand what you're saying here, but given that the machines involved are corporate build, and have a plethora of bespoke applications, vendor products, and virus scanners running, it really could be anything doing the post, certainly not something within the bounds of the applications that I am working on.


    Is there any way to turn this behaviour off to prove the assertion?


    Chris


     

  • Replied 8 September 2017, 12:58 pm EST

    Chris,


    I do not know of a way to turn off the Clipboard chain. However, there looks to be utilities (Clipboard Recovery 2.0, ArsClip, etc) that can be used to remove objects from the Clipboard chain. If this is the case, you should be able to use this to 1) find the application causing the message to be fired and/or 2) remove Sperad from the Clipboard chain.

  • Replied 8 September 2017, 12:58 pm EST

    Hello,


    There is no method in Spread that has been made public to give this functionality.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels