Hej
Jeg er begynder (I Visual Basic 6) og forsøger at lave en screensaver i stil med den der er i XP.
Jeg har stjålet lidt kode fra lignende projekter som jeg ikke er inde i, men øvelse gør jo mester som man siger.
Anyway, de problemer jeg har er:
- "nMouseCount > 10" får programmet til at afslutte alt efter hvad jeg sætter > til
- Når jeg bruger "ShowCursor False" bliver markøren skjult når jeg vender tilbage til VB
- Afsnittet "CheckCommandLine" virker ikke. Når jeg klikker på screensaver under skærmindstillingerne starter screensaveren og igen når jeg siger "anvend"
//MadsRH
Min kode ser sådan ud:
' Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Dim nMouseCount As Integer
Dim sCmdLine As String
Sub CheckCommandLine()
' this section isn't working.
Dim sCmdLine As String
sCmdLine = Trim$(LCase$(Command$))
'RUNNING AS A SCREEN SAVER
If sCmdLine = "/s" Or sCmdLine = "" Then
Exit Sub
End If
'RUNNING IN SETUP (CONFIG) MODE
If sCmdLine = "/c" Then
MsgBox "Config Screen Not Available"
End
End If
'RUNNING IN PREVIEW MODE
If Left$(sCmdLine, 2) = "/p" Then
'parameter can be retrieved with Val(Mid$(sCmdLine,3))
End
End If
End Sub
Private Sub Form_Click()
' When I return to VB the cursor is hidden
ShowCursor True
Unload Me
End
End Sub
Private Sub Form_Load()
Call SetWindowPos(Screensaver.hwnd, HWND_TOPMOST, 0&, 0&, 0, 0, SWP_NOSIZE)
' should hide the mouse but I can't make it show again
' ShowCursor True
Label1.BackColor = black
Label1.Caption = "1"
Dim cx As Long
Dim cy As Long
Dim RetVal As Long
' Determine if screen is already maximized.
If Me.WindowState = vbMaximized Then
' Set window to normal size
Me.WindowState = vbNormal
End If
' Get full screen width.
cx = GetSystemMetrics(SM_CXSCREEN)
' Get full screen height.
cy = GetSystemMetrics(SM_CYSCREEN)
' Call API to set new size of window.
RetVal = SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, cx, cy, _
SWP_SHOWWINDOW)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
' for some reson the program ends after a few seconds depenting on what i replace "nMouseCount > 10" with
nMouseCount = nMouseCount + 1
If nMouseCount > 10 Then End
End Sub
Private Sub Picture1_Click()
' ShowCursor True
Unload Me
End Sub
Private Sub Timer1_Timer()
' Okay, this is kind of a stupid way to do this - i know
10 Dim vidte, hojte
20 If Label1.Caption = 1 Then GoTo 30 Else
21 If Label1.Caption = 2 Then GoTo 70 Else
22 If Label1.Caption = 3 Then GoTo 110 Else
23 If Label1.Caption = 4 Then GoTo 150 Else GoTo 490
30 Label1.Caption = Label1.Caption + 1
40 Picture1.Top = Screen.Height / 9
50 Picture1.Left = Screen.Width / 2
60 GoTo 500
70 Label1.Caption = Label1.Caption + 1
80 Picture1.Top = (Screen.Height / 2) + (Screen.Height / 9)
90 Picture1.Left = Screen.Width / 2
100 GoTo 500
110 Label1.Caption = Label1.Caption + 1
120 Picture1.Top = Screen.Height / 5
130 Picture1.Left = Screen.Width / 5
140 GoTo 500
150 Label1.Caption = Label1.Caption + 1
160 Picture1.Top = Screen.Height - 3000
170 Picture1.Left = Screen.Width / 5
179 Label1.Caption = 1
180 GoTo 500
190
200
490 Label1.Caption = 1
500
End Sub
Indlæg senest redigeret d. 17.09.2008 22:23 af Bruger #6154