|
-
Aug 31st, 2000, 08:52 PM
#1
Thread Starter
Frenzied Member
Hi all. I know I'm being a pain, but I haven't even found a working ss on the web with a sample of picture preview.
The code below doesn't work, but I don't know why. It doesn't show the preview and it makes the "settings" and "preview" buttons stop responding.
Anybody know why?
CODE FOR THE SCREENSAVER FORM:
(one imagebox (image1 set stretch to true))
Private Sub Form_Load()
frmMain.Width = Screen.Width
frmMain.Height = Screen.Height
Image1.Left = 0
Image1.Top = 0
Image1.Width = Screen.Width
Image1.Height = Screen.Height
strFilename = App.Path & "\eol.jpg"
Image1.Picture = LoadPicture(strFilename)
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeySpace: StopSS
End Select
End Sub
Private Sub StopSS()
Unload Me
End
End Sub
AND the code for the Module:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Sub Main()
Dim strCmdLine As String
Dim strArguments As String
Dim hWndPreview As Long
strArguments = Trim(Command$)
If App.PrevInstance = True Then End
strCmdLine = Left(Command, 2)
If strCmdLine = "/p" Then
hWndPreview = Trim(Right(strArguments, Len(strArguments) - 2))
Call SetParent(frmMain.hWnd, hWndPreview)
frmMain.Show
ElseIf strCmdLine = "/c" Then
MsgBox ("There are no configuration settings for this screensaver.")
Else
Call Load(frmMain)
frmMain.Show
End If
End Sub
-
Aug 31st, 2000, 09:40 PM
#2
Frenzied Member
this might be why:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeySpace = StopSS
End Select
End Sub
NXSupport - Your one-stop source for computer help
-
Aug 31st, 2000, 09:51 PM
#3
Member
hWndPreview = Trim(Right(strArguments, Len(strArguments) - 2))
is that the actual object.hWnd of the Preview window? You're passing a string to a Long, try this instead
hWndPreview = CLng(Trim(Right$(strArguments, Len(strArguments) -2)))
MsgBox ("There are no configuration settings for this screensaver.") 'this is specifying a Function, Remove the parenthesis and this part will work correctly. You'll get a runtime error if you don't.
MsgBox "There are no configuration settings for this screensaver."
Glacius Cool
Concept Designer
VB5sp4,VC++6sp3
-
Aug 31st, 2000, 10:00 PM
#4
Member
Sorry dimava, his code is almost correct.
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeySpace: StopSS
End Select
End Sub
Private Sub StopSS()
Unload Me
End '--------Why did you put this here if you already have Unload Me ??
'--------You only have this form to unload and no external dependencies that won't unload with Unload Me, in other words you can get rid of the End statement.
End Sub
Would work better if it was:
Private sub some stuff here
Select Case KeyCode
Case is vbKeySpace
StopSS
End Select
End sub
Private Sub StopSS()
Unload Me
End Sub
which is the same as
Private sub some stuff here
If KeyCode = vbKeySpace or chr$(32) then Unload Me
end sub
Glacius Cool
Concept Designer
VB5sp4,VC++6sp3
-
Aug 31st, 2000, 10:01 PM
#5
Frenzied Member
yea, I guess I was wrong, sorry
NXSupport - Your one-stop source for computer help
-
Sep 1st, 2000, 01:12 AM
#6
Thread Starter
Frenzied Member
Hey fellas.
thanks for replying. I made those changes but still get the same results.
If either of you have time or inclination, could you try the code on your machine and let me know if you get this problem?
-
Sep 1st, 2000, 01:23 AM
#7
Thread Starter
Frenzied Member
oh, just a couple of things.
First, that wasn't the actual code. I used Selece Case, not If block in the Module:
Public Sub Main()
If App.PrevInstance = True Then End
Dim strArguments As String
Dim hWndPreview As Long
strArguments = Trim(Command$)
Select Case Left(strArguments, 2)
Case "/s"
frmMain.Show
Case "/p"
hWndPreview = CLng(Trim(Right$(strArguments, Len(strArguments) - 2)))
Call SetParent(frmMain.hWnd, hWndPreview)
frmMain.Show
Case "/c"
frmDirectory.Show
End Select
End Sub
=======================================================
Second, i tested this also by replacing the screensaver in Case "/p" with just a blank form with no code whatsoever and still get the same results.
-
Sep 8th, 2000, 02:52 AM
#8
Thread Starter
Frenzied Member
Wen Gang, Programmer
VB6, QB, HTML, ASP, VBScript, Visual C++, Java
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
|