-
Now that I've made a few so-so screensavers, i'd like to ask if anybody here knows how to put the preview image into the box, so that when the user selects my screensaver an image will appear on the little preview monitor in win95 and win98.
Can anybody help me on this one?
Thanks
-
look at http://www.learn.com/ under the computers section, there should be a tutorial on screensavers(BTW: you have to sign up first, but its free)
-
when your screensaver app is run it will be asked to do one of 3 things
- Run the screensaver
- Run a preview of the screensaver in a smaller window
- Display its configuration screen
The way screensavers are informed which way to run is through the Commandline
the command lines for each mode are these
[list = 1][*]/s[*]/p[*]/c[/list]
To get at these we use the Command$ key word.
in the case of the Prieview the commandline also contains a number, written after the \p, this is the hWnd of the window that the prieview sohold be displayed in.
So, If your screensaver is a Form, called Form1, which runs on its own as soon as the form is loaded you can use a Sub Main to decide on the run mode.
add a standard module to your project and add this
Code:
Option Explicit
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
'The Program Starts Here
Public Sub Main()
'String to hold the command line
Dim strArguments As String
'Variable to hold the window handle of the preview window
Dim hWndPreview As Long
'get the command line
strArguments = Trim(Command$)
Select Case Left(strArguments, 2) 'NB we use the left 2 chars because the hWnd may be takked on the end
Case "/s" 'We just run the screensaver
Form1.Show
Case "/p" 'We Want a preview
'lop off the first 2 characters to get our hWnd
hWndPreview = Trim(Right(strArguments, Len(strArguments) - 2))
'show the form
Form1.Show
'Use SetParent to make the form a childwindow of the Prieview window
Call SetParent(Form1.hWnd, hWndPreview)
'Maximise the window so it exactly fills the preview screen
Form1.Windowstate = vbMaximized
Case "/c" 'We havn't got a config screen so show a messagebox and end
MsgBox "This Screensaver Does Not Have a Setup Screen"
End Select
End Sub
then goto project properties in the project window and set the startup object to sub main, the program will then check the command line before running your form.
[Edited by Sam Finch on 09-04-2000 at 08:15 AM]
-
Hi.
thanks for the reply.
what i mean to say is rather than the /p
(maybe i'm way off, i don't know)
I just want to put a picture in the little box, not when the user clicks the Preview button, but just when my screensaver is selected, an image that shows in the little PC .
-
this is what you need, when the user clicks the preview button the screensaver runs as normal (it gets a /s) when the screensaver is selected in control pannel then the screensaver is run with the /p command line and is given the hWnd of the little PC, the code should make the window a child of the PC's window, so the screensaver will run in the PC's window.
-
Sam,
Okay. Got it. I guess I was a bit dense about that.
But, now that I have used the preview code, the control panel part no longer works properly. I have to hit the buttons ( both preview and settings) several times before I get either of them to come up.
When I went back to the code and remarked (') all the lines under Case "/p", the ss went back to working as usual.
Do you have any idea why it is doing that?
I put the actual SS form name in place of the Form1 in your code.
If it makes a difference, the SS has basically the function of giving a slideshow of jpg images from one or more directories chosen by the user in the settings form.
Thanks.