Option Strict On
Option Explicit On
Public Class Form1
''' <summary>
''' This program was created by David Day to be very simple to use for Window's XP users
''' </summary>
''' <remarks>
''' As of right now the pin to desktop is a little funky
''' That could be fixed by using some API's.
''' </remarks>
Private pt As New Point
Private saved As Boolean = False
Declare Function SetParent Lib "user32.dll" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
#Region "Moves a bordless Form"
Public Const HT_CAPTION As Integer = &H2
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
Private Sub Panel1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
'If saved = False Then
' Dim delta As New Size(e.X - pt.X, e.Y - pt.Y)
' If (e.Button = MouseButtons.Left) Then
' Me.Location += delta : pt = e.Location - delta
' Else
' pt = e.Location
' End If
'End If
If e.Button = Windows.Forms.MouseButtons.Left Then
DirectCast(sender, Control).Capture = False
Me.WndProc(Message.Create(Me.Handle, WM_NCLBUTTONDOWN, CType(HT_CAPTION, IntPtr), IntPtr.Zero))
End If
End Sub
#End Region
#Region "Control Events"
Private Sub lblAdd_Click(sender As Object, e As System.EventArgs) Handles lblAdd.Click
'Adds a new sticky
Dim form As New Form1
form.Show()
form.Focus()
End Sub
Private Sub lblClose_Click(sender As System.Object, e As System.EventArgs) Handles lblClose.Click
'Closes the Form
Me.Close()
End Sub
#End Region
#Region "Context Menustrip"
Private Sub ClearTextToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ClearTextToolStripMenuItem.Click
'Clears Text
txtBox.Text = String.Empty
If txtBox.ReadOnly = True Then
txtBox.ReadOnly = False
End If
End Sub
Private Sub SaveTextToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles SaveTextToolStripMenuItem.Click
'Makes the textbox readonly
txtBox.ReadOnly = True : EditTextToolStripMenuItem.Enabled = True : SaveTextToolStripMenuItem.Enabled = False
End Sub
Private Sub EditTextToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles EditTextToolStripMenuItem.Click
'Makes the textbox editable
txtBox.ReadOnly = False : EditTextToolStripMenuItem.Enabled = False : SaveTextToolStripMenuItem.Enabled = True
End Sub
Private Sub PinToDesktopToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PinToDesktopToolStripMenuItem.Click
'Pins the program
If saved = False Then
saved = True : PinToDesktopToolStripMenuItem.Checked = True : lblClose.Visible = False : Me.ShowInTaskbar = False
SetParent(Me.Handle, FindWindow("ProgMan", Nothing))
Me.SendToBack()
Else
saved = False : PinToDesktopToolStripMenuItem.Checked = False : lblClose.Visible = True : Me.ShowInTaskbar = True
End If
End Sub
#End Region
End Class