2017-03-20 22 views
0

私はカスタムウィンドウのサイズを変更したいので、windowstyle=noneです。
そのためにはありませんいくつかのOpen-Sourelibを使いたいです。 だから、これはGoogle経由でarticleでした。 私は、コードのサイズを変更するための代わりの四角形のボタンを使用したいので、私は、コードを少し変更した後は、次のようになります。カーソル位置と異なるマウス位置へのリサイズ

Private bottomResize As Boolean = False 
    Private initBtmY As Double 

    Private Sub BottomResizeRect_MouseEnter _ 
    (ByVal sender As Object, ByVal e As _ 
    System.Windows.Input.MouseEventArgs) _ 
    Handles btResizeAndFold.MouseEnter 

     bottomResize = False 
     'Console.WriteLine("Mouse Enter called") 
    End Sub 

    Dim boing As Boolean = False 
    Private Sub BottomResizeRect_MouseLeftButtonDown _ 
    (ByVal sender As Object, ByVal e As _ 
    System.Windows.Input.MouseButtonEventArgs) _ 
    Handles btResizeAndFold.PreviewMouseLeftButtonDown 
     bottomResize = True 
     boing = True 
     'Console.WriteLine("Mouse left down called") 

     'Get the initial Y coordinate 
     'cursor location on our window 
     initBtmY = e.GetPosition(Me).Y 
    End Sub 

    Private Sub BottomResizeRect_MouseLeftButtonUp _ 
    (ByVal sender As Object, 
    ByVal e As System.Windows.Input.MouseButtonEventArgs) _ 
    Handles btResizeAndFold.PreviewMouseLeftButtonUp 
     'Console.WriteLine("Mouse left up called") 
     bottomResize = False 
     btResizeAndFold.ReleaseMouseCapture() 
    End Sub 

    Private Sub BottomResizeRect_MouseMove _ 
    (ByVal sender As Object, ByVal e As _ 
    System.Windows.Input.MouseEventArgs) _ 
    Handles btResizeAndFold.PreviewMouseMove 
     'Get the new Y coordinate cursor location 

     Dim newBtmY As Double = e.GetPosition(Me).Y 
     'Get the change between the initial and 
     'new cursor location 
     Dim diff As Double = initBtmY - newBtmY 
     'Minimum window height 
     Dim minHeight As Integer = 200 
     Dim differnceConstant = 5 

     If bottomResize = True And (diff > differnceConstant Or diff < (differnceConstant * -1)) Then 
      'Let our rectangle capture the mouse 
      btResizeAndFold.CaptureMouse() 

      Dim newHeight = e.GetPosition(Me).Y - diff 

      If newHeight > minHeight Then 
       Me.Height = newHeight 
      End If 

     End If 
    End Sub 

問題は、今私が押して私の窓のサイズを変更しようとするということであり、マウスの左ボタンをクリックしてマウスをドラッグすると、ウィンドウの高さの増減がマウスカーソルの動きと同期していないので、問題はマウスsychronosの動きをウィンドウの成長にいかにするかです

答えて