tjbradford
Technical User
Hi,
Below is some vb6 code that I would like some advice on, not so much on whats here , more on what its lacking , its a screensaver and works fine on my single head desktop but how would i get it running cross a duel head screen ?
I am seeking expanding the form across two screens or some code to discover the desktop space and set the form accordingly.
I have tried two evenings to google this but not found anything to resolve this.
Many thanks
Option Explicit
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Public X, Y, pics, MyDate, TgtEvent, TgtDate
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Click()
ShowCursor True
End
End Sub
Private Sub Form_DblClick()
ShowCursor True
End
End Sub
Private Sub form_keydown(KeyCode As Integer, Shift As Integer)
Dim blnIsShift As Boolean
blnIsShift = Shift And vbShiftMask
If blnIsShift And (KeyCode = vbKeyF10) Then
ShowCursor True
Else
ShowCursor True
End
End If
End Sub
Private Sub Form_Load()
Text1.Enabled = False
Label2.Visible = False
Dim greenpc
greenpc = Environ("powerdown")
Label3.Visible = False
ShowCursor False
Timer9.Enabled = True
pics = GetSetting(App.EXEName, "Settings", "pics", pics)
If pics = 0 Then
Picture1.Visible = False
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
' Label1.Visible = True
Timer5.Enabled = True
Timer6.Enabled = False
Timer7.Enabled = True
Timer8.Enabled = False
'Change TgtDate to whatever date you want to count down to.
' TgtDate = GetSetting(App.EXEName, "Settings", "date", TgtDate)
' TgtEvent = GetSetting(App.EXEName, "Settings", "event", TgtEvent)
' MyDate = DateDiff("d", Now() + 1, TgtDate)
' Label1 = MyDate & " Days till " & TgtEvent
End If
'If pics = 1 Then
' Label1.Visible = False
' Picture1.Picture = frmItems.Picture4.Picture
' Picture1.Width = 2535
'' Picture1.Height = 2915
'End If
'If pics = 2 Then
' Label1.Visible = False
' Picture1.Picture = frmItems.Picture3.Picture
' Picture1.Width = 4935
' Picture1.Height = 3855
'End If
'If pics = 3 Then
' Label1.Visible = False
' Picture1.Picture = frmItems.Picture2.Picture
' Picture1.Width = 6135
' Picture1.Height = 4695
'End If
'screen/s detection needs to go here i think ?
frmMain.WindowState = vbMaximized
Picture1.Left = Screen.Width / 2 - Picture1.Width / 2
Picture1.Top = Screen.Height / 2 - Picture1.Height / 2
Y = 3
X = 3
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = True
Timer4.Enabled = False
End Sub
Private Sub Picture1_Click()
ShowCursor True
End
End Sub
Private Sub Text1_Change()
ShowCursor True
End
End Sub
Private Sub Timer5_Timer()
If Label1.Left > 1 Then
Label1.Left = Label1.Left - Y
Else
Timer5.Enabled = False
Timer6.Enabled = True
End If
End Sub
Private Sub Timer6_Timer()
If Label1.Left < Screen.Width - Label1.Width Then
Label1.Left = Label1.Left + Y
Else
Timer5.Enabled = True
Timer6.Enabled = False
End If
End Sub
Private Sub Timer7_Timer()
If Label1.Top > 1 Then
Label1.Top = Label1.Top - X
Else
Timer7.Enabled = False
Timer8.Enabled = True
End If
End Sub
Private Sub Timer8_Timer()
If Label1.Top < Screen.Height - Label1.Height Then
Label1.Top = Label1.Top + X
Else
Timer7.Enabled = True
Timer8.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
If Picture1.Left > 1 Then
Picture1.Left = Picture1.Left - Y
Else
Timer1.Enabled = False
Timer2.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
If Picture1.Left < Screen.Width - Picture1.Width Then
Picture1.Left = Picture1.Left + Y
Else
Timer1.Enabled = True
Timer2.Enabled = False
End If
End Sub
Private Sub Timer3_Timer()
If Picture1.Top > 1 Then
Picture1.Top = Picture1.Top - X
Else
Timer3.Enabled = False
Timer4.Enabled = True
End If
End Sub
Private Sub Timer4_Timer()
If Picture1.Top < Screen.Height - Picture1.Height Then
Picture1.Top = Picture1.Top + X
Else
Timer3.Enabled = True
Timer4.Enabled = False
End If
End Sub
'Private Sub Hook1_Active()
' List1.AddItem "User is Active again"
' Form2.Visible = False
'End Sub
'Private Sub Hook1_Idle()
' List1.AddItem "User Idle"
'End Sub
Private Sub Timer9_Timer()
Static i As Integer
i = i + 1
Label2.Caption = (i)
'If i = 3 Then 'Timer9.Enabled = False
''MsgBox "done"
'Else
'End If
Dim greenpc, greenpccheck
greenpccheck = Environ("powerdown")
If greenpccheck = "" Then
greenpc = 11
Else
greenpc = greenpccheck
End If
If frmMain.Label2.Caption = greenpc Then
Shell "calc.exe", vbNormalFocus
'MsgBox "bye bye"
Else
'
End If
End Sub
Below is some vb6 code that I would like some advice on, not so much on whats here , more on what its lacking , its a screensaver and works fine on my single head desktop but how would i get it running cross a duel head screen ?
I am seeking expanding the form across two screens or some code to discover the desktop space and set the form accordingly.
I have tried two evenings to google this but not found anything to resolve this.
Many thanks
Option Explicit
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Public X, Y, pics, MyDate, TgtEvent, TgtDate
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Click()
ShowCursor True
End
End Sub
Private Sub Form_DblClick()
ShowCursor True
End
End Sub
Private Sub form_keydown(KeyCode As Integer, Shift As Integer)
Dim blnIsShift As Boolean
blnIsShift = Shift And vbShiftMask
If blnIsShift And (KeyCode = vbKeyF10) Then
ShowCursor True
Else
ShowCursor True
End
End If
End Sub
Private Sub Form_Load()
Text1.Enabled = False
Label2.Visible = False
Dim greenpc
greenpc = Environ("powerdown")
Label3.Visible = False
ShowCursor False
Timer9.Enabled = True
pics = GetSetting(App.EXEName, "Settings", "pics", pics)
If pics = 0 Then
Picture1.Visible = False
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
Timer4.Enabled = False
' Label1.Visible = True
Timer5.Enabled = True
Timer6.Enabled = False
Timer7.Enabled = True
Timer8.Enabled = False
'Change TgtDate to whatever date you want to count down to.
' TgtDate = GetSetting(App.EXEName, "Settings", "date", TgtDate)
' TgtEvent = GetSetting(App.EXEName, "Settings", "event", TgtEvent)
' MyDate = DateDiff("d", Now() + 1, TgtDate)
' Label1 = MyDate & " Days till " & TgtEvent
End If
'If pics = 1 Then
' Label1.Visible = False
' Picture1.Picture = frmItems.Picture4.Picture
' Picture1.Width = 2535
'' Picture1.Height = 2915
'End If
'If pics = 2 Then
' Label1.Visible = False
' Picture1.Picture = frmItems.Picture3.Picture
' Picture1.Width = 4935
' Picture1.Height = 3855
'End If
'If pics = 3 Then
' Label1.Visible = False
' Picture1.Picture = frmItems.Picture2.Picture
' Picture1.Width = 6135
' Picture1.Height = 4695
'End If
'screen/s detection needs to go here i think ?
frmMain.WindowState = vbMaximized
Picture1.Left = Screen.Width / 2 - Picture1.Width / 2
Picture1.Top = Screen.Height / 2 - Picture1.Height / 2
Y = 3
X = 3
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = True
Timer4.Enabled = False
End Sub
Private Sub Picture1_Click()
ShowCursor True
End
End Sub
Private Sub Text1_Change()
ShowCursor True
End
End Sub
Private Sub Timer5_Timer()
If Label1.Left > 1 Then
Label1.Left = Label1.Left - Y
Else
Timer5.Enabled = False
Timer6.Enabled = True
End If
End Sub
Private Sub Timer6_Timer()
If Label1.Left < Screen.Width - Label1.Width Then
Label1.Left = Label1.Left + Y
Else
Timer5.Enabled = True
Timer6.Enabled = False
End If
End Sub
Private Sub Timer7_Timer()
If Label1.Top > 1 Then
Label1.Top = Label1.Top - X
Else
Timer7.Enabled = False
Timer8.Enabled = True
End If
End Sub
Private Sub Timer8_Timer()
If Label1.Top < Screen.Height - Label1.Height Then
Label1.Top = Label1.Top + X
Else
Timer7.Enabled = True
Timer8.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
If Picture1.Left > 1 Then
Picture1.Left = Picture1.Left - Y
Else
Timer1.Enabled = False
Timer2.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
If Picture1.Left < Screen.Width - Picture1.Width Then
Picture1.Left = Picture1.Left + Y
Else
Timer1.Enabled = True
Timer2.Enabled = False
End If
End Sub
Private Sub Timer3_Timer()
If Picture1.Top > 1 Then
Picture1.Top = Picture1.Top - X
Else
Timer3.Enabled = False
Timer4.Enabled = True
End If
End Sub
Private Sub Timer4_Timer()
If Picture1.Top < Screen.Height - Picture1.Height Then
Picture1.Top = Picture1.Top + X
Else
Timer3.Enabled = True
Timer4.Enabled = False
End If
End Sub
'Private Sub Hook1_Active()
' List1.AddItem "User is Active again"
' Form2.Visible = False
'End Sub
'Private Sub Hook1_Idle()
' List1.AddItem "User Idle"
'End Sub
Private Sub Timer9_Timer()
Static i As Integer
i = i + 1
Label2.Caption = (i)
'If i = 3 Then 'Timer9.Enabled = False
''MsgBox "done"
'Else
'End If
Dim greenpc, greenpccheck
greenpccheck = Environ("powerdown")
If greenpccheck = "" Then
greenpc = 11
Else
greenpc = greenpccheck
End If
If frmMain.Label2.Caption = greenpc Then
Shell "calc.exe", vbNormalFocus
'MsgBox "bye bye"
Else
'
End If
End Sub