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


C# Interop.WindowInteropHelper类代码示例

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


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

示例1: GoFullScreen

        public static void GoFullScreen(this Window window)
        {
            if (IsFullScreen(window))
            {
                return;
            }

            windowState = window.WindowState;
            windowStyle = window.WindowStyle;
            windowTopmost = window.Topmost;
            windowResizeMode = window.ResizeMode;
            windowRect.X = window.Left;
            windowRect.Y = window.Top;
            windowRect.Width = window.Width;
            windowRect.Height = window.Height;

            window.WindowState = WindowState.Maximized;
            window.WindowStyle = WindowStyle.None;
            windowTopmost = false;
            windowResizeMode = ResizeMode.NoResize;
            IntPtr handle = new WindowInteropHelper(window).Handle;
            Screen screen = Screen.FromHandle(handle);
            window.Width = screen.Bounds.Width;
            window.Height = screen.Bounds.Height;

            fullWindow = window;
        }
开发者ID:AntZhou,项目名称:AntFramework,代码行数:27,代码来源:WindowExpend.cs

示例2: ShowDialog

 public static CustomMessageBoxResult ShowDialog(Form owner, string caption, string message)
 {
     VersionPickDialog messageBox = new VersionPickDialog();
     var helper = new WindowInteropHelper(messageBox);
     helper.Owner = owner.Handle;
     return messageBox.ShowDialogInternal(caption, message);
 }
开发者ID:Dybuk,项目名称:ME3Explorer,代码行数:7,代码来源:VersionPickDialog.xaml.cs

示例3: PostInitializeWindow

        private void PostInitializeWindow()
        {
            Activate();
            Focus();

            // Set the name of the inspected app to the title
            var process = Process.GetCurrentProcess();
            string processName = process.MainWindowTitle ?? process.ProcessName;
            Title += " -  " + processName;

            try
            {
                var interopHelper = new WindowInteropHelper(this);
                _handle = interopHelper.Handle;
                NativeMethods.SetForegroundWindow(_handle);
            }
            catch (Exception)
            {
            }

            if( _viewModel.ShowUsageHint)
            {
                var usageHintWindow = new UsageHintWindow();
                usageHintWindow.Owner = this;
                usageHintWindow.ShowDialog();
            }

            // Initialize this service
            ServiceLocator.Resolve<MouseElementService>();
        }
开发者ID:bdurrani,项目名称:WPF-Inspector,代码行数:30,代码来源:InspectorWindow.xaml.cs

示例4: LoginDialog_Loaded

 void LoginDialog_Loaded(object sender, RoutedEventArgs e)
 {
     Handle = new WindowInteropHelper(this).Handle;
     Presenter.Initialise(this);
     wb.Navigating += wb_Navigating;
     wb.Navigated += wb_Navigated;
 }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:LoginDialog.xaml.cs

示例5: AfterEngineInit

        public void AfterEngineInit()
        {
            // Basics.
            {
                var deviceDesc = new Device.Descriptor {DebugDevice = true};
                renderDevice = new ClearSight.RendererDX12.Device(ref deviceDesc,
                    ClearSight.RendererDX12.Device.FeatureLevel.Level_11_0);

                var descCQ = new CommandQueue.Descriptor() {Type = CommandListType.Graphics};
                commandQueue = renderDevice.Create(ref descCQ);

                var wih = new WindowInteropHelper(window);
                var swapChainDesc = new SwapChain.Descriptor()
                {
                    AssociatedGraphicsQueue = commandQueue,

                    MaxFramesInFlight = 3,
                    BufferCount = 3,

                    Width = (uint) window.Width,
                    Height = (uint) window.Height,
                    Format = Format.R8G8B8A8_UNorm,

                    SampleCount = 1,
                    SampleQuality = 0,

                    WindowHandle = wih.Handle,
                    Fullscreen = false
                };
                swapChain = renderDevice.Create(ref swapChainDesc);

                var commandListDesc = new CommandList.Descriptor()
                {
                    Type = CommandListType.Graphics,
                    AllocationPolicy = new CommandListInFlightFrameAllocationPolicy(CommandListType.Graphics, swapChain)
                };
                commandList = renderDevice.Create(ref commandListDesc);
            }

            // Render targets.
            {
                var descHeapDesc = new DescriptorHeap.Descriptor()
                {
                    Type = DescriptorHeap.Descriptor.ResourceDescriptorType.RenderTarget,
                    NumResourceDescriptors = swapChain.Desc.BufferCount
                };
                descHeapRenderTargets = renderDevice.Create(ref descHeapDesc);

                var rtvViewDesc = new RenderTargetViewDescription()
                {
                    Format = swapChain.Desc.Format,
                    Dimension = Dimension.Texture2D,
                    Texture = new TextureSubresourceDesc(mipSlice: 0)
                };
                for (uint i = 0; i < swapChain.Desc.BufferCount; ++i)
                {
                    renderDevice.CreateRenderTargetView(descHeapRenderTargets, i, swapChain.BackbufferResources[i], ref rtvViewDesc);
                }
            }
        }
