Results 1 to 9 of 9

Thread: check it out, weird error from combo box

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    check it out, weird error from combo box

    This is weird, I even started a new project to prove I'm not doing anythign wrong. When you have visual styles enabled, if you load a form using the ShowDialog method in the selectedIndexChanged event of the combo box, you get an error (I'm sure it has nothing to do with the combo box, it's just a situation when it happens. Apparently it has to do with visual styles and the ShowDialog method). Try this:

    In a new project add a combo box to a form (called Form1 here) and add a bunch of items into the combo box. Then add this code:
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Application.EnableVisualStyles()
    3.     End Sub
    4.  
    5.     Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
    6.         Dim frm As New Form1
    7.         frm.ShowDialog()
    8.     End Sub

    Run the app. Now select an item from the combo box and a new form pops up, repeat this again and then close the second form that pops up and wait a few seconds,... dont you get an error?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Lively Member JAtkinson's Avatar
    Join Date
    Feb 2004
    Location
    Richmond, VA
    Posts
    68
    An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll

    Additional information: External component has thrown an exception.


    Thats what I get.

    James
    Visual Studio .net 2003 EA
    VB .net
    C#

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    wow man, this is pretty stupid. Apparently an obvious bug ha?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm apparently some other people have had problems with this too. This is similar: http://www.manning-sandbox.com/threa...essageID=17578


    Apparently the comboBox handles things differently in Framework 1.1 and when you have visual styles enabled, it can raise an exception if you show a dialog in the selectedIndexChanged event. I removed the Application.EnableVisualStyles() call and instead used a manifest file as it was suggested in the link above and apparently it works fine.... but this is really stupid of microsoft


    edit: they also suggested to use Application.DoEvents() right after calling EnableVisualStyles()... apparently this visual styles thingie causes other problems that are solved by calling DoEvents right after it, but in this case it did NOT change anything
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5
    Lively Member JAtkinson's Avatar
    Join Date
    Feb 2004
    Location
    Richmond, VA
    Posts
    68
    You may find this interesting too.

    http://www.codeproject.com/buglist/E...lStylesBug.asp

    James
    Visual Studio .net 2003 EA
    VB .net
    C#

  6. #6

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    haha interesting! it's better not to use that evil. Apparently there are many other problems with it. Shame on microsoft
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: check it out, weird error from combo box

    I just ran into this problem today. I know its an old thread.. but I figured I would post since I was trying to find a solution and apparently there is none (other than NOT using enablevisualstyles)

    I did find out that MS at least DOES know about it.. although I guess they are not fixing it?

    I know that there is going to be another service pack for VS.NET 2003 in the second 1/4 of this year.

    from MSKB
    You may receive the same error message that is discussed in the "Symptoms" section when you use the ShowDialog method to open a form. To work around this behavior, use the Show method instead of the ShowDialog method.
    hardly a workaround being that show and showdialog have totally different behavior..

  8. #8
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: check it out, weird error from combo box

    Did you try calling InitCustomControlsEx as the first step of your app?

    (I don't use Windows eXtreme Paintset so can't test it myself)

  9. #9
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: check it out, weird error from combo box

    Quote Originally Posted by Merrion
    Did you try calling InitCustomControlsEx as the first step of your app?

    (I don't use Windows eXtreme Paintset so can't test it myself)
    I don't know what that is? Is it an API function or something?

    The only solutions MS has provided is to do what I said above, or use a manifest file instead of Application.EnableVisualStyles

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width