Problem with WndProc in VS.NET 2005(CLI C++)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

if I have the compiler option /clr:oldSyntax in a Windows Forms application

protected:
void WndProc(System::Windows::Forms::Message* m)

is called

If I remove oldSyntax

protected:
void WndProc(System::Windows::Forms::Message^ m) override

gets the compiler error that there is not a method in the base class to
override. Without the override keyword the method is not called.

Does anyone have an idea what is the problem?

Dennis Worthem
 
Don't confuse with pointer and handle, the WndProc in Form has only function
to deal with pointer. But you tried to process with handle(^). Infact your
code is supposed to work with both syntax.
Bijoy
 
Hi,
inline
dworthem said:
if I have the compiler option /clr:oldSyntax in a Windows Forms
application

protected:
void WndProc(System::Windows::Forms::Message* m)

is called

If I remove oldSyntax

protected:
void WndProc(System::Windows::Forms::Message^ m) override

System::Windows::Forms::Message is a value type, you can only get a
handle-to-object(^) when it's boxed. So the parameter above is a handle to
a boxed Message.

For WndProc, Message is passed by-reference which requires a tracking
reference (%) :

protected:
void WndProc(System::Windows::Forms::Message% m) override
{
//...
__super::WndProc(m);
}

HTH,
greetings
 
Back
Top