|
-
September 15th, 2008, 12:49 AM
#1
Background Switcher
So i currently have this background switcher that works. Thing is, what's supposed to center it in the screen actually tiles it and i don't know why. Ultimately, i'd like to be able to have a separate picture for each monitor, but that's not really necessary. So my question is two fold: One, why doesn't the line indicated below center the background and what should I do instead and two, how do i go about even starting to have two separate pictures, one for each monitor, at the same time with each centered based on the monitor their on. This is important because I have two monitors that are different sizes and something centered in a 1440x900 resolution won't be centered correctly in a 1024x768 resolution.
Code:
Public Class settings
Public 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
Dim Pics As New List(Of String)
Private Sub settings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TimeUnit.SelectedIndex = 1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TFPath As String
FolderBrowserDialog1.ShowDialog()
TFPath = FolderBrowserDialog1.SelectedPath
Try
Dim DInfo As System.IO.DirectoryInfo = System.IO.Directory.GetParent(TFPath)
Dim ER As String = DInfo.Name
Change_Wallpaper(ER)
Catch ex As Exception
If System.IO.Directory.Exists(TFPath) = True Then
Change_Wallpaper(TFPath)
Else
MsgBox("Error: Directory " & TFPath & " doesn't exist!", MsgBoxStyle.Critical, "Error")
End If
End Try
End Sub
Private Sub Change_Wallpaper(ByVal Path As String)
Dim TStor As String()
TStor = System.IO.Directory.GetFiles(Path, "*.*")
For Each hold As String In TStor
Pics.Add(hold)
Next
Pics.Sort()
Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Control_ Panel\Desktop", "WallpaperStyle", 3, Microsoft.Win32.RegistryValueKind.String)
My.Settings.WeAreOn = 1
SystemParametersInfo(20, 3, Pics(0), &H1)
End Sub
Private Sub Next_wallpaper()
If My.Settings.WeAreOn >= Pics.Count Then
My.Settings.WeAreOn = 0
SystemParametersInfo(20, 0, Pics(My.Settings.WeAreOn), &H1)
Else
SystemParametersInfo(20, 0, Pics(My.Settings.WeAreOn), &H1)
End If
My.Settings.WeAreOn += 1
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Pics.Count <> 0 Then
Next_wallpaper()
End If
End Sub
Private Sub TimeUnit_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimeUnit.SelectedIndexChanged
Dim FinalTime As Integer = 0
If TimeUnit.SelectedItem = "Minutes" Then
FinalTime = (60 * TimeInt.Text) * 1000
Timer1.Stop()
Timer1.Interval = FinalTime
Timer1.Start()
ElseIf TimeUnit.SelectedItem = "Seconds" Then
FinalTime = TimeInt.Text * 1000
Timer1.Stop()
Timer1.Interval = FinalTime
Timer1.Start()
ElseIf TimeUnit.SelectedItem = "Hours" Then
FinalTime = ((60 * 60) * TimeInt.Text) * 1000
Timer1.Stop()
Timer1.Interval = FinalTime
Timer1.Start()
End If
End Sub
Private Sub TimeInt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimeInt.TextChanged
Dim FinalTime As Integer = 0
If TimeUnit.SelectedItem = "Minutes" Then
FinalTime = (60 * TimeInt.Text) * 1000
Timer1.Stop()
Timer1.Interval = FinalTime
Timer1.Start()
ElseIf TimeUnit.SelectedItem = "Seconds" Then
FinalTime = TimeInt.Text * 1000
Timer1.Stop()
Timer1.Interval = FinalTime
Timer1.Start()
ElseIf TimeUnit.SelectedItem = "Hours" Then
FinalTime = ((60 * 60) * TimeInt.Text) * 1000
Timer1.Stop()
Timer1.Interval = FinalTime
Timer1.Start()
End If
End Sub
End Class
This line was what I hacked together for center:
Code:
Microsoft.Win32.Registry.SetValue("HKEY_CURRENT_USER\Control_ Panel\Desktop", "WallpaperStyle", 3, Microsoft.Win32.RegistryValueKind.String)
Microsoft Visual Basic 2008 Express Edition
.NET Framwork 3.5 Beta SP1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|