当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.GetWindowPlacement方法代码示例

本文整理汇总了C#中System.IntPtr.GetWindowPlacement方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.GetWindowPlacement方法的具体用法?C# IntPtr.GetWindowPlacement怎么用?C# IntPtr.GetWindowPlacement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.GetWindowPlacement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResizeCustomControl

    private void ResizeCustomControl(IntPtr hWnd, InteropUtil.RECT rect, params IntPtr[] buttons)
    {
      DialogUtil.Assume(buttons != null && buttons.Length > 0);

      hWnd.AssumeNonZero();

      var wndLoc = hWnd.GetWindowPlacement();

      wndLoc.Right = rect.right;
      hWnd.SetWindowPlacement(ref wndLoc);

      foreach (var hBtn in buttons)
      {
        int btnRight, btnWidth;

        m_calcPosMap[hBtn.GetDlgCtrlID()](this, rect.right, out btnRight, out btnWidth);

        PositionButton(hBtn, btnRight, btnWidth);
      }

      //see bug # 844
      //We clip hWnd to only draw in the rectangle around our custom buttons.
      //When we supply a custom dialog template to GetOpenFileName(), it adds 
      //an extra HWND to the open file dialog, and then sticks all the controls 
      //in the dialog //template inside the HWND. It then resizes the control 
      //to stretch from the top of the open file dialog to the bottom of the 
      //window, extending the bottom of the window large enough to include the 
      //additional height of the dialog template. This ends up sticking our custom
      //buttons at the bottom of the window, which is what we want.
      //
      //However, the fact that the parent window extends from the top of the open 
      //file dialog was causing some painting problems on Windows XP SP 3 systems. 
      //Basically, because the window was covering the predefined controls on the 
      //open file dialog, they were not getting painted. This results in a blank 
      //window. I tried setting an extended WS_EX_TRANSPARENT style on the dialog, 
      //but that didn't help.
      //
      //So, to fix the problem I setup a window region for the synthetic HWND. 
      //This clips the drawing of the window to only within the region containing
      //the custom buttons, and thus avoids the problem.
      //
      //I'm not sure why this wasn't an issue on Vista. 
      var hRgn = InteropUtil.CreateRectRgnIndirect(ref rect);
      try
      {
        if (hWnd.SetWindowRgn(hRgn, true) == 0)
        {
          //setting the region failed, so we need to delete the region we created above.
          hRgn.DeleteObject();
        }
      }
      catch
      {

        if (hRgn != IntPtr.Zero)
        {
          hRgn.DeleteObject();
        }
      }
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:60,代码来源:OpenFileOrFolderDialog.cs

示例2: PositionButton

    private void PositionButton(IntPtr hWnd, int right, int width)
    {
      hWnd.AssumeNonZero();
      var id = hWnd.GetDlgCtrlID();

      //hWnd.BringWindowToTop();

      var buttonLoc = hWnd.GetWindowPlacement();

      buttonLoc.Right = right;
      buttonLoc.Left = buttonLoc.Right - width;
      hWnd.SetWindowPlacement(ref buttonLoc);
      hWnd.InvalidateRect(IntPtr.Zero, true);

    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:15,代码来源:OpenFileOrFolderDialog.cs

示例3: InitDialog

    private void InitDialog(IntPtr hWnd)
    {
      m_hWnd = hWnd;

      var hParent = hWnd.GetParent().AssumeNonZero();
      hParent.SetWindowSubclass(m_openFileSubClassDelegate, 0, 0);

      //disable and hide the filter combo box
      var hFilterCombo = hParent.GetDlgItem(InteropUtil.ID_FilterCombo).AssumeNonZero();
      hFilterCombo.EnableWindow(false);
      hParent.SendMessage(InteropUtil.CDM_HIDECONTROL, InteropUtil.ID_FilterCombo, 0);
      hParent.SendMessage(InteropUtil.CDM_HIDECONTROL, InteropUtil.ID_FilterLabel, 0);

      //update the file name label
      var hFileNameLabel = hParent.GetDlgItem(InteropUtil.ID_FileNameLabel).AssumeNonZero();

      if (FileNameLabel != "")
      {
        hFileNameLabel.SendMessageString(InteropUtil.WM_SETTEXT, 0, FileNameLabel);
      }

      //find the button controls in the parent
      var hOkButton = hParent.GetDlgItem(InteropUtil.IDOK).AssumeNonZero();
      var hCancelButton = hParent.GetDlgItem(InteropUtil.IDCANCEL).AssumeNonZero();

      //We don't want the accelerator keys for the ok and cancel buttons to work, because
      //they are not shown on the dialog. However, we still want the buttons enabled
      //so that "esc" and "enter" have the behavior they used to. So, we just
      //clear out their text instead.
      hOkButton.SetWindowTextW("");
      hCancelButton.SetWindowTextW("");

      //find our button controls
      var hSelectButton = hWnd.GetDlgItem(InteropUtil.ID_SELECT).AssumeNonZero();
      var hCustomCancelButton = hWnd.GetDlgItem(InteropUtil.ID_CUSTOM_CANCEL).AssumeNonZero();

      //copy the font from the parent's buttons
      hSelectButton.LoadFontFrom(hOkButton);
      hCustomCancelButton.LoadFontFrom(hCancelButton);

      var cancelLoc = hCancelButton.GetWindowPlacement();

      //hide the ok and cancel buttons
      hParent.SendMessage(InteropUtil.CDM_HIDECONTROL, InteropUtil.IDOK, 0);
      hParent.SendMessage(InteropUtil.CDM_HIDECONTROL, InteropUtil.IDCANCEL, 0);

      //expand the file name combo to take up the space left by the OK and cancel buttons.
      var hFileName = hParent.GetDlgItem(InteropUtil.ID_FileNameCombo).AssumeNonZero();
      var fileNameLoc = hFileName.GetWindowPlacement();
      fileNameLoc.Right = hOkButton.GetWindowPlacement().Right;
      hFileName.SetWindowPlacement(ref fileNameLoc);

      var parentLoc = hParent.GetWindowPlacement();

      //subtract the height of the missing cancel button
      parentLoc.Bottom -= (cancelLoc.Bottom - cancelLoc.Top);
      hParent.SetWindowPlacement(ref parentLoc);

      //move the select and custom cancel buttons to the right hand side of the window:

      var selectLoc = hSelectButton.GetWindowPlacement();
      var customCancelLoc = hCustomCancelButton.GetWindowPlacement();
      m_cancelWidth = customCancelLoc.Right - customCancelLoc.Left;
      m_selectWidth = selectLoc.Right - selectLoc.Left;
      m_buttonGap = customCancelLoc.Left - selectLoc.Right;

      var ctrlLoc = hWnd.GetWindowPlacement();
      ctrlLoc.Right = fileNameLoc.Right;

      //ResizeCustomControl(hWnd, fileNameLoc.Right, hCustomCancelButton, hSelectButton);
      ResizeCustomControl(hWnd);
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:72,代码来源:OpenFileOrFolderDialog.cs


注:本文中的System.IntPtr.GetWindowPlacement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。