I'm using Python2.7 and Visual Studio 2010 on Windows 7 Professional.
I'm trying to use SendMessage to send a copydatastruct object to a MFC C++ program. The C++ program receives the message fine, however, I cannot figure out the correct data type for the dwData attribute.
The dwData attribute is being checked against variables declared in the C++ code:
#define RUN_ASYNC 0x8001
#define RUN_SYNC 0x8002
...
#define RUN_MCS 0x8012
...
The OnCopyData function in the C++ code has a basic switch statement:
...
switch(pCopyDataStruct->dwData)
{
case RUN_ASYNC:
{
// DO STUFF
}
break;
case RUN_SYNC:
{
// DO STUFF
}
break;
...
case RUN_MCS:
{
// DO STUFF
}
break;
...
default:
TRACE(_T("OnCopyData unknown function"))
break;
}
Since I'm not sending it properly, it never hits the proper case and ends up using the default.
I'm setting up the copydatastruct in my python script as:
class COPYDATASTRUCT(Structure):
_fields_ = [("dwData", c_ulong),
("cbData", c_uint),
("lpData", c_void_p)]
and declaring the variables as:
RUN_ASYNC = 8001
RUN_SYNC = 8002
...
RUN_MCS = 8012
...
This sends the correct four digit number to the C++ program, but it's not being recognized properly for the switch case.
When I declared the variables in the python script as:
RUN_ASYNC = 0x8001
RUN_SYNC = 0x8002
...
RUN_MCS = 0x8012
...
The C++ program receives a number like 32786 that, of course, doesn't work with the switch statement.
How do I need to declare the variables that I'm going to be sending to the C++ program in the dwData attribute to get them to work with the C++ code. I have a feeling that I'm being really stupid, and missing something relatively simple.
Thanks in advance.