Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim 作業領域 As Size
- Dim haba As Integer = 40
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'ウィンドウ枠を消す
- Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
- '作業領域を取得する
- 作業領域 = New Size(System.Windows.Forms.Screen.GetWorkingArea(Me).Width, System.Windows.Forms.Screen.GetWorkingArea(Me).Height)
- 'ウィンドウサイズの設定
- Me.Size = New Size(作業領域.Width, haba)
- '表示位置の設定
- Me.Location = New Point(0, 作業領域.Height - haba)
- End Sub
- 'Form1のMouseMoveイベントハンドラ
- Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
- 'マウスの左ボタンが押されているとき
- If (e.Button And MouseButtons.Left) = MouseButtons.Left Then
- Dim x As Integer = 作業領域.Width
- Dim y As Integer = 作業領域.Height
- Dim Mousex As Integer = MousePosition.X
- Dim Mousey As Integer = MousePosition.Y
- '左側面に張り付く
- If (Mousex >= 0 And Mousex < x * (1 / 4)) And (Mousey >= 0 And Mousey < y) Then
- 'ウィンドウサイズの設定
- Me.Size = New Size(haba, y)
- '表示位置の設定
- Me.Location = New Point(0, 0)
- End If
- '右側面に張り付く
- If (Mousex >= x * (3 / 4) And Mousex < x) And (Mousey >= 0 And Mousey < y) Then
- 'ウィンドウサイズの設定
- Me.Size = New Size(haba, y)
- '表示位置の設定
- Me.Location = New Point(x - haba, 0)
- End If
- '上側面に張り付く
- If (Mousex >= x * (1 / 4) And Mousex < x * (3 / 4)) And (Mousey >= 0 And Mousey < y * (1 / 2)) Then
- 'ウィンドウサイズの設定
- Me.Size = New Size(x, haba)
- '表示位置の設定
- Me.Location = New Point(0, 0)
- End If
- '下側面に張り付く
- If (Mousex >= x * (1 / 4) And Mousex < x * (3 / 4)) And (Mousey >= y * (1 / 2) And Mousey < y) Then
- 'ウィンドウサイズの設定
- Me.Size = New Size(x, haba)
- '表示位置の設定
- Me.Location = New Point(0, y - haba)
- End If
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement