Friday, August 12, 2011

CHANGING VISTA BACKGROUNG IMAGE LIKE XP (VB.NET)

I have always wanted my Vista desktop background images to change just as it is in XP, so I had to make a program for that purpose. Below is the program I made for this purpose.
Emmm...this code is really self-explained because there is no indepth programming done here, so no much comment.... :D. That was not an excuse lol

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
main form
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



Imports
System.IOImports System.Windows.Forms.FormPublic
Class frmMainInherits System.Windows.Forms.Form#Region "Windows Form Generated Codes"

InitializeComponent()

Public Sub New()MyBase.New()End Sub'Form overrides dispose to clean up the component list.<System.Diagnostics.DebuggerNonUserCode()> _

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)TryIf disposing AndAlso components IsNot Nothing Thencomponents.Dispose()
End IfFinally
MyBase.Dispose(disposing)End TryEnd Sub

Friend WithEvents NtiHidding As System.Windows.Forms.NotifyIconFriend WithEvents btnSettings As System.Windows.Forms.Button'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer'NOTE: The following procedure is required by the Windows Form Designer'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.<System.Diagnostics.DebuggerStepThrough()> _
















Private Sub InitializeComponent()Me.components = New System.ComponentModel.ContainerDim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))Me.panMain = New System.Windows.Forms.PanelMe.lblMainName = New System.Windows.Forms.LabelMe.lblHide = New System.Windows.Forms.LabelMe.lblClose = New System.Windows.Forms.LabelMe.btnPlayStop = New System.Windows.Forms.ButtonMe.btnBrowse = New System.Windows.Forms.ButtonMe.TimerPlay = New System.Windows.Forms.Timer(Me.components)Me.NtiHidding = New System.Windows.Forms.NotifyIcon(Me.components)Me.btnSettings = New System.Windows.Forms.ButtonMe.btnNxt = New System.Windows.Forms.ButtonMe.btnPrv = New System.Windows.Forms.ButtonMe.panMain.SuspendLayout()Me.SuspendLayout()''panMain'





Me.panMain.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingleMe.panMain.Controls.Add(Me.lblMainName)Me.panMain.Controls.Add(Me.lblHide)Me.panMain.Controls.Add(Me.lblClose)Me.panMain.Dock = System.Windows.Forms.DockStyle.TopMe.panMain.Location = New System.Drawing.Point(0, 0)Me.panMain.Name = "panMain"

Me.panMain.Size = New System.Drawing.Size(166, 19)Me.panMain.TabIndex = 0''lblMainName'

Me.lblMainName.Dock = System.Windows.Forms.DockStyle.FillMe.lblMainName.Location = New System.Drawing.Point(0, 0)Me.lblMainName.Name = "lblMainName"

Me.lblMainName.Size = New System.Drawing.Size(126, 17)Me.lblMainName.TabIndex = 2Me.lblMainName.Text = "Blue_Dreams"
Me.lblMainName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft''lblHide'


Me.lblHide.Dock = System.Windows.Forms.DockStyle.RightMe.lblHide.ForeColor = System.Drawing.Color.WhiteMe.lblHide.Location = New System.Drawing.Point(126, 0)Me.lblHide.Name = "lblHide"

Me.lblHide.Size = New System.Drawing.Size(19, 17)Me.lblHide.TabIndex = 1Me.lblHide.Text = "_"
Me.lblHide.TextAlign = System.Drawing.ContentAlignment.MiddleCenter''lblClose'


Me.lblClose.Dock = System.Windows.Forms.DockStyle.RightMe.lblClose.ForeColor = System.Drawing.Color.RedMe.lblClose.Location = New System.Drawing.Point(145, 0)Me.lblClose.Name = "lblClose"

Me.lblClose.Size = New System.Drawing.Size(19, 17)Me.lblClose.TabIndex = 0Me.lblClose.Text = "x"
Me.lblClose.TextAlign = System.Drawing.ContentAlignment.MiddleCenter''btnPlayStop'


Me.btnPlayStop.BackgroundImage = Global.BlueDreams.My.Resources.Resources.player_playMe.btnPlayStop.BackgroundImageLayout = System.Windows.Forms.ImageLayout.ZoomMe.btnPlayStop.Location = New System.Drawing.Point(28, 21)Me.btnPlayStop.Name = "btnPlayStop"

Me.btnPlayStop.Size = New System.Drawing.Size(27, 23)Me.btnPlayStop.TabIndex = 2Me.btnPlayStop.UseVisualStyleBackColor = True''btnBrowse'
Me.btnBrowse.Location = New System.Drawing.Point(84, 21)Me.btnBrowse.Name = "btnBrowse"

Me.btnBrowse.Size = New System.Drawing.Size(53, 23)Me.btnBrowse.TabIndex = 4Me.btnBrowse.Text = "..."Me.btnBrowse.UseVisualStyleBackColor = True''TimerPlay'
Me.TimerPlay.Interval = 10''NtiHidding'
Me.NtiHidding.Icon = CType(resources.GetObject("NtiHidding.Icon"), System.Drawing.Icon)Me.NtiHidding.Text = "Blue Dreams"Me.NtiHidding.Visible = True''btnSettings'


Me.btnSettings.BackgroundImage = Global.BlueDreams.My.Resources.Resources.settingMe.btnSettings.BackgroundImageLayout = System.Windows.Forms.ImageLayout.ZoomMe.btnSettings.Location = New System.Drawing.Point(139, 21)Me.btnSettings.Name = "btnSettings"

Me.btnSettings.Size = New System.Drawing.Size(27, 23)Me.btnSettings.TabIndex = 5Me.btnSettings.UseVisualStyleBackColor = True''btnNxt'


Me.btnNxt.BackgroundImage = Global.BlueDreams.My.Resources.Resources._nextMe.btnNxt.BackgroundImageLayout = System.Windows.Forms.ImageLayout.ZoomMe.btnNxt.Location = New System.Drawing.Point(56, 21)Me.btnNxt.Name = "btnNxt"

Me.btnNxt.Size = New System.Drawing.Size(27, 23)Me.btnNxt.TabIndex = 3Me.btnNxt.UseVisualStyleBackColor = True''btnPrv'


Me.btnPrv.BackgroundImage = Global.BlueDreams.My.Resources.Resources.previousMe.btnPrv.BackgroundImageLayout = System.Windows.Forms.ImageLayout.ZoomMe.btnPrv.Location = New System.Drawing.Point(1, 21)Me.btnPrv.Name = "btnPrv"

Me.btnPrv.Size = New System.Drawing.Size(27, 23)Me.btnPrv.TabIndex = 1Me.btnPrv.UseVisualStyleBackColor = True''frmMain'










Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.FontMe.BackColor = System.Drawing.Color.BlueMe.ClientSize = New System.Drawing.Size(166, 47)Me.Controls.Add(Me.btnSettings)Me.Controls.Add(Me.btnBrowse)Me.Controls.Add(Me.btnNxt)Me.Controls.Add(Me.btnPlayStop)Me.Controls.Add(Me.btnPrv)Me.Controls.Add(Me.panMain)Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)Me.Name = "frmMain"Me.Text = "BlueDreams"

Me.panMain.ResumeLayout(False)Me.ResumeLayout(False)End Sub









Friend WithEvents panMain As System.Windows.Forms.PanelFriend WithEvents lblMainName As System.Windows.Forms.LabelFriend WithEvents lblHide As System.Windows.Forms.LabelFriend WithEvents lblClose As System.Windows.Forms.LabelFriend WithEvents btnPrv As System.Windows.Forms.ButtonFriend WithEvents btnPlayStop As System.Windows.Forms.ButtonFriend WithEvents btnNxt As System.Windows.Forms.ButtonFriend WithEvents btnBrowse As System.Windows.Forms.ButtonFriend WithEvents TimerPlay As System.Windows.Forms.Timer#End Region'+++++++++++++++++++'PRIVATES'+++++++++++++++++++Private strImages(1000) As StringPrivate intCounting As Integer 'for couting in the arrayPrivate intLoadingImg As Integer 'for loading the imagePrivate intMonitoring As Integer 'for checking image loadin countsPrivate isPlaying As Boolean 'check wether the wallpapar is playing'Import all the classesPrivate CheckApp As New fCheckIfAppIsRunning 'use the checkApp classPrivate NewfMouseAction As fMouseAction 'use the drag class'Change wallpapars

Private Const SPI_SETDESKWALLPAPER As Integer = 20Private Const SPIF_UPDATEINIFILE As Integer = 1Private strFileName As String





