Error during FpCombo draw

  • mchargue 1 year, 4 months ago

    I’ve had an error come in from the field that occurred during the drawing for FpCombo. I can’t reproduce it on any machines here, but was hoping someone can offer some guidance as to what the issue is and how it can be resolved or protected against. Here is the call stack that I received.

    Error Type: InvalidOperationException
    Stack Trace: ??: System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsCombinationDefined(String className, Int32 part)
    ??: FarPoint.Win.DropDownButtonElement.OnPaintBackground(Graphics g, Rectangle rectInput)
    ??: FarPoint.Win.ElementWindowless.PaintElements(Graphics g, Rectangle faceRect)
    ??: FarPoint.Win.ElementWindowless.OnPaint(Graphics g, Rectangle rectInput)
    ??: FarPoint.Win.SuperEditBase.OnPaint(PaintEventArgs e)
    ??: System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
    ??: System.Windows.Forms.Control.WmPaint(Message& m)
    ??: System.Windows.Forms.Control.WndProc(Message& m)
    ??: FarPoint.Win.SuperEditBase.WndProc(Message& m)
    ??: FarPoint.Win.FpCombo.WndProc(Message& m)
    ??: System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    This is using version 9 of Spread. Thanks!

  • 122p
    Sean Lawyer122p 1 year, 4 months ago

    Hi,

    From the call stack, assuming you’re using the latest v9 (or that it hasn’t changed), it appears to be getting the problem in this code inside FarPoint.Win.DropDownButtonElement.OnPaintBackground():

    ...
    VisualStyleElement element = VisualStyleElement.ComboBox.DropDownButton.Normal;
    if (rectInput.Contains(this.Parent.PointToClient(Control.MousePosition)))
    {
    if (Control.MouseButtons == MouseButtons.Left)
    {
    element = VisualStyleElement.ComboBox.DropDownButton.Pressed;
    }
    else
    {
    element = VisualStyleElement.ComboBox.DropDownButton.Hot;
    }
    }
    if (VisualStyleRenderer.IsElementDefined(element)) // <- problem happens here (unexpected InvalidOperationException) { . . . [/code] The user does not have Visual Style themes supported on their system, and Spread does not handle this case correctly and tries to use it for drawing the combo box button anyway. The help context for VisualStyleRenderer.IsElementDefined() indicates that InvalidOperationException is thrown when the operating system does not support visual styles: [url]https://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstylerenderer.iselementdefined(v=vs.110).aspx[/url] If you change the Spread instances’ VisualStyles properties to “Off” or “Auto” then it should get around the problem: [url]http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.FpSpread~VisualStyles.html[/url] But I think Spread should be handling this case better and automatically ignore invalid settings for VisualStyles instead of throwing an exception, so we’ll look into this issue more and post a bug about it when we’re able to reproduce it in a simple sample. If you can get more information about the user’s OS and system configuration, that might be helpful for reproducing it. Regards, -Sean

  • mchargue 1 year, 4 months ago

    Hi Sean,

    Thanks for the information. Here are the specs I have from the log that was created by this error. Looks to be a Korean version of Windows 7.

    Operating System:
    Caption: Microsoft Windows 7 Professional K
    FreePhysicalMemory: 1489068
    FreeVirtualMemory: 5625156
    Manufacturer: Microsoft Corporation
    ServicePackMajorVersion: 1
    TotalVirtualMemorySize: 8090692
    TotalVisibleMemorySize: 4046264
    Version: 6.1.7601
    Processor:
    Caption: Intel64 Family 6 Model 37 Stepping 2
    Description: Intel64 Family 6 Model 37 Stepping 2
    Family: 185
    Name: Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz
    NumberOfCores: 2
    Status: OK

  • 15p
    Kevin Ashley15p 1 year, 4 months ago

    Hello,

    I tried creating a sample Winforms project with the following code for setting a combo box cell and turning on the VisualStyles for the Spread object:

    fpSpread1.VisualStyles = FarPoint.Win.VisualStyles.On;

    FarPoint.Win.Spread.CellType.ComboBoxCellType cmbocell = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
    cmbocell.Items = (new String[] { “January”, “February”, “March”, “April”, “May”, “June” });
    cmbocell.AutoSearch = FarPoint.Win.AutoSearch.SingleCharacter;
    cmbocell.Editable = true;
    cmbocell.MaxDrop = 4;
    fpSpread1.ActiveSheet.Cells[0, 0].CellType = cmbocell;

    Then I built and ran that on a Windows 7 machine with the visual styles disabled:

    http://www.sevenforums.com/tutorials/127339-visual-styles-windows-buttons-turn-off.html

    I couldn’t reproduce the issue. Are there any other things I am missing to reproduce the problem?

    Regards,
    Kevin

  • Bill Croteau 3 months, 1 week ago

    Even though this thread is a year old I’ve just received a similar problem from the field. Like mchargue I cannot reproduce this in my environment however I CAN guarantee that it is happening at ONE customer installation (multiple instances at their location). I have concluded of course that our customer has some “strange” configuration that’s causing the problem…

    We’re using Spread v9.35.20161.0 (I’ve attempted to upgrade to v10 however am unable to do so due to a different bug with v10 which is critical to our operation and so we’ve reverted back to 9.35 which works better – except for this issue.)

    Customer is running Win 7 64-bit.

    As Sean Lawyer pointed out a year ago “…Spread should be handling this case better and automatically ignore invalid settings for VisualStyles instead of throwing an exception…”

    My question is: Has this been fixed? Has there been any traction on this issue at all? Is there a work-around? I’ve attempted to set

    spread.VisualStyles = FarPoint.Win.VisualStyles.Off

    I understand the complexity of attempting to fix a bug that you cannot reproduce in your lab environment or with a simple test case – nonetheless this IS happening.

    Here’s MY pertinent log information:

    2017-04-04 14:14:15.4011 [ERROR] [TSMain.frmTsMain] Unhandled Exception. System.InvalidOperationException: Visual Styles-related operation resulted in an error because visual styles are currently disabled in the client area.
       at System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsCombinationDefined(String className, Int32 part)
       at FarPoint.Win.DropDownButtonElement.OnPaintBackground(Graphics g, Rectangle rectInput)
       at FarPoint.Win.ElementWindowless.PaintElements(Graphics g, Rectangle faceRect)
       at FarPoint.Win.ElementWindowless.OnPaint(Graphics g, Rectangle rectInput)
       at FarPoint.Win.SuperEditBase.OnPaint(PaintEventArgs e)
       at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
       at System.Windows.Forms.Control.WmPaint(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at FarPoint.Win.SuperEditBase.WndProc(Message& m)
       at FarPoint.Win.FpCombo.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)    at System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsCombinationDefined(String className, Int32 part)
       at FarPoint.Win.DropDownButtonElement.OnPaintBackground(Graphics g, Rectangle rectInput)
       at FarPoint.Win.ElementWindowless.PaintElements(Graphics g, Rectangle faceRect)
       at FarPoint.Win.ElementWindowless.OnPaint(Graphics g, Rectangle rectInput)
       at FarPoint.Win.SuperEditBase.OnPaint(PaintEventArgs e)
       at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
       at System.Windows.Forms.Control.WmPaint(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at FarPoint.Win.SuperEditBase.WndProc(Message& m)
       at FarPoint.Win.FpCombo.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    What’s curious however is that my customer was able to temporarily resolve this issue by DISABLING the Themes service… So themes WAS running when the error occurs but stopping it FIXED the problem… My conclusion of course is that something related to but not the Themes-service proper has resulted in this problem – finding the WHAT is the needle in the haystack.

  • 105p
    Reeva105p 3 months, 1 week ago

    Hello,

    Since this issue was never reproduced at our end in our sample. Hence, this wasn’t posted as a bug. It would be great if you provide us with a sample replicating the issue along with stating configuration of your user’s OS and system architecture. That would help us in replicating the issue first in same environment and then escalating it for further fixing.

    If possible, please share the same. We will look into this issue thereon.

    Thanks,
    Reeva

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to create new topics.