-
Hey guys.
this is kind of a repost of an earlier question.
(Thanks Sam)
I am wondering why when I put my screensaver form in the preview window where the Screen saver is selected, i get these problems:
1. Both the Settings... button and the Preview button have to be clicked several times before I can get them to run.
2. The preview screen doesn't behave like the form does when the actual screen saver runs.
On this second problem, what i mean is, if I point the preview to a third form with just an image, then it does fine. but when i point it to the original SS form, which is a slideshow of images, i dont get the same thing in the preview window, but just the form background without the images.
Anybody know why on either of these?
Thanks
-
Hi wengang,
Im trying to create my own screensaver, but am stuck when it comes to previewing it. Could u help me out, maybe (if it isn't a problem) post ur code so that I can have a look?
Thanx.
-
If you move/click mouse or keyboard then your app will close right? What's happening is that your app fires these events because you moved the mouse or something. To avoid it to close immediately you just make a timer:
Code:
Private StartupTimer as Long
Sub Form_Load
StartupTimer=Timer
End sub
Sub Form_Mousemove(...
If Timer-StartupTimer>0.5 then unload me
end sub
-
Rammy, it's really not hard at all. I forgot the thread number but i just asked a couple of days ago. Do a search of this forum with the following words:
picture preview screensaver
The thread that was started by me has the entire code for creating the screensaver.
Kedaman, thanks for the help on that. I think that is exactly what i needed.
-
Kedaman, having said that, i do have a few questions, if you have a minute.
My screensaver only unloads with a mouse click on the form, nothing else.
I think maybe this timer wouldnt apply?
Also, what goes in the (...
index?
Also, i added in these pieces of code in the appropriate places, (adding the mousemove sub contents to my form_click sub instead) and it has no effect on the problem.
Clicking the buttons on the control panel's settings and preview options for screensaver, it feels like a race with the ss form to get a response. Several constant clicks and i can get it.
any thoughts?
-
Sorry i don't have my VB on this computer so i just put those (...) there. no index needed, just the event arguments.
Put your the line for the ontimerunload thing in your mousedown event instead, but i'm not sure what problem you had.
what you could do is let the app write down a log of what parameters is pased to it, command function you know, open a file with append and print them there. And also the mousedown events.
-
yes. what i have is pretty basic. a settings page that lets users choose directories, background color, timing, etc.
All is written to a file.
then the screen saver form opens the file, reads the directories, gets the jpgs out of all of them and randomly displays them in a slideshow.
The problem is still here and very basic.
I want to put an image in the little preview window, but every time i put something there, the settings and preview buttons stop responding unless i click them over and over.
Second problem is that the screen saver itself runs with no problem at all , but when i make it a daughter to the little preview window, it only shows the form and background color, but no images flashing.
I still haven't got this....
so, what do you think?
-
It could be a problem with the resizing of the form when you put it in the preview window, I've forgotten exactly what code I gave you, try using this to show the form(in preview mode)
Code:
Form1.Show
SetParent Form1.hWnd, hWndPreview
Form1.WindowState = vbMaximized
that will maximise the form again in the smaller window, I'm now sure if this was the code I gave you or not, If it was, or it still doesn't work then try changing the size of the form and running the screensaver normally (so instead of it running maximized over the whole screen make it run in a small window and see what it does, then change the code for the screen saver so that it will run normally in a little window and set it back to running normally in fullscreen mode, then it should work properly in preview mode.
-
Hey Sam
Thanks again.
still, the problem is the same as mentioned just above.
as for the last part, i can't quite follow what you mean.
i tried just something simple, i created a third form called frmPreview, on which i just wrote the name of the screensaver on a label and then placed this in the /p code.
Of course, it shows up in the preview window, but causes the same problem (about the buttons).
So, what's next?
-
okay guys.
I've written the simplest screensaver possible in order to test this problem. And, i still get the problem with the buttons. So, if anybody is willing, please copy this code and run it yourself to see if you get the same results (i've run this on 2 machines already). Thanks.
This only has one form (frmMain.frm) and one Module(Module1.bas) , and of course one picture in the app.path.(eol.jpg)
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
So if anybody has a little free time on your hands, could you please run this and let me know if you get the problem?
Thanks so much.
-
Hi,
while on the subject of screensavers.....Im trying to create my own, (as I've mentioned before).....have started with a real simple one...I'm just displaying a couple of bitmaps repeatedly using a timer. I have an Image control on my form....and I'm changing the picture property of the image control in the timer's Timer event.
The problem I'm facing is that when I try to end my application using the form's mousemove event, it works only if I move my mouse over the form and not the image control. Is there a way aroung this??? an API or anything????
Thanx in advance.
-
Rammy, you should call the forms mousemove event from the image mousemove event, and the same thing with mousedown and keydown events if you want it to unload att clicking or pressing keys.
wengang, too bad i don't have more than vb3 on this comp, but i'll try
-
thanx kedaman,
think my brain's stopped of late.....forgot that the image has a mousemove event as well!