2

ETA: I use visual studio 2008 express edition.

If I override WndProc and mess up somehow, I'll usually backtrack by commenting out code until it works again.

The strange thing with WndProc though is you can strip it down to:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    MyBase.WndProc((m))
End Sub

and it still throws the error.

I have to remove the code and retype it in to reset the error.

Anyone else experienced this?

ETA:

Answered below by Chris Haas.

I hadn't realised, but this problem must only have occurred when I'd used code from reflector. Reflector mis-translates to vb.net and inserts extra brackets into the calls to WndProc base.

Jules
  • 4,319
  • 3
  • 44
  • 72
  • Its an 'Error creating window handle' at: System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) – Jules Apr 21 '10 at 15:58
  • It is so wierd. I got it working by cutting all the code out and re-overriding. Then i pasted the code back bit-by-bit and kept testing to make sure it was ok. Eventually I ended up with all the code there and it worked. Then I tried copying and pasting the whole block of the code in there....it doesn't work! – Jules Apr 21 '10 at 16:04

1 Answers1

5

When you wrap an argument in parenthesis you are overriding the ByRef call and instead calling it ByVal. See Argument Not Being Modified by Procedure Call - Underlying Variable

Just change the code to:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    MyBase.WndProc(m)
End Sub
Chris Haas
  • 53,986
  • 12
  • 141
  • 274
  • Cheers, looks like that is it. The code I was starting with was from reflector which is mistranslating to vb.net and inserting the brackets when they shouldn't be there. Mystery solved! – Jules Apr 21 '10 at 18:16