Private NewDire As DirectoryInfoPrivate Declare Function SystemParametersInfo Lib "user32" Alias _"SystemParametersInfoA" (ByVal uAction As Integer, ByVal uParam _As Integer, ByVal lpvParam As String, _ByVal fuWinIni As Integer) As Integer
Public Sub LoadImages()'loads from the default directoryIf NewDire Is Nothing ThenNewDire =
New DirectoryInfo(My.Settings.DefaultDire)End If
intCounting += 1
strImages(intCounting) = Images.ToString
For Each Images As FileInfo In NewDire.GetFiles("*.png")On Error Resume NextNext
intCounting += 1
strImages(intCounting) = Images.ToString
For Each Images As FileInfo In NewDire.GetFiles("*.jpg")On Error Resume NextNext
intCounting += 1
strImages(intCounting) = Images.ToString
For Each Images As FileInfo In NewDire.GetFiles("*.jpeg")On Error Resume NextNext
intCounting += 1
strImages(intCounting) = Images.ToString
For Each Images As FileInfo In NewDire.GetFiles("*.ico")On Error Resume NextNext
intCounting += 1
strImages(intCounting) = Images.ToString
For Each Images As FileInfo In NewDire.GetFiles("*.jif")On Error Resume NextNext
intCounting += 1
strImages(intCounting) = Images.ToString
For Each Images As FileInfo In NewDire.GetFiles("*.mpg")On Error Resume NextNext
intCounting += 1
strImages(intCounting) = Images.ToString
For Each Images As FileInfo In NewDire.GetFiles("*.tif")On Error Resume NextNext
Me.TimerPlay.Start()End Sub
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosingTryMe.NtiHidding.Visible = False


Me.TimerPlay.Stop()My.Settings.Save()Catch ex As ExceptionEnd TryEnd Sub
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load'Check if application is runningCheckApp.IsAppRunning()
Try
Select Case My.Settings.AskLocCase "Ask"
Dim od As New FolderBrowserDialogIf od.ShowDialog = DialogResult.OK ThenNewDire =
LoadImages()
New DirectoryInfo(od.SelectedPath)Me.btnPlayStop.BackgroundImage = Nothing
isPlaying =
Me.btnPlayStop.BackgroundImage = My.Resources._stopTrue
End IfCase "Default" : Case ElseNewDire =
LoadImages()


New DirectoryInfo(My.Settings.DefaultDire.ToString)Me.TimerPlay.Start()My.Settings.Reload()Me.btnPlayStop.BackgroundImage = Nothing
isPlaying =
Me.btnPlayStop.BackgroundImage = My.Resources._stopTrueEnd Select
Catch ex As ExceptionEnd TryTryNewfMouseAction =
New fMouseAction(Me, lblMainName, lblHide)Me.NtiHidding.Visible = True

Catch ex As ExceptionEnd TryTry



