473,322 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Error creating window handle

Hello All,

I'm haveing a problem instantiating a form. When I try to instantiate
my form and call it's ShowDialog() method, I get the following error
message:

An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in system.windows.forms.dll
Additional information: Error creating window handle.
Dim frm As New modMastController.frmSubClass
frm.ShowDialog()
Here's the Form Code:
__________________________________________________ ___________
Public Class frmSubClass
Inherits System.Windows.Forms.Form
Public Event UserMessage(ByVal uMsg As System.Int32, ByVal
wParam As System.Int32, ByVal lParam As System.Int32)
#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(424, 253)
Me.Name = "frmSubClass"
Me.Text = ""
Me.ResumeLayout(False)

End Sub

#End Region

Public Const WM_APP As System.Int32 = &H8000&

#Region "Subclassing Current Form Only"
Protected Overrides Sub WndProc(ByRef m As Message)
If (m.Msg > WM_APP) Then
RaiseEvent UserMessage(m.Msg, m.WParam.ToInt32,
m.LParam.ToInt32)
End If
End Sub
#End Region
End Class
__________________________________________________ ________________
I have no idea what I'm doing wrong. Any ideas? Thanks!

-Joel
Nov 21 '05 #1
1 6953
Joel Whitehouse wrote:
Hello All,

I'm haveing a problem instantiating a form. When I try to instantiate
my form and call it's ShowDialog() method, I get the following error
message:

An unhandled exception of type 'System.ComponentModel.Win32Exception'
occurred in system.windows.forms.dll
Additional information: Error creating window handle.
Dim frm As New modMastController.frmSubClass
frm.ShowDialog()
Here's the Form Code:
__________________________________________________ ___________
Public Class frmSubClass
Inherits System.Windows.Forms.Form
Public Event UserMessage(ByVal uMsg As System.Int32, ByVal
wParam As System.Int32, ByVal lParam As System.Int32)
#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(424, 253)
Me.Name = "frmSubClass"
Me.Text = ""
Me.ResumeLayout(False)

End Sub

#End Region

Public Const WM_APP As System.Int32 = &H8000&

#Region "Subclassing Current Form Only"
Protected Overrides Sub WndProc(ByRef m As Message)
If (m.Msg > WM_APP) Then
RaiseEvent UserMessage(m.Msg, m.WParam.ToInt32,
m.LParam.ToInt32)
End If
End Sub
#End Region
End Class
__________________________________________________ ________________
I have no idea what I'm doing wrong. Any ideas? Thanks!

-Joel


Hey guys, I found it! The key is to add this line to the end of the
Protected Overrides Sub WndProc(ByRef m As Message) function link this:
Protected Overrides Sub WndProc(ByRef m As Message)
If (m.Msg > WM_APP) Then
RaiseEvent UserMessage(m.Msg, m.WParam.ToInt32, m.LParam.ToInt32)
End If
MyBase.WndProc(m) '**************Essential line of code!
End Sub
So many people have had this problem and never posted the answer. I
hope google caches this a few times, for other people's sakes.

-Joel
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Altramagnus | last post by:
I have 30 - 40 type of different window. For each type I need about 20 instances of the window. When I try to create them, I get "Error creating window handle" My guess is there is a maximum...
0
by: Matt Warner | last post by:
Hi guys, A couple of people have already posted questions about similar issues but haven't had any response. Occasionally, sometimes after running the app for a few hours, it bombs out saying...
4
by: Altramagnus | last post by:
I have 30 - 40 type of different window. For each type I need about 20 instances of the window. When I try to create them, I get "Error creating window handle" My guess is there is a maximum...
4
by: Altramagnus | last post by:
I have 30 - 40 type of different window. For each type I need about 20 instances of the window. When I try to create them, I get "Error creating window handle" My guess is there is a maximum...
0
by: Matt Warner | last post by:
Hi guys, A couple of people have already posted questions about similar issues but haven't had any response. Occasionally, sometimes after running the app for a few hours, it bombs out saying...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.