WndProc error

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
Stripped down code :-

VB.NET:
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Select Case m.Msg
            Case WM_SYSCOMMAND
                Select Case Convert.ToInt32(m.WParam)
                    Case Else
                        MyBase.WndProc(m)
                End Select
            Case Else
                MyBase.WndProc(m)
        End Select
    End Sub

When it tries to process Convert.ToInt32(m.WParam), I get :-

VB.NET:
Unable to cast object of type 'System.IntPtr' to type 'System.IConvertible'.

but if I use m.WParam.ToInt32, it works.

1. Why?

2. Are there any other occasions like this, when I shouldnt be using a Convert. method?
 
Back
Top