zoukankan      html  css  js  c++  java
  • WINFORM跟随WPF窗体移动

    <Window x:Name="mainWindow1" x:Class="WpfApplication9.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
        Title="MainWindow"  Width="984" Height="747" LocationChanged="mainWindow1_LocationChanged"  Loaded="mainWindow1_Loaded" 
            Background="Transparent" OpacityMask="White" AllowsTransparency="True" WindowStyle="None" Cursor="Arrow"
           WindowStartupLocation="CenterScreen"  
            >
        
        <Grid Margin="0,0,0,-121"    Loaded="Grid_Loaded" >
            <Image x:Name="image1" Stretch="Fill" Source="main-bg.png" StretchDirection="Both" Width="984" Height="747" MouseDown="image1_MouseDown" Margin="0,0,0,121" />
            <Button x:Name="btn1" Content="X" HorizontalAlignment="Left" VerticalAlignment="Top" Width="58" Margin="693,333,0,0" Click="Button_Click" Height="28" RenderTransformOrigin="-0.698,0.511"/>
            <Rectangle x:Name="rect1" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="222" Margin="235,377,0,0" Stroke="Black" VerticalAlignment="Top" Width="516"/>
            <Label x:Name="lbl1" Content="Label" HorizontalAlignment="Left" Margin="102,246,0,0" VerticalAlignment="Top" Width="196"/>
            <Button Content="-" HorizontalAlignment="Left" Height="28" Margin="641,333,0,0" VerticalAlignment="Top" Width="47" Click="Button_Click_1"/>
        </Grid>
    </Window>




    namespace WpfApplication9
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
               
            }
            private void Button_Click(object senderRoutedEventArgs e)
            {
                Close();
            }
     
            Form1 frm1 = new Form1();
            private void Grid_Loaded(object senderRoutedEventArgs e)
            {
                MoveFuc(); 
            }
            private void MoveFuc()
            {
                frm1.Left = (int)mainWindow1.Left + (int)rect1.Margin.Left;
                frm1.Top = (int)mainWindow1.Top + (int)rect1.Margin.Top;
                frm1.Width = (int)rect1.Width;
                frm1.Height = (int)rect1.Height;           
            }
            private void mainWindow1_LocationChanged(object senderEventArgs e)
            {
                MoveFuc();
            }
       
            private void mainWindow1_Loaded(object senderRoutedEventArgs e)
            {
                frm1.Show();
            }
            private void image1_MouseDown(object senderMouseButtonEventArgs e)
            {
                DragMove();
            }
            private void Button_Click_1(object senderRoutedEventArgs e)
            {
                mainWindow1.WindowState = System.Windows.WindowState.Minimized;
                frm1.WindowState = System.Windows.Forms.FormWindowState.Minimized;
            }
     
        }
    }




    附件列表

    • 相关阅读:
      微信小程序之授权 wx.authorize
      微信小程序之可滚动视图容器组件 scroll-view
      纯 CSS 利用 label + input 实现选项卡
      Nuxt.js + koa2 入门
      koa2 入门(1)koa-generator 脚手架和 mongoose 使用
      vue 自定义指令
      时运赋
      WEBGL 2D游戏引擎研发系列 第一章 <新的开始>
      EasyUI特殊情况下的BUG整理
      数字时钟DigClock
    • 原文地址:https://www.cnblogs.com/xe2011/p/3758652.html
    Copyright © 2011-2022 走看看