Error Creating Window Handle...anybody?

LeeSalter

Freshman
Joined
Feb 13, 2003
Messages
26
Location
In a House
I have two forms.

I have this code at the top of the first form (ControlPanel).
Visual Basic:
Public frmUserManager As UserManager
    Public myUser As LANUser

A button on ControlPanel has the following code attached:

Visual Basic:
   Private Sub btnAdministerUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdministerUser.Click

Dim UserID As String
Dim setTop As Short = CShort(MyBase.Top) + CShort(MyBase.Height)
 Dim setLeft As Short = CShort(MyBase.Left)

        Try
            If frmUserManager.Visible = True Then
                'frmManagerWindow already exists.
            End If

        Catch ex As Exception
            frmUserManager = New UserManager(setTop, setLeft)
            Me.myUser = New LANUser()
        End Try

        UserID = InputBox("Please enter User ID", "Enter User ID")

        If Me.myUser.GetUserDetails(UserID, frmUserManager) = True Then
            frmUserManager.Show()
        End If


    End Sub

LANUser is a class that has some methods that call the NetUserGetInfo API.

After the button on ControlPanel is pressed and the code is fired, the UserManager form is displayed with details from the LANUser class.

This works perfectly for seven or eight passes.
However, eventually, an error occurs just before displaying the input box that say "Error Creating Window Handle".

Has anybody come across this problem before??
 
I've figured this out.
The structure passed to the NetUserGetInfo API from my LANUser class was declared as a Structure type.

I changed it to a subclass and it seems to have solved not only this problem, but also a problem I was having with my app locking up and getting a StackOverflowError.

Structure variables are placed on the stack. Class variables are placed on the heap, unless I'm mistaken, and as I was calling the NetUser api each time I wanted to administer a different user, the stack was filling up very quickly!!
 
Back
Top