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


C# WindowInteropHelper.ToInt64方法代码示例

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


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

示例1: Register

        /// <summary>
        /// Registers the an element within a window, allowing the user to use it to drag the window.
        /// Make sure that this method is called after the window has loaded; placing it in the 
        /// window's constructor will not work.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <param name="element">The element.</param>
        public static void Register(Window window, UIElement element)
        {
            var windowHandle = new WindowInteropHelper(window).Handle;

            if (windowHandle.ToInt64() > 0)
            {
                element.MouseMove += delegate(object sender, MouseEventArgs e)
                {
                    if (e.Source == element)
                    {
                        Action moveWindow = () =>
                            {
                                if (e.LeftButton == MouseButtonState.Pressed)
                                {
                                    ReleaseCapture();
                                    SendMessage(
                                        windowHandle,
                                        WM_NCLBUTTONDOWN,
                                        HT_CAPTION, 0);
                                }
                            };

                        // This may seem a bit odd; I was encountering an odd exception with the
                        // moveWindow code when I did not use the dispatcher and tried to drag off
                        // of a control that was not the window itself.
                        // More details here: http://stackoverflow.com/questions/7442943/dispatcher-throws-invalidoperationexception-on-messagebox-show-in-textchanged-ev#answer-7443519
                        Application.Current.Dispatcher.BeginInvoke(
                            DispatcherPriority.Normal,
                            moveWindow);
                    }
                };
            }
        }
开发者ID:hrudham,项目名称:Quicken,代码行数:40,代码来源:Draggable.cs

示例2: Flash

 /// <summary>
 /// Flashes the window in the task bar.
 /// </summary>
 /// <param name="window">The Window instance.</param>
 /// <returns></returns>
 public static bool Flash(this Window window)
 {
     IntPtr hWnd = new WindowInteropHelper(window).Handle;
     if (hWnd.ToInt64() != 0)
     {
         FLASHWINFO fInfo = new FLASHWINFO();
         fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
         fInfo.hwnd = hWnd;
         fInfo.dwFlags = FLASHW_TIMER | FLASHW_TRAY;
         fInfo.uCount = 3;
         fInfo.dwTimeout = 0;
         return FlashWindowEx(ref fInfo);
     }
     return false;
 }
开发者ID:uxoricide,项目名称:TxTranslation,代码行数:20,代码来源:WindowExtensions.cs

示例3: HideIcon

 /// <summary>
 /// Hides the icon in the window title bar.
 /// </summary>
 /// <param name="window">The Window instance.</param>
 public static void HideIcon(this Window window)
 {
     IntPtr hwnd = new WindowInteropHelper(window).Handle;
     if (hwnd.ToInt64() == 0)
     {
         window.SourceInitialized += (s, e) => HideIcon(window);
     }
     else
     {
         uint exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
         SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_DLGMODALFRAME);
         SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
         SendMessage(hwnd, WM_SETICON, new IntPtr(1), IntPtr.Zero);   // Important if there's a native icon resource in the .exe file
         SendMessage(hwnd, WM_SETICON, IntPtr.Zero, IntPtr.Zero);
     }
 }
开发者ID:uxoricide,项目名称:TxTranslation,代码行数:20,代码来源:WindowExtensions.cs

示例4: HideMaximizeBox

 /// <summary>
 /// Hides the maximize button in the window title bar.
 /// </summary>
 /// <param name="window">The Window instance.</param>
 public static void HideMaximizeBox(this Window window)
 {
     IntPtr hwnd = new WindowInteropHelper(window).Handle;
     if (hwnd.ToInt64() == 0)
     {
         window.SourceInitialized += (s, e) => HideMaximizeBox(window);
     }
     else
     {
         SetWindowLong(hwnd, GWL_STYLE,
             GetWindowLong(hwnd, GWL_STYLE) & ~(WS_MAXIMIZEBOX));
     }
 }
开发者ID:uxoricide,项目名称:TxTranslation,代码行数:17,代码来源:WindowExtensions.cs


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