Advertisement
Guest User

タスクバーもどき

a guest
May 24th, 2015
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.57 KB | None | 0 0
  1. Public Class Form1
  2.     Dim 作業領域 As Size
  3.     Dim haba As Integer = 40
  4.  
  5.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  6.  
  7.         'ウィンドウ枠を消す
  8.         Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
  9.  
  10.         '作業領域を取得する
  11.         作業領域 = New Size(System.Windows.Forms.Screen.GetWorkingArea(Me).Width, System.Windows.Forms.Screen.GetWorkingArea(Me).Height)
  12.         'ウィンドウサイズの設定
  13.         Me.Size = New Size(作業領域.Width, haba)
  14.         '表示位置の設定
  15.         Me.Location = New Point(0, 作業領域.Height - haba)
  16.  
  17.     End Sub
  18.  
  19.     'Form1のMouseMoveイベントハンドラ
  20.     Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
  21.  
  22.         'マウスの左ボタンが押されているとき
  23.         If (e.Button And MouseButtons.Left) = MouseButtons.Left Then
  24.  
  25.             Dim x As Integer = 作業領域.Width
  26.             Dim y As Integer = 作業領域.Height
  27.             Dim Mousex As Integer = MousePosition.X
  28.             Dim Mousey As Integer = MousePosition.Y
  29.  
  30.             '左側面に張り付く
  31.             If (Mousex >= 0 And Mousex < x * (1 / 4)) And (Mousey >= 0 And Mousey < y) Then
  32.                 'ウィンドウサイズの設定
  33.                 Me.Size = New Size(haba, y)
  34.                 '表示位置の設定
  35.                 Me.Location = New Point(0, 0)
  36.             End If
  37.  
  38.             '右側面に張り付く
  39.             If (Mousex >= x * (3 / 4) And Mousex < x) And (Mousey >= 0 And Mousey < y) Then
  40.                 'ウィンドウサイズの設定
  41.                 Me.Size = New Size(haba, y)
  42.                 '表示位置の設定
  43.                 Me.Location = New Point(x - haba, 0)
  44.             End If
  45.  
  46.             '上側面に張り付く
  47.             If (Mousex >= x * (1 / 4) And Mousex < x * (3 / 4)) And (Mousey >= 0 And Mousey < y * (1 / 2)) Then
  48.                 'ウィンドウサイズの設定
  49.                 Me.Size = New Size(x, haba)
  50.                 '表示位置の設定
  51.                 Me.Location = New Point(0, 0)
  52.             End If
  53.  
  54.             '下側面に張り付く
  55.             If (Mousex >= x * (1 / 4) And Mousex < x * (3 / 4)) And (Mousey >= y * (1 / 2) And Mousey < y) Then
  56.                 'ウィンドウサイズの設定
  57.                 Me.Size = New Size(x, haba)
  58.                 '表示位置の設定
  59.                 Me.Location = New Point(0, y - haba)
  60.             End If
  61.  
  62.         End If
  63.     End Sub
  64.  
  65. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement