locked
How to make mouse disable? RRS feed

  • Question

  • I created two maximized windows. I need the two windows are mouse disable. So I set this.Cursor = Cursors.None;. One is parent window, another is child window. When parent window shows child window, the mouse cursor is visible. And I move the mouse, the cursor is disappearing. In fact, I want to mouse cursor is invisible always. I was puzzled what should I do.

    //Window1.xaml.

    //The main window .Press “Show second window” to call second window.

    <Window x:Class="CursorsTest.Window1"  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="CursorsTest" Height="500" Width="500" Background="Black"WindowStyle="None" AllowsTransparency="True" WindowState="Maximized">

    <Grid>

    <Button Name="btnShow" Content="Show second window" Width="200" Height="50" Click="btnShow_Click"/>

    </Grid>

    </Window>

    //Window1.xaml.cs

       public partial class Window1 : System.Windows.Window

        {

            public Window1()

            {

                InitializeComponent();

                this.Cursor = Cursors.None;

                btnShow.Focus();

            }

     

            void btnShow_Click(object sender, RoutedEventArgs e)

            {

                w2 Dlg = new w2();

                Dlg.ShowDialog();

            }

        }

    //w2.xaml.

    //The child window.

    <Window x:Class="CursorsTest.w2"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="CursorsTest" Height="500" Width="500" Background="Black"

        WindowStyle="None" AllowsTransparency="True" WindowState="Maximized"

        >

        <Grid>

          <Button Name="btnDialog"  Content="Second widow" Width="100" Height="50"   Click="btnShow_Click"/>

         </Grid>

    </Window>

    //w2.xaml.cs

    public partial class w2 : System.Windows.Window

        {

            public w2()

            {

                InitializeComponent();

                this.Cursor = Cursors.None;

                btnDialog.Focus();

             

            }

            void btnShow_Click(object sender, RoutedEventArgs e)

            {

                Application.Current.Shutdown(0);

            }

        }

    Monday, October 23, 2006 10:43 AM