• Advertisement

Archived

This topic is now archived and is closed to further replies.

how can i use WndProc() in .NET applications?

This topic is 5096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to use windows message handling in my application made with VC++.NET 2003. How? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
ok i''ve tried to add this line at the .h file:
private: void WndProc( Message __gc* mess){}
but if i build the application i get this error:

error C3252: ''MyApp::MyWindows::WndProc'' : in a managed type you cannot reduce the accessibility to a virtual method

what means?

Share this post


Link to post
Share on other sites
ok i''ve resolved making it public.But now how can i get messages from windows?
Does it work like VC++ 6 or VC++.NET 2002?

Share this post


Link to post
Share on other sites
where can get a full list of WindowsMessages (WM)?

Share this post


Link to post
Share on other sites
why do i get these error using this:

public: void WndProc( Message __gc* msg )
{
switch (msg->Msg)
{
case WM_NCACTIVATE :
textBox1->Text = S"attivato";
break;
}
Form::WndProc(msg);
}

errors:

error C2051: case expression not constant (at line "case WM_NCACTIVATE :")
error C2065: ''WM_NCACTIVATE'' : undeclared identifier (at the same line)
warning C4060: switch statement contains no ''case'' or ''default'' labels (at the last but one "}")


Share this post


Link to post
Share on other sites
i''ve resolved another time including "windows.h" but i''ve get much errors about the undefined object "GetObject" that i resolve is i put the line #undef GetObject, after the header, and other errors as:

error C2653: ''MessageBoxA'' : is not a class or namespace name
error C2660: ''System::Windows::Forms::Control::Show'' : function does not take 2 arguments

at the line:
MessageBox::Show(S"Hello World", S"Bye");

the question is, why i need to include that header to use WM_ ?
and why if i just include it i get these errors?
At the end why using #undef i resolve one?

Share this post


Link to post
Share on other sites
GetObject and MessageBox are macros defined in the windows headers. They map these names to either the ANSI or the UNICODE imlplementation. However, they collide with .NET Method-Names, that''s why you get these errors.

General rule of thumb: whenever the compiler complains about a "SomeNameA" or "SomeNameW", you have to #undef SomeName.

The more interesting question to me is: why do you want to override the WndProc? Maybe if you tell us we''ll find a more elegant ''.NETish'' way.

Regards,
Andre

Share this post


Link to post
Share on other sites
1)Yes, i want handle some Windows Message, as Windows Unactivate and viceversa and so on...
2)Also if i use #undef MessageBoxA i get anyway error C2653 and error C2660 error.
Thanks.

Share this post


Link to post
Share on other sites
quote:
Original post by Link
the question is, why i need to include that header to use WM_ ?

You can always dig into the Windows headers and get the numerical values of those messages. That''s what you''d have to do if you were using C# or VB.NET anywyay.

Share this post


Link to post
Share on other sites
quote:
Original post by Link
1)Yes, i want handle some Windows Message, as Windows Unactivate and viceversa and so on...
2)Also if i use #undef MessageBoxA i get anyway error C2653 and error C2660 error.
Thanks.



ok i''ve resolved also the point 2. It need to #undef MessageBox at the place of MessageBoxA

Thanks at all.

Share this post


Link to post
Share on other sites

  • Advertisement