Error creating window handle

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jonathan Boivin

    #1

    Error creating window handle

    Hi people,

    Let me introduce to how I get this error.

    I have a form which load all my bills representation depending upon filters
    which each bill is a usercontrol of my own having some textboxes containing
    bill's datas. (I already replaced the labels by painting the text instead.)

    When I click on my filter button, it clears the current usercontrol bills
    and load the new ones upon the current chosen filters. The bug happens when
    you filter multiple times which doesn't depend on the filters chosen. There
    is not precise time when the bug is thrown. My bill usercontrol includes
    also two other usercontrols which show the history of the bill and one other
    which show furthermore infos. The futhermore infos usercontrol only contains
    textboxes and labels (again) had been replaced by text screen printing. The
    history controls are a ComboBox I created myself from a ListBox I created
    myself from skratch. The ComboBox includes 1 Label, 1 Button and My List
    Control. This last one only has a panel control and inherits from
    UserControl and it's already disposing all drawing objects (not quite sure
    though the disposing is linked to the problem).

    From what I see, I think the problem is coming from a number of exceeding
    window handle created. (Because when I look into my last created bill
    usercontrol, not all the controls within are created). Further, when the bug
    just happened (after storing to a log file), I can't open anything else
    (external programs I mean) unless I close my own program.

    How come can I reach the window handles limit if the first time I load all
    bills it doesn't bug, only after a few tries ?

    Also, is there a way to know how many window handles are created ?

    Thanks,
    Jonathan Boivin
    ---
    jonathanboivin@ cints.net | http://www.cints.net


  • rowe_newsgroups

    #2
    Re: Error creating window handle

    Also, is there a way to know how many window handles are created ?

    What OS are you using? If I'm not mistaken, Windows XP allows 10,000
    window handles per process - and I doubt you have that many. I'm
    curious though, are you sure you are actually destroying the window
    handles when "it clears the current usercontrol bills"? Perhaps you
    could use the DestroyWindow API to make sure you are killing the
    handles?

    http://msdn2.microsoft.com/en-us/library/ms632682.aspx
    http://www.pinvoke.net/default.aspx/...royWindow.html ).

    Also, to get a count of window handles you could use the
    EnumChildWindow s API

    http://msdn2.microsoft.com/en-us/library/ms633494.aspx


    Thanks,

    Seth Rowe


    On Mar 27, 3:15 am, "Jonathan Boivin" <d...@cyberinte rnautes.net>
    wrote:
    Hi people,
    >
    Let me introduce to how I get this error.
    >
    I have a form which load all my bills representation depending upon filters
    which each bill is a usercontrol of my own having some textboxes containing
    bill's datas. (I already replaced the labels by painting the text instead.)
    >
    When I click on my filter button, it clears the current usercontrol bills
    and load the new ones upon the current chosen filters. The bug happens when
    you filter multiple times which doesn't depend on the filters chosen. There
    is not precise time when the bug is thrown. My bill usercontrol includes
    also two other usercontrols which show the history of the bill and one other
    which show furthermore infos. The futhermore infos usercontrol only contains
    textboxes and labels (again) had been replaced by text screen printing. The
    history controls are a ComboBox I created myself from a ListBox I created
    myself from skratch. The ComboBox includes 1 Label, 1 Button and My List
    Control. This last one only has a panel control and inherits from
    UserControl and it's already disposing all drawing objects (not quite sure
    though the disposing is linked to the problem).
    >
    From what I see, I think the problem is coming from a number of exceeding
    window handle created. (Because when I look into my last created bill
    usercontrol, not all the controls within are created). Further, when the bug
    just happened (after storing to a log file), I can't open anything else
    (external programs I mean) unless I close my own program.
    >
    How come can I reach the window handles limit if the first time I load all
    bills it doesn't bug, only after a few tries ?
    >
    Also, is there a way to know how many window handles are created ?
    >
    Thanks,
    Jonathan Boivin
    ---
    jonathanboi...@ cints.net |http://www.cints.net

    Comment

    • Jonathan Boivin

      #3
      Re: Error creating window handle

      I am running under WinXP and I just get aware of this 10,000 window handles
      not so long ago.

      I just added this file to my project and use the EnumWindows class to count
      how many handles I have.
      The file used is located at (got to copy/paste) :


      I create a function using the EnumWindows class to count the handles which
      is :
      Public Shared Function CountWindowHand les() As Integer
      Dim i As Integer
      Dim eW As New vbAccelerator.C omponents.Win32 .EnumWindows
      eW.GetWindows()
      For i = 0 To eW.Items.Count - 1
      Try
      If eW.Items(i).Tex t.ToUpper.Start sWith("CLINICA" ) Then
      Dim MyPointer As IntPtr = eW.Items(i).Han dle
      Dim handlesCount As New
      vbAccelerator.C omponents.Win32 .EnumWindows
      handlesCount.Ge tWindows(MyPoin ter)
      If handlesCount.It ems.Count 0 Then
      Return handlesCount.It ems.Count
      End If
      End If
      Catch
      End Try
      Next

      Return 0
      End Function

      This works fine and I add two MsgBox to display me the number of handles
      before clearing the bill usercontrols and one after.
      First time = 53, 53.
      Second time = 2608, 53 (Filtering is set to ALL)

      The bill usercontrols are added in a Panel which automanage the vertical
      scrollbar. I use the Clear method on the Items of the panel to remove them.
      53 represents when my software and the window (without bills) are opened and
      2608 is including the bills.

      I downloaded the C# software version which enumerates the handles
      (http://www.vbaccelerator.com/home/NE...dows_Code.asp).
      When I browse throught my software primary handle I see a lot of :
      HANDLE NUMBER + WindowsForms10. STATIC.app.0.33 c0d9d
      or
      HANDLE NUMBER + WindowsForms10. EDIT.app.0.33c0 d9d

      I made a screen shot of what I mostly see which is avaible at :



      I decided to make another test, but this time not with the billing window. I
      opened 10 client accounts which was representing around 1000 handles. I
      closed them and loaded them more than 10 times, no bug. When I'm using the
      billing window, even if I close it after the filtering and reopen and
      refilter, the third time (or so) it craches.

      Thanks,
      Jonathan Boivin
      ---
      jonathanboivin@ cints.net | http://www.cints.net
      "rowe_newsgroup s" <rowe_email@yah oo.coma écrit dans le message de news:
      1174994904.2351 07.175570@o5g20 00...legro ups.com...
      >Also, is there a way to know how many window handles are created ?
      >
      What OS are you using? If I'm not mistaken, Windows XP allows 10,000
      window handles per process - and I doubt you have that many. I'm
      curious though, are you sure you are actually destroying the window
      handles when "it clears the current usercontrol bills"? Perhaps you
      could use the DestroyWindow API to make sure you are killing the
      handles?
      >
      http://msdn2.microsoft.com/en-us/library/ms632682.aspx
      http://www.pinvoke.net/default.aspx/...royWindow.html ).
      >
      Also, to get a count of window handles you could use the
      EnumChildWindow s API
      >
      http://msdn2.microsoft.com/en-us/library/ms633494.aspx

      >
      Thanks,
      >
      Seth Rowe
      >
      >
      On Mar 27, 3:15 am, "Jonathan Boivin" <d...@cyberinte rnautes.net>
      wrote:
      >Hi people,
      >>
      >Let me introduce to how I get this error.
      >>
      >I have a form which load all my bills representation depending upon
      >filters
      >which each bill is a usercontrol of my own having some textboxes
      >containing
      >bill's datas. (I already replaced the labels by painting the text
      >instead.)
      >>
      >When I click on my filter button, it clears the current usercontrol bills
      >and load the new ones upon the current chosen filters. The bug happens
      >when
      >you filter multiple times which doesn't depend on the filters chosen.
      >There
      >is not precise time when the bug is thrown. My bill usercontrol includes
      >also two other usercontrols which show the history of the bill and one
      >other
      >which show furthermore infos. The futhermore infos usercontrol only
      >contains
      >textboxes and labels (again) had been replaced by text screen printing.
      >The
      >history controls are a ComboBox I created myself from a ListBox I created
      >myself from skratch. The ComboBox includes 1 Label, 1 Button and My List
      >Control. This last one only has a panel control and inherits from
      >UserControl and it's already disposing all drawing objects (not quite
      >sure
      >though the disposing is linked to the problem).
      >>
      >From what I see, I think the problem is coming from a number of exceeding
      >window handle created. (Because when I look into my last created bill
      >usercontrol, not all the controls within are created). Further, when the
      >bug
      >just happened (after storing to a log file), I can't open anything else
      >(external programs I mean) unless I close my own program.
      >>
      >How come can I reach the window handles limit if the first time I load
      >all
      >bills it doesn't bug, only after a few tries ?
      >>
      >Also, is there a way to know how many window handles are created ?
      >>
      >Thanks,
      >Jonathan Boivin
      >---
      >jonathanboi... @cints.net |http://www.cints.net
      >

      Comment

      Working...