• <legend id='H7YV7'><style id='H7YV7'><dir id='H7YV7'><q id='H7YV7'></q></dir></style></legend>

          <bdo id='H7YV7'></bdo><ul id='H7YV7'></ul>
      1. <small id='H7YV7'></small><noframes id='H7YV7'>

        <tfoot id='H7YV7'></tfoot>

        <i id='H7YV7'><tr id='H7YV7'><dt id='H7YV7'><q id='H7YV7'><span id='H7YV7'><b id='H7YV7'><form id='H7YV7'><ins id='H7YV7'></ins><ul id='H7YV7'></ul><sub id='H7YV7'></sub></form><legend id='H7YV7'></legend><bdo id='H7YV7'><pre id='H7YV7'><center id='H7YV7'></center></pre></bdo></b><th id='H7YV7'></th></span></q></dt></tr></i><div id='H7YV7'><tfoot id='H7YV7'></tfoot><dl id='H7YV7'><fieldset id='H7YV7'></fieldset></dl></div>

        .NET 中是否有等效的 Mac OS X 文档模式表?

        时间:2023-10-06

              <i id='B4F3O'><tr id='B4F3O'><dt id='B4F3O'><q id='B4F3O'><span id='B4F3O'><b id='B4F3O'><form id='B4F3O'><ins id='B4F3O'></ins><ul id='B4F3O'></ul><sub id='B4F3O'></sub></form><legend id='B4F3O'></legend><bdo id='B4F3O'><pre id='B4F3O'><center id='B4F3O'></center></pre></bdo></b><th id='B4F3O'></th></span></q></dt></tr></i><div id='B4F3O'><tfoot id='B4F3O'></tfoot><dl id='B4F3O'><fieldset id='B4F3O'></fieldset></dl></div>

              <small id='B4F3O'></small><noframes id='B4F3O'>

                <bdo id='B4F3O'></bdo><ul id='B4F3O'></ul>
                <legend id='B4F3O'><style id='B4F3O'><dir id='B4F3O'><q id='B4F3O'></q></dir></style></legend>
                  <tbody id='B4F3O'></tbody>
                  <tfoot id='B4F3O'></tfoot>
                  本文介绍了.NET 中是否有等效的 Mac OS X 文档模式表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的应用程序收到越来越多的请求,要求某些对话框的行为类似于 Mac OS X Document modal Sheet 功能,其中对话框仅对父控件/对话框而不是整个应用程序是模态的(参见 http://en.wikipedia.org/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 http://en.wikipedia.org/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# .NET 中是否有与 Document modal Sheet 等效的功能?甚至是某人已经完成的紧密实现,还是我自己尝试实现此功能?我尝试搜索 Google 和 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.

                  我接受了 p-daddy 的建议:https://stackoverflow.com/a/428782/654244

                  我使用 hans-passant:https://stackoverflow.com/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);
                  }
                  

                  这篇关于.NET 中是否有等效的 Mac OS X 文档模式表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:WinForms AcceptButton 不起作用? 下一篇:单击提交按钮时,我的 ASPX 文件中的第二个模态不会发布

                  相关文章

                • <i id='X3eVP'><tr id='X3eVP'><dt id='X3eVP'><q id='X3eVP'><span id='X3eVP'><b id='X3eVP'><form id='X3eVP'><ins id='X3eVP'></ins><ul id='X3eVP'></ul><sub id='X3eVP'></sub></form><legend id='X3eVP'></legend><bdo id='X3eVP'><pre id='X3eVP'><center id='X3eVP'></center></pre></bdo></b><th id='X3eVP'></th></span></q></dt></tr></i><div id='X3eVP'><tfoot id='X3eVP'></tfoot><dl id='X3eVP'><fieldset id='X3eVP'></fieldset></dl></div>
                • <legend id='X3eVP'><style id='X3eVP'><dir id='X3eVP'><q id='X3eVP'></q></dir></style></legend>

                    <tfoot id='X3eVP'></tfoot>

                    1. <small id='X3eVP'></small><noframes id='X3eVP'>

                        <bdo id='X3eVP'></bdo><ul id='X3eVP'></ul>