是否有Mac OS X的文件模式板的.NET等效?

编程入门 行业动态 更新时间:2024-10-21 07:39:55
本文介绍了是否有Mac OS X的文件模式板的.NET等效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的申请已被越来越多的要求有一定的对话的行为类似的 Mac OS X的文件模式表的功能,其中一个对话框是模式只父控件/对话框,而不是整个应用程序(见的 en.wikipedia/wiki/Window_dialog )。

My application has been getting more and more requests to have certain dialogs behave similar to Mac OS X Document modal Sheet functionality, where a dialog is modal to just the parent control/dialog, and not the whole application (see en.wikipedia/wiki/Window_dialog).

当前窗口的ShowDialog()不足以满足我的应用程序的需要,我需要有一个对话框是模态的应用程序中的另一个对话框,但仍允许访问应用程序的其他地区的用户。

Current windows ShowDialog() is insufficient for the needs of my application, as I need to have a dialog be modal to another dialog in the application, but still allow the user to access other areas of the application.

有一个等同于文档中的C#模态表?甚至接近实现有人做,还是我对我自己,试图实现这个功能?我试图寻找谷歌和SO无济于事。

Is there an equivalent to Document modal Sheet in C# .NET? Or even a close implementation someone has done, or am I on my own to try and implement this functionality? I tried searching Google and SO to no avail.

谢谢

凯尔

推荐答案

重新审视这个问题之后,我做了一些挖掘和发现,将工作我需要一个混合解决方案。

After revisiting this issue, I did some digging and found a hybrid solution that will work for my needs.

我把建议由对爸爸:的stackoverflow/a/428782/654244

和我修改了code工作的32位和64位编译使用的建议,由 hans-顺便: stackoverflow/a/3344276/654244

And I modified the code to work for 32-bit and 64-bit compiles using the suggestion by hans-passant: stackoverflow/a/3344276/654244

结果如下:

const int GWL_STYLE = -16; const int WS_DISABLED = 0x08000000; public static int GetWindowLong(IntPtr hWnd, int nIndex) { if (IntPtr.Size == 4) { return GetWindowLong32(hWnd, nIndex); } return GetWindowLongPtr64(hWnd, nIndex); } public static int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong) { if (IntPtr.Size == 4) { return SetWindowLong32(hWnd, nIndex, dwNewLong); } return SetWindowLongPtr64(hWnd, nIndex, dwNewLong); } [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)] private static extern int GetWindowLong32(IntPtr hWnd, int nIndex); [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto)] private static extern int GetWindowLongPtr64(IntPtr hWnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)] private static extern int SetWindowLong32(IntPtr hWnd, int nIndex, int dwNewLong); [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr", CharSet = CharSet.Auto)] private static extern int SetWindowLongPtr64(IntPtr hWnd, int nIndex, int dwNewLong); public static void SetNativeEnabled(IWin32Window control, bool enabled) { if (control == null || control.Handle == IntPtr.Zero) return; NativeMethods.SetWindowLong(control.Handle, NativeMethods.GWL_STYLE, NativeMethods.GetWindowLong(control.Handle, NativeMethods.GWL_STYLE) & ~NativeMethods.WS_DISABLED | (enabled ? 0 : NativeMethods.WS_DISABLED)); } public static void ShowChildModalToParent(IWin32Window parent, Form child) { if (parent == null || child == null) return; //Disable the parent. SetNativeEnabled(parent, false); child.Closed += (s, e) => { //Enable the parent. SetNativeEnabled(parent, true); }; child.Show(parent); }

更多推荐

是否有Mac OS X的文件模式板的.NET等效?

本文发布于:2023-10-07 15:19:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469749.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模式   文件   Mac   OS   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!