Need to be able to receive WM_COPYDATA messages in VC.NET.

  • Thread starter Thread starter Fred Hebert
  • Start date Start date
F

Fred Hebert

I am new to .NET and trying to convert some existing code to .NET. The
application that is giving be problems is one that receives status messages
from a device via WM_COPYDATA messages and logs, and/or acts upon them.

In MFC this was easy, but I can't seem to figure out how to set up the
handler in .NET. It should be simple but I am obviously missing something.

Can anyone tell me how to set up a function to receive the messages. Once
I have the pointer to the COPYDATASTRUCT I'm ok.

I think a fragment showing how to declare the function properly is all I
need, or just point to some documentation.

Thanks in advance,
Fred.
 
Just override the WndProc method of a form or control.



Mattias

Could you be just a little more specific?

I had gotten some bad info that me going in the wrong direction for a
while. I almost have it figured out, but I am having a little problem
with the reinterpret_cast in the fragment below.

I am new to .NET and really struggling with silly syntax problems. The
biggest problem is a lot of abstract reference material in the
documentation but no actual syntactical examples. Before you get
excited, I know there are a lot of examples in MSDN, but most are fairly
simplistic and I have not found any that addresses this topic.


protected: void WndProc(Message* m)
{
if (m->Msg == WM_COPYDATA)
{
COPYDATASTRUCT* CopyData = reinterpret_cast
<COPYDATASTRUCT*> (m->LParam);
int DataType = CopyData->dwData;
int DataSize = CopyData->cbData;
switch (DataType)
...
}
}
else
__super::WndProc(m);
}
 
Fred,
I had gotten some bad info that me going in the wrong direction for a
while. I almost have it figured out, but I am having a little problem
with the reinterpret_cast in the fragment below. [...]
COPYDATASTRUCT* CopyData = reinterpret_cast
<COPYDATASTRUCT*> (m->LParam);

Try replacing m->LParam with m->LParam.ToPointer()




Mattias
 
Fred,
I had gotten some bad info that me going in the wrong direction for a
while. I almost have it figured out, but I am having a little problem
with the reinterpret_cast in the fragment below. [...]
COPYDATASTRUCT* CopyData = reinterpret_cast
<COPYDATASTRUCT*> (m->LParam);

Try replacing m->LParam with m->LParam.ToPointer()




Mattias

Thanks,

I had figured that out shortly after posting that last message.


This transition is very frustrating, my ming is going at 100MPH, but I have
to constantly stop for these frustrating syntax problems. I think one of
the problems, is that I am jumping into the deep end of the pool first.

Anyhow, thanks for the response.

Fred.
 
Back
Top