开发者ID:Wumpf,项目名称:ClearSight,代码行数:60,代码来源:Application.cs

示例6: SetWindowStyle

 private void SetWindowStyle()
 {
     var helper = new WindowInteropHelper(this);
     const int gwlExstyle = -20;
     const int wsExNoactivate = 0x08000000;
     NativeWin32.SetWindowLong(helper.Handle, gwlExstyle, (IntPtr)(wsExNoactivate | wsExNoactivate));
 }
开发者ID:GHLabs,项目名称:SambaPOS-3,代码行数:7,代码来源:PopupWindow.xaml.cs

示例7: OnLoaded

 void OnLoaded(object sender, RoutedEventArgs e)
 {
     // Hide Maximize & Size on the system context menu
     var hwnd = new WindowInteropHelper(this).Handle;
     NativeMethods.SetWindowLong(hwnd, NativeMethods.GWL_STYLE,
         NativeMethods.GetWindowLong(hwnd, NativeMethods.GWL_STYLE)  & ~NativeMethods.WS_SYSMENU);
 }
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:ApplicationView.xaml.cs

示例8: wnd_Loaded

        static void wnd_Loaded(object sender, RoutedEventArgs e)
        {
            Window wnd = (Window)sender;
            Brush originalBackground = wnd.Background;
            wnd.Background = Brushes.Transparent;
            try
            {
                IntPtr mainWindowPtr = new WindowInteropHelper(wnd).Handle;
                HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
                mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);

                //System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr);
                //float DesktopDpiX = desktop.DpiX;
                //float DesktopDpiY = desktop.DpiY;

                MARGINS margins = new MARGINS();
                margins.cxLeftWidth = -1;
                margins.cxRightWidth = -1;
                margins.cyTopHeight = -1;
                margins.cyBottomHeight = -1;

                //DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
            }
            catch (DllNotFoundException)
            {
                wnd.Background = originalBackground;
            }
        }
开发者ID:qsqurrl,项目名称:CustomerTrackerWPF,代码行数:28,代码来源:Glass.cs

示例9: ExtendGlassFrame

        public static bool ExtendGlassFrame(Window window, Thickness margin)
        {
            try
            {
                // desktop window manader must be enabled if it isn't don't bother trying to add glass
                if (!DwmIsCompositionEnabled())
                {
                    return false;
                }

                IntPtr hwnd = new WindowInteropHelper(window).Handle;

                if (hwnd == IntPtr.Zero)
                {
                    throw new InvalidOperationException("The Window must be shown before extending glass.");
                }

                // Set the background to transparent from both the WPF and Win32 perspectives
                //window.Background = Brushes.Transparent;
                HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;

                MARGINS margins = new MARGINS(margin);
                DwmExtendFrameIntoClientArea(hwnd, ref margins);
                return true;
            }
            catch
            {
                return false;
            }
        }
开发者ID:maxbpro,项目名称:RelationAnalizer,代码行数:30,代码来源:VistaGlassHelper.cs

示例10: ToFullscreen

        public static void ToFullscreen(this Window window)
        {
            if (window.IsFullscreen())
            { 
                return; 
            }
   
            _windowState = window.WindowState;
            _windowStyle = window.WindowStyle;
            _windowTopMost = window.Topmost;
            _windowResizeMode = window.ResizeMode;
            _windowRect.X = window.Left;
            _windowRect.Y = window.Top;
            _windowRect.Width = window.Width;
            _windowRect.Height = window.Height;

            window.WindowState = WindowState.Normal; 
            window.WindowStyle = WindowStyle.None;
            window.ResizeMode = ResizeMode.NoResize;
            window.Topmost = true; 

          
            var handle = new WindowInteropHelper(window).Handle; 
            Screen screen = Screen.FromHandle(handle); 
            window.MaxWidth = screen.Bounds.Width;
            window.MaxHeight = screen.Bounds.Height;
            window.WindowState = WindowState.Maximized;
             
            window.Activated += new EventHandler(window_Activated);
            window.Deactivated += new EventHandler(window_Deactivated); 
            _fullWindow = window;
        }
