ok.

vb Code:
  1. Imports System
  2. Imports System.Drawing
  3. Imports System.Collections
  4. Imports System.ComponentModel
  5. Imports System.Windows.Forms
  6. Imports System.Data
  7. Imports System.Runtime.InteropServices
  8.  
  9. Public Class mainform
  10.  
  11.     Private Structure RECT
  12.         Public left As Integer
  13.         Public top As Integer
  14.         Public right As Integer
  15.         Public bottom As Integer
  16.     End Structure
  17.  
  18.     Private Structure APPBARDATA
  19.         Public cbSize As Integer
  20.         Public hWnd As IntPtr
  21.         Public uCallbackMessage As Integer
  22.         Public uEdge As Integer
  23.         Public rc As RECT
  24.         Public lParam As IntPtr
  25.     End Structure
  26.  
  27.     Private Enum ABMsg As Integer
  28.         ABM_NEW = 0
  29.         ABM_REMOVE = 1
  30.         ABM_QUERYPOS = 2
  31.         ABM_SETPOS = 3
  32.         ABM_GETSTATE = 4
  33.         ABM_GETTASKBARPOS = 5
  34.         ABM_ACTIVATE = 6
  35.         ABM_GETAUTOHIDEBAR = 7
  36.         ABM_SETAUTOHIDEBAR = 8
  37.         ABM_WINDOWPOSCHANGED = 9
  38.         ABM_SETSTATE = 10
  39.     End Enum
  40.  
  41.     Private Enum ABNotify As Integer
  42.         ABN_STATECHANGE = 0
  43.         ABN_POSCHANGED
  44.         ABN_FULLSCREENAPP
  45.         ABN_WINDOWARRANGE
  46.     End Enum
  47.  
  48.     Private Enum ABEdge As Integer
  49.         ABE_LEFT = 0
  50.         ABE_TOP = 1
  51.         ABE_RIGHT = 2
  52.         ABE_BOTTOM = 3
  53.     End Enum
  54.  
  55.     Private fBarRegistered As Boolean = False
  56.  
  57.     Private Declare Function SHAppBarMessage Lib "shell32.dll" Alias "SHAppBarMessage" _
  58.     (ByVal dwMessage As Integer, <MarshalAs(UnmanagedType.Struct)> ByRef pData As _
  59.     APPBARDATA) As Integer
  60.  
  61.     Private Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" _
  62.     (ByVal nIndex As Integer) As Integer
  63.  
  64.     Private Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Integer, _
  65.     ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, _
  66.     ByVal bRepaint As Integer) As Integer
  67.  
  68.     Private Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" _
  69.     (ByVal lpString As String) As Integer
  70.  
  71.     Private uCallBack As Integer
  72.  
  73.     Dim icons As Integer = 0
  74.  
  75.     Private Sub mainform_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
  76.         If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  77.             Dim files() As String = DirectCast(e.Data.GetData(DataFormats.FileDrop, False), String())
  78.             For Each file As String In files
  79.                 Dim pb As New PictureBox
  80.                 pb.Size = New Size(32, 32)
  81.                 pb.Location = New Point(12 + (icons * 44), 12)
  82.                 pb.Tag = file
  83.                 Dim icon As Icon = icon.ExtractAssociatedIcon(file)
  84.                 pb.Image = icon.ToBitmap
  85.                 pb.Cursor = Cursors.Hand
  86.                 AddHandler pb.DoubleClick, AddressOf pb_DoubleClick
  87.                 ToolTip1.SetToolTip(pb, file)
  88.                 Me.Controls.Add(pb)
  89.                 icons += 1
  90.             Next
  91.         End If
  92.     End Sub
  93.  
  94.     Private Sub pb_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
  95.         Process.Start(DirectCast(sender, PictureBox).Tag.ToString)
  96.     End Sub
  97.  
  98.     Private Sub mainform_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragOver
  99.         If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  100.             e.Effect = DragDropEffects.Copy
  101.         Else
  102.             e.Effect = DragDropEffects.None
  103.         End If
  104.     End Sub
  105.  
  106.     Private Sub mainform_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  107.         RegisterBar()
  108.     End Sub
  109.  
  110.     Private Sub appBar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  111.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  112.         Me.ClientSize = New System.Drawing.Size(1024, 56)
  113.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
  114.  
  115.         RegisterBar()
  116.         Me.Invalidate()
  117.     End Sub
  118.  
  119.     Private Sub mainform_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
  120.         e.Graphics.DrawLine(New Pen(Color.White, 3), 0, 0, Me.Width, 0)
  121.         e.Graphics.DrawLine(New Pen(Color.White, 3), 0, 0, 0, Me.Height)
  122.         e.Graphics.DrawLine(New Pen(Color.Black, 3), 0, Me.Height - 3, Me.Width, Me.Height - 3)
  123.         e.Graphics.DrawLine(New Pen(Color.Black, 3), Me.Width - 3, 0, Me.Width - 3, Me.Height)
  124.     End Sub
  125.  
  126.     Private Sub RegisterBar()
  127.         Dim abd As New APPBARDATA
  128.         abd.cbSize = Marshal.SizeOf(abd)
  129.         abd.hWnd = Me.Handle
  130.         If Not fBarRegistered Then
  131.             uCallBack = RegisterWindowMessage("AppBarMessage")
  132.             abd.uCallbackMessage = uCallBack
  133.  
  134.             Dim ret As Integer = SHAppBarMessage(CType(ABMsg.ABM_NEW, Integer), abd)
  135.             fBarRegistered = True
  136.  
  137.             ABSetPos()
  138.         Else
  139.             SHAppBarMessage(CType(ABMsg.ABM_REMOVE, Integer), abd)
  140.             fBarRegistered = False
  141.         End If
  142.     End Sub
  143.  
  144.  
  145.     Private Sub ABSetPos()
  146.         Dim abd As New APPBARDATA()
  147.         abd.cbSize = Marshal.SizeOf(abd)
  148.         abd.hWnd = Me.Handle
  149.         abd.uEdge = CInt(ABEdge.ABE_BOTTOM)
  150.  
  151.         If abd.uEdge = CInt(ABEdge.ABE_LEFT) OrElse abd.uEdge = CInt(ABEdge.ABE_RIGHT) Then
  152.             abd.rc.top = 0
  153.             abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height
  154.             If abd.uEdge = CInt(ABEdge.ABE_LEFT) Then
  155.                 abd.rc.left = 0
  156.                 abd.rc.right = Size.Width
  157.             Else
  158.                 abd.rc.right = SystemInformation.PrimaryMonitorSize.Width
  159.                 abd.rc.left = abd.rc.right - Size.Width
  160.  
  161.             End If
  162.         Else
  163.             abd.rc.left = 0
  164.             abd.rc.right = SystemInformation.PrimaryMonitorSize.Width
  165.             If abd.uEdge = CInt(ABEdge.ABE_TOP) Then
  166.                 abd.rc.top = 0
  167.                 abd.rc.bottom = Size.Height
  168.             Else
  169.                 abd.rc.bottom = SystemInformation.PrimaryMonitorSize.Height
  170.                 abd.rc.top = abd.rc.bottom - Size.Height
  171.             End If
  172.         End If
  173.  
  174.         ' Query the system for an approved size and position.
  175.         SHAppBarMessage(CInt(ABMsg.ABM_QUERYPOS), abd)
  176.  
  177.         ' Adjust the rectangle, depending on the edge to which the
  178.         ' appbar is anchored.
  179.         Select Case abd.uEdge
  180.             Case CInt(ABEdge.ABE_LEFT)
  181.                 abd.rc.right = abd.rc.left + Size.Width
  182.                 Exit Select
  183.             Case CInt(ABEdge.ABE_RIGHT)
  184.                 abd.rc.left = abd.rc.right - Size.Width
  185.                 Exit Select
  186.             Case CInt(ABEdge.ABE_TOP)
  187.                 abd.rc.bottom = abd.rc.top + Size.Height
  188.                 Exit Select
  189.             Case CInt(ABEdge.ABE_BOTTOM)
  190.                 abd.rc.top = abd.rc.bottom - Size.Height
  191.                 Exit Select
  192.         End Select
  193.  
  194.         ' Pass the final bounding rectangle to the system.
  195.         SHAppBarMessage(CInt(ABMsg.ABM_SETPOS), abd)
  196.  
  197.         ' Move and size the appbar so that it conforms to the
  198.         ' bounding rectangle passed to the system.
  199.         MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, True)
  200.     End Sub
  201.  
  202.     Protected Overloads Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
  203.         If m.Msg = uCallBack Then
  204.             Select Case m.WParam.ToInt32()
  205.                 Case CInt(ABNotify.ABN_POSCHANGED)
  206.                     ABSetPos()
  207.                     Exit Select
  208.             End Select
  209.         End If
  210.  
  211.         MyBase.WndProc(m)
  212.     End Sub
  213.  
  214.     Protected Overloads Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
  215.         Get
  216.             Dim cp As CreateParams = MyBase.CreateParams
  217.             cp.Style = cp.Style And (Not 12582912)
  218.             ' WS_CAPTION
  219.             cp.Style = cp.Style And (Not 8388608)
  220.             ' WS_BORDER
  221.             cp.ExStyle = 128 Or 8
  222.             ' WS_EX_TOOLWINDOW | WS_EX_TOPMOST
  223.             Return cp
  224.         End Get
  225.     End Property
  226.  
  227. End Class