wndproc not working in .NET

  • Thread starter Thread starter Reza
  • Start date Start date
R

Reza

Hello folkz
What am i doing wrong?
I been looking everywhere and it seems like it should work.

Form.h File
============
public __gc class Form1 : public System::Windows::Forms::Form
{
protected: virtual void WndProc(Message* m);
public:
Form1(void)
{
InitializeComponent();
}
etc ......
};

Form.cpp file
==========
void Form1::WndProc(Message* m)
{
if(m->Msg == WM_MNG_START_CNF)
{
textBox1->Text = "HEJ";
}
base::WndProc(m); //why doesn't this work??? Form1::WndProc(m); don't
work neither
}

Any idea?
 
Reza,

I actually haven't overriden the WndProc from C++ but here's an
implementation I did in C# that works. Perhaps you can nail down the
difference and figure out what the difference is. The only difference I
see is that I'm asserting the permission for FullTrust .




[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
protected override void WndProc(ref Message m)
{
// Listen for operating system messages.
switch (m.Msg)
{
case WM_DISPLAYCHANGE:
break;
}
base.WndProc(ref m);
}


Thanks! Robert Gruen
Microsoft, VB.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
 
I couldn't reply to you Rober so i added this header :)

If i use,
in my Form1.h :
protected: virtual void WndProc(Message* m); //Also tried without vitrual
with the same error

and in the Form1.cpp:
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
void Form1::WndProc(Message m)
{
// Listen for operating system messages.
switch (m.Msg)
{
case WM_DISPLAYCHANGE:
break;
}
//base.WndProc(m);
}

i ger this Error:
------------------------
c:\3\=Temp=\myEventTest\myEventTest\Form1.cpp(20): error C2143: syntax error
: missing ']' before '('
c:\3\=Temp=\myEventTest\myEventTest\Form1.cpp(20): error C3400: 'string':
unexpected token/character encountered in attribute block
-----------------------
Also if you notice i can't use the base.Wndroc for some reason i don't
understand. It is not recognized.

And also i don't think "override" is recognized in .Net C++. In the MSDN
help it doesn't show any exampel for C++.

Please let me know if you understand the problem and what i'm doing wrong.
I have seen many exampels but none works. It's realy strange.
I tried to send you an email with the project (just a few line code
actually) but your email was rejected. Isn't your email adress working?

Thanks
/Reza
 
Back
Top