开发者ID:jasenkin,项目名称:Jasen.Framework,代码行数:32,代码来源:WindowExtension.cs

示例11: AddInstanceButton_Click

        private void AddInstanceButton_Click(object sender, RoutedEventArgs e)
        {
            NewEnemyInstanceWindow instWindow = new NewEnemyInstanceWindow(this.NewEnemyElement);
            var helper = new WindowInteropHelper(instWindow);
            helper.Owner = new WindowInteropHelper(this).Handle;
            bool? res = instWindow.ShowDialog();
            if (res != null && (bool)res)
            {

            }
            else
            {
               // MessageBox.Show("Did not add new enemy instance");
            }
            /*
             * NewEnemyWindow eneWindow = new NewEnemyWindow();
            var helper = new WindowInteropHelper(eneWindow);
            helper.Owner = new WindowInteropHelper(this).Handle;
            bool? res = eneWindow.ShowDialog();
            if (res != null && (bool)res)
            {
            }
            else
            {
                MessageBox.Show("Did not add new enemy");
            }
             */
        }
开发者ID:MegatronX,项目名称:KHMPOld,代码行数:28,代码来源:NewEnemyWindow.xaml.cs

示例12: OnSourceInitialized

        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            var helper = new WindowInteropHelper(this);
            SetWindowLong(helper.Handle, GWL_EXSTYLE, GetWindowLong(helper.Handle, GWL_EXSTYLE) | WS_EX_NOACTIVATE);
        }
开发者ID:tomotaco,项目名称:ScreenKeyboardEscFn,代码行数:7,代码来源:MainWindow.xaml.cs

示例13: OnShowDialog

 private void OnShowDialog(object sender, EventArgs e)
 {
     var application = (DTE)GetService(typeof(SDTE));
     if (application.Solution == null || !application.Solution.IsOpen)
         MessageBox.Show("Please open a solution first. ", "No solution");
     else
     {
         if (application.Solution.IsDirty) // solution must be saved otherwise adding/removing projects will raise errors
         {
             MessageBox.Show("Please save your solution first. \n" +
                             "Select the solution in the Solution Explorer and press Ctrl-S. ",
                             "Solution not saved");
         }
         else if (application.Solution.Projects.OfType<Project>().Any(p => p.IsDirty))
         {
             MessageBox.Show("Please save your projects first. \n" +
                             "Select the project in the Solution Explorer and press Ctrl-S. ",
                             "Project not saved");
         }
         else
         {
             var window = new MainDialog(application, GetType().Assembly);
             var helper = new WindowInteropHelper(window);
             helper.Owner = (IntPtr)application.MainWindow.HWnd;
             window.ShowDialog();
         }
     }
 }
开发者ID:ndglover,项目名称:NuGetReferenceSwitcher,代码行数:28,代码来源:NuGetReferenceSwitcherPackage.cs

示例14: ExtendGlassFrame

        public static bool ExtendGlassFrame(Window window, Thickness margin)
        {
            // Get the Operating System From Environment Class
            OperatingSystem os = Environment.OSVersion;

            // Get the version information
            Version vs = os.Version;

            if (vs.Major < 6)
                return false;

            if (!DwmIsCompositionEnabled())
                return false;

            IntPtr hwnd = new WindowInteropHelper(window).Handle;
            if (hwnd == IntPtr.Zero)
                throw new InvalidOperationException("Glass cannot be extended before the window is shown.");

            // Set the background to transparent from both the WPF and Win32 perspectives
            window.Background = Brushes.Transparent;
            HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;

            MARGINS margins = new MARGINS(margin);
            DwmExtendFrameIntoClientArea(hwnd, ref margins);

            return true;
        }
开发者ID:brschwalm,项目名称:Vienna,代码行数:27,代码来源:GlassHelper.cs

示例15: ExtendGlassFrame

        public static bool ExtendGlassFrame(Window window, Thickness margin)
        {
            if (!Native.DwmIsCompositionEnabled())
                return false;

            try
            {
                IntPtr hwnd = new WindowInteropHelper(window).Handle;

                if (hwnd == IntPtr.Zero)
                    throw new InvalidOperationException("The Window must be shown before extending glass.");

                // Set the background to transparent from both the WPF and Win32 perspectives
                window.Background = Brushes.Transparent;
                HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;

                Native.MARGINS margins = new Native.MARGINS(margin);
                Native.DwmExtendFrameIntoClientArea(hwnd, ref margins);

                return true;
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Error • Glass");
            }

            return false;
        }
开发者ID:gayancc,项目名称:screentogif,代码行数:28,代码来源:Glass.cs


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