G
Guest
Hi,
I have CLI/C++ code to override WndProc(Message% m) in order to create NC
area. I tried to marshal unmanaged ptr (m.LParam) to managed object by using
Marshal:trToStructure like:
if (m.WParam == IntPtr(1))
{
NCCALCSIZE_PARAMS csp;
csp = (NCCALCSIZE_PARAMS)Marshal:trToStructure(m.LParam,
(NCCALCSIZE_PARAMS));
csp.rgrc[0].top += borderWidth;
csp.rgrc[0].bottom -= borderWidth;
csp.rgrc[0].left += borderWidth;
csp.rgrc[0].right -= borderWidth;
Marshal::StructureToPtr(csp, m.LParam, false);
}
I'm having difficult in creating the managed type of the NCCALCSIZE_PARAMS
in order to pass to PtrToStructure as the second parameter. I've tried some
suggestions from the forum unsuccessfully. In C#, it's easily done by
typeof(NCCALCSIZE_PARAMS). Is any easy way to translate this C# yntax to
CLI/C++ equavilent. Or, do I have to do in a hard way -- create a managed
equavilent value structure, copy native pointered NCCALCSIZE_PARAMS data into
the managed structure and then marshal back to native structure ptr after
modifying data in order to pass out WinProc. It's messy. Why doesn't CLI/C++
have an easy syntax as C# in this regard. Anyone has a good idea of it?
Thanks
I have CLI/C++ code to override WndProc(Message% m) in order to create NC
area. I tried to marshal unmanaged ptr (m.LParam) to managed object by using
Marshal:trToStructure like:
if (m.WParam == IntPtr(1))
{
NCCALCSIZE_PARAMS csp;
csp = (NCCALCSIZE_PARAMS)Marshal:trToStructure(m.LParam,
(NCCALCSIZE_PARAMS));
csp.rgrc[0].top += borderWidth;
csp.rgrc[0].bottom -= borderWidth;
csp.rgrc[0].left += borderWidth;
csp.rgrc[0].right -= borderWidth;
Marshal::StructureToPtr(csp, m.LParam, false);
}
I'm having difficult in creating the managed type of the NCCALCSIZE_PARAMS
in order to pass to PtrToStructure as the second parameter. I've tried some
suggestions from the forum unsuccessfully. In C#, it's easily done by
typeof(NCCALCSIZE_PARAMS). Is any easy way to translate this C# yntax to
CLI/C++ equavilent. Or, do I have to do in a hard way -- create a managed
equavilent value structure, copy native pointered NCCALCSIZE_PARAMS data into
the managed structure and then marshal back to native structure ptr after
modifying data in order to pass out WinProc. It's messy. Why doesn't CLI/C++
have an easy syntax as C# in this regard. Anyone has a good idea of it?
Thanks