Me.FormBorderStyle = Windows.Forms.FormBorderStyle.NoneMe.Location = New Point(My.Computer.Screen.Bounds.Width - Me.Width - 10, _My.Computer.Screen.Bounds.Height - 70)Catch ex As ExceptionEnd TryEnd Sub'Timer to play the background images
Private Sub TimerPlay_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerPlay.TickTryintMonitoring += 1
isPlaying =
True
Me.btnPlayStop.BackgroundImage = My.Resources._stopIf intMonitoring >= My.Settings.Delay ThenintLoadingImg += 1
SystemParametersInfo(20, 0, NewDire.ToString &
intMonitoring = 0
"\" & strImages(intLoadingImg).ToString, 1)If intLoadingImg = intCounting ThenintLoadingImg = 0
End IfEnd If
isPlaying =
Catch ex As ExceptionTrueintLoadingImg = 0
End TryEnd Sub'Button to play or stop the background images
Private Sub btnPlayStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlayStop.ClickTryIf NewDire Is Nothing Then

Dim msger = MessageBox.Show("Directory is empty." & vbNewLine & "Load new directory.", _"Blue Dreams", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)If msger = Windows.Forms.DialogResult.OK Then
Call btnBrowse_Click(sender, e)Exit SubEnd IfEnd If'PlayIf (isPlaying = False) ThenMe.btnPlayStop.BackgroundImage = Nothing

intCounting = 0
Me.btnPlayStop.BackgroundImage = My.Resources._stopMe.TimerPlay.Start()'StopElseIf (isPlaying = True) ThenMe.btnPlayStop.BackgroundImage = Nothing

isPlaying =
Me.btnPlayStop.BackgroundImage = My.Resources.player_playMe.TimerPlay.Stop()FalseEnd If
Catch ex As ExceptionEnd TryEnd Sub'Load directory for images
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.ClickTry
intCounting = 0

Me.TimerPlay.Stop()Dim od As New FolderBrowserDialogIf od.ShowDialog = DialogResult.OK ThenNewDire =
LoadImages()
New DirectoryInfo(od.SelectedPath)End If
Catch ex As ExceptionEnd TryEnd Sub'Close the app

intCounting = 0
Application.Exit()
Private Sub lblClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblClose.ClickMe.TimerPlay.Stop()End Sub'View previous image
Private Sub btnPrv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrv.ClickTryintLoadingImg -= 1
SystemParametersInfo(20, 0, NewDire.ToString &

"\" & strImages(intLoadingImg).ToString, 1)Catch ex As ExceptionEnd TryEnd Sub'View next image
Private Sub btnNxt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNxt.ClickTryintLoadingImg += 1
SystemParametersInfo(20, 0, NewDire.ToString &

"\" & strImages(intLoadingImg).ToString, 1)Catch ex As ExceptionEnd TryEnd Sub
Private Sub NtiHidding_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NtiHidding.MouseDoubleClickMe.NtiHidding.Visible = False
Me.Show()Me.NtiHidding.Visible = TrueEnd Sub
Private Sub btnSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSettings.ClickTry

My.Forms.frmSettings.Show()Catch ex As ExceptionEnd Try
End

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Settings form
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Imports System.Windows.Forms.FormPublic
Class frmSettingsInherits Windows.Forms.Form#Region "Windows Form Generated Codes"

InitializeComponent()
Public Sub New()MyBase.New()End Sub'Form overrides dispose to clean up the component list.<System.Diagnostics.DebuggerNonUserCode()> _

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)TryIf disposing AndAlso components IsNot Nothing Thencomponents.Dispose()
End IfFinally
MyBase.Dispose(disposing)End TryEnd Sub
Friend WithEvents lblName As System.Windows.Forms.Label'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer'NOTE: The following procedure is required by the Windows Form Designer'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor.<System.Diagnostics.DebuggerStepThrough()> _














Private Sub InitializeComponent()Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmSettings))Me.gbxMain = New System.Windows.Forms.GroupBoxMe.btnBrowse = New System.Windows.Forms.ButtonMe.cbx2 = New System.Windows.Forms.CheckBoxMe.cbx1 = New System.Windows.Forms.CheckBoxMe.nupNum = New System.Windows.Forms.NumericUpDownMe.lblNum = New System.Windows.Forms.LabelMe.btnDone = New System.Windows.Forms.ButtonMe.lblSetting = New System.Windows.Forms.LabelMe.lblName = New System.Windows.Forms.LabelMe.gbxMain.SuspendLayout()CType(Me.nupNum, System.ComponentModel.ISupportInitialize).BeginInit()Me.SuspendLayout()''gbxMain'





Me.gbxMain.Controls.Add(Me.btnBrowse)Me.gbxMain.Controls.Add(Me.cbx2)Me.gbxMain.Controls.Add(Me.cbx1)Me.gbxMain.Controls.Add(Me.nupNum)Me.gbxMain.Controls.Add(Me.lblNum)Me.gbxMain.Location = New System.Drawing.Point(13, 41)Me.gbxMain.Name = "gbxMain"

Me.gbxMain.Size = New System.Drawing.Size(331, 146)Me.gbxMain.TabIndex = 0Me.gbxMain.TabStop = False''btnBrowse'
Me.btnBrowse.Location = New System.Drawing.Point(292, 63)Me.btnBrowse.Name = "btnBrowse"

Me.btnBrowse.Size = New System.Drawing.Size(33, 23)Me.btnBrowse.TabIndex = 4Me.btnBrowse.Text = "..."Me.btnBrowse.UseVisualStyleBackColor = True''cbx2'Me.cbx2.AutoSize = True
Me.cbx2.Location = New System.Drawing.Point(156, 67)Me.cbx2.Name = "cbx2"

