wndproc not working in .NET

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?
 
R

Robert Gruen [MSFT]

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.
 
R

Reza

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top