Error when WNDPROC used in Form

maxmanzero

Member
Joined
Sep 29, 2004
Messages
12
Programming Experience
Beginner
I am writing an application that uses a comControl to talk to the super IO controller on a motherboard. Everything works fine until I include the wndproc method in the form code to process some of the wnd messages. When the wnproc is present I get the following error when the control is initialized

An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.windows.forms.dll
Additional information: Error creating window handle.

Can anyone help me?
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
post some code here ta help us understand which statement(s) cause the error
 

maxmanzero

Member
Joined
Sep 29, 2004
Messages
12
Programming Experience
Beginner
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

Debug.WriteLine("In wndproc")

End Sub

If this code is anywhere in my main form when I call mainFrm.Show() it throws the
"Error Cannot get windows handle"
 

Matrixmatrix

Member
Joined
Sep 30, 2004
Messages
7
Programming Experience
1-3
Hi

Try this one:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Debug.WriteLine("In wndproc")​
MyBase.WndProc(m)
End Sub

Found at Microsoft MSDN.....:)
 

maxmanzero

Member
Joined
Sep 29, 2004
Messages
12
Programming Experience
Beginner
Sweet!! That did it! Thanks Matrix and Jugg for the replies
 
Top Bottom