Me.cbx2.Size = New System.Drawing.Size(136, 17)Me.cbx2.TabIndex = 3Me.cbx2.Text = "Use my default location"Me.cbx2.UseVisualStyleBackColor = True''cbx1'Me.cbx1.AutoSize = True
Me.cbx1.Location = New System.Drawing.Point(9, 67)Me.cbx1.Name = "cbx1"

Me.cbx1.Size = New System.Drawing.Size(151, 17)Me.cbx1.TabIndex = 2Me.cbx1.Text = "Always ask me for location"Me.cbx1.UseVisualStyleBackColor = True''nupNum'



Me.nupNum.Increment = New Decimal(New Integer() {5, 0, 0, 0})Me.nupNum.Location = New System.Drawing.Point(84, 22)Me.nupNum.Maximum = New Decimal(New Integer() {500, 0, 0, 0})Me.nupNum.Minimum = New Decimal(New Integer() {50, 0, 0, 0})Me.nupNum.Name = "nupNum"


Me.nupNum.Size = New System.Drawing.Size(75, 20)Me.nupNum.TabIndex = 1Me.nupNum.Value = New Decimal(New Integer() {50, 0, 0, 0})''lblNum'Me.lblNum.AutoSize = True
Me.lblNum.Location = New System.Drawing.Point(6, 27)Me.lblNum.Name = "lblNum"

Me.lblNum.Size = New System.Drawing.Size(72, 13)Me.lblNum.TabIndex = 0Me.lblNum.Text = "Switch Delay:"''btnDone'
Me.btnDone.Location = New System.Drawing.Point(269, 193)Me.btnDone.Name = "btnDone"

Me.btnDone.Size = New System.Drawing.Size(75, 23)Me.btnDone.TabIndex = 1Me.btnDone.Text = "Done"Me.btnDone.UseVisualStyleBackColor = True''lblSetting'Me.lblSetting.AutoSize = True
Me.lblSetting.Location = New System.Drawing.Point(16, 25)Me.lblSetting.Name = "lblSetting"

Me.lblSetting.Size = New System.Drawing.Size(45, 13)Me.lblSetting.TabIndex = 2Me.lblSetting.Text = "Settings"''lblName'

Me.lblName.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))Me.lblName.Location = New System.Drawing.Point(16, 190)Me.lblName.Name = "lblName"

Me.lblName.Size = New System.Drawing.Size(226, 31)Me.lblName.TabIndex = 3Me.lblName.Text = "Kalagbor Aleruchi Victor (June 2011) Mailingvictor@gmail.com"
Me.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter''frmSettings'









Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.FontMe.BackColor = System.Drawing.Color.BlueMe.ClientSize = New System.Drawing.Size(356, 230)Me.Controls.Add(Me.lblName)Me.Controls.Add(Me.lblSetting)Me.Controls.Add(Me.btnDone)Me.Controls.Add(Me.gbxMain)Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingleMe.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)Me.MaximizeBox = FalseMe.MinimizeBox = FalseMe.Name = "frmSettings"Me.Text = "Blue Dreams - Settings"




Me.gbxMain.ResumeLayout(False)Me.gbxMain.PerformLayout()CType(Me.nupNum, System.ComponentModel.ISupportInitialize).EndInit()Me.ResumeLayout(False)Me.PerformLayout()End Sub






Friend WithEvents gbxMain As System.Windows.Forms.GroupBoxFriend WithEvents cbx1 As System.Windows.Forms.CheckBoxFriend WithEvents nupNum As System.Windows.Forms.NumericUpDownFriend WithEvents lblNum As System.Windows.Forms.LabelFriend WithEvents btnDone As System.Windows.Forms.ButtonFriend WithEvents lblSetting As System.Windows.Forms.LabelFriend WithEvents btnBrowse As System.Windows.Forms.ButtonFriend WithEvents cbx2 As System.Windows.Forms.CheckBox#End Region'Form load event to load all the saved settings
Private Sub frmSettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadTry
Me.nupNum.Value = My.Settings.DelayIf My.Settings.AskLoc = "Ask" ThenMe.cbx1.Checked = TrueMe.cbx2.Checked = FalseElseMe.cbx2.Checked = TrueMe.cbx1.Checked = FalseEnd If
Catch ex As ExceptionEnd TryEnd Sub'Get the value of the delay count for the timer
Private Sub nupNum_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nupNum.ValueChangedTryMy.Settings.Delay = Nothing


My.Settings.Delay = Me.nupNum.ValueMy.Settings.Save()Catch ex As ExceptionEnd TryEnd Sub'Get the new directory locationg for loading the images
Private Sub cbx1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbx1.CheckedChangedTryMy.Settings.AskLoc = NothingMy.Settings.AskLoc = "Ask"

My.Settings.Save()Catch ex As ExceptionEnd TryEnd Sub'Use the defult directory to load images
Private Sub cbx2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbx2.CheckedChangedTryMy.Settings.AskLoc = NothingMy.Settings.AskLoc = "Default"

My.Settings.Save()Catch ex As ExceptionEnd TryEnd Sub'Close the form
Private Sub btnDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDone.ClickTryIf My.Settings.DefaultDire = Nothing Then
MessageBoxButtons.OK, MessageBoxIcon.Information)
Dim msger = MessageBox.Show("No directory has been choosen", "Blue Dreams", _ElseIf My.Settings.DefaultDire <> Nothing Then
My.Forms.frmMain.LoadImages()End If

Me.Close()Catch ex As ExceptionEnd TryEnd Sub'Browse for new directory
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.ClickTry
Dim OpenImg As New FolderBrowserDialogIf OpenImg.ShowDialog = Windows.Forms.DialogResult.OK ThenMy.Settings.DefaultDire = Nothing

My.Settings.DefaultDire = OpenImg.SelectedPath.ToStringMy.Settings.Save()End If
Catch ex As ExceptionEnd TryEnd SubEnd Class

++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The classess
Class1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Public


Class fCheckIfAppIsRunningPublic Sub IsAppRunning()Try'Check if application is already runningIf Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).GetUpperBound(0) > 0 Then'Inform and end if there is an error

MessageBoxIcon.Information)
Dim msger = MessageBox.Show("BlueDream is already running", _"BlueDreams", MessageBoxButtons.OK, _If msger = Windows.Forms.DialogResult.OK ThenApplication.Exit()
End IfEnd IfCatch'Inform and end if there is an error

Dim msger = MessageBox.Show("There was an error loading BlueDreams", _"BlueDreams", MessageBoxButtons.OK, MessageBoxIcon.Error)If msger = Windows.Forms.DialogResult.OK ThenApplication.Exit()
End IfEnd Try
End

+++++++++++++++
class2
+++++++++++++++
Public
Class fMouseAction'Private NewfMouseAction As fMouseActionPrivate IsMouseDown As BooleanPrivate xLoc As DoublePrivate yLoc As Double






lblMainName = lblMName
lblMini = lblMin
Main = IMain

Private WithEvents lblMainName As LabelPrivate WithEvents lblMini As ControlPrivate Main As FormPublic Sub New(ByVal IMain As Form, _ByVal lblMName As Label, _ByVal lblMin As Control)End Sub
frmMain.NtiHidding.Visible =
Private Sub lblMini_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblMini.ClickFalsefrmMain.Hide()
frmMain.NtiHidding.Visible =
TruefrmMain.NtiHidding.Visible = TrueEnd Sub'++++++++++++++++++++++++++++++++++++++'Mouse Action'++++++++++++++++++++++++++++++++++++++
IsMouseDown =
Private Sub lblMainName_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblMainName.MouseDownTruexLoc = Control.MousePosition.X - Main.Left
yLoc = Control.MousePosition.Y - Main.Top

End Sub
Private Sub lblMainName_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblMainName.MouseMoveIf Main.WindowState = FormWindowState.Normal ThenIf IsMouseDown = True ThenMain.Left = Control.MousePosition.X - xLoc
Main.Top = Control.MousePosition.Y - yLoc
'Make it transparentMain.Opacity = 0.7
End IfEnd IfEnd Sub
IsMouseDown =
Private Sub lblMainName_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblMainName.MouseUpFalseIf IsMouseDown = False ThenMain.Opacity = 1
Main.Refresh()
End If
End

++++++++++++++++++++++++++++++++++++++++++++++++++++++
Check out this cool vid on youtube
Enjoy :D
++++++++++++++++++++++++++++++++++++++++++++++++++++++
End Sub Class
End Sub Class
End Sub Class

No comments:

Post a Comment