关于64位机器中对话框消息的问题 [英] a question about dialog message in 64 bit machine
问题描述
所有
我们正在使用C#和可扩展对话框来创建我们自己的对话框。
它在32位机器上运行良好。
问题是,我可以捕获对话框Notify消息,当我将lParam转换为OFNotify时
IntPtr ipNotify = new IntPtr(lParam) ;
OfNotify ofNot =(OfNotify)Marshal.PtrToStructure(ipNotify,
typeof(OfNotify));
UInt16 code = ofNot.code;
在64位机器中,代码始终为零。
我为OfNotify结构尝试了两种不同的结构
[StructLayout(LayoutKind.Explicit)]
内部结构OfNotify_1
{
[ FieldOffset(0)]公共NMHDR hdr;
[FieldOffset(12)] public IntPtr ipOfn;
[FieldOffset(16)] public IntPtr ipFile;
};
///< summary>
///公共对话框发送的部分通知消息
///< / summary>
[StructLayout(LayoutKind.Explicit)]
内部结构NMHDR
{
[FieldOffset(0)] public IntPtr hWndFrom;
[FieldOffset(4)] public UInt16 idFrom;
[FieldOffset(8)]公共UInt16代码;
};
和
[StructLayout(LayoutKind.Sequential,CharSet = CharSet.Ansi)]
内部结构OfNotify
{
//内部NMHDR hdr; // FIXME:无法封送
内部IntPtr hwndFrom;
internal int idFrom;
内部UInt16代码;
内部IntPtr lpOFN;
//内部字符串pszFile; // FIXME:不能被编组
内部IntPtr pszFile;
}
它们不起作用。代码始终为零。
以前有人有同样的问题吗?
我解决了!
我解决了!
我解决了!
我自己!
我自己!
我自己!
搜索结果
hi, all
We are using C# with the Extensible Dialog to make our own dialog.
It makes fine in 32 bit machine.
The problem is, I can catch the dialog Notify message, when I convert
the lParam to OFNotify
IntPtr ipNotify = new IntPtr(lParam);
OfNotify ofNot = (OfNotify)Marshal.PtrToStructure(ipNotify,
typeof(OfNotify));
UInt16 code = ofNot.code;
in 64 bit machine, code is always zero.
I tried two different structure for OfNotify structure
[StructLayout(LayoutKind.Explicit)]
internal struct OfNotify_1
{
[FieldOffset(0)] public NMHDR hdr;
[FieldOffset(12)] public IntPtr ipOfn;
[FieldOffset(16)] public IntPtr ipFile;
};
/// <summary>
/// Part of the notification messages sent by the common dialogs
/// </summary>
[StructLayout(LayoutKind.Explicit)]
internal struct NMHDR
{
[FieldOffset(0)] public IntPtr hWndFrom;
[FieldOffset(4)] public UInt16 idFrom;
[FieldOffset(8)] public UInt16 code;
};
and
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal struct OfNotify
{
//internal NMHDR hdr; // FIXME: cannot be marshaled
internal IntPtr hwndFrom;
internal int idFrom;
internal UInt16 code;
internal IntPtr lpOFN;
//internal string pszFile; // FIXME: cannot be
marshaled
internal IntPtr pszFile;
}
they don't work. the code is always zero.
Any one had the same issue before?
I resolved it !
I resolved it !
I resolved it !
by myself !
by myself !
by myself !
这篇关于关于64位机器中对话框消息的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!