Page 1 of 1

Help with Screen Saver Preview

Posted: Thu Sep 09, 2004 11:52 pm
by upnorth
Hello,

I am using using Windows 2000 Pro, PB 3.91 registered.

I have created a screensaver for Windows and I wanted to add something for the preview that appears in the little window on the Display Properties\Screen Saver Tab.

Below is my code to test this. I built the code by looking at a bunch of VB examples that I found around the Internet.

The problem is that when you select the screensaver, nothing appears to happen :cry: unless:

1) :D You click anywhere. Either on the Display properties window, the screen saver tab, the Desktop, or any other app.
or
2) :D Do nothing. Just wait about 10 to 15 seconds and the Display Properties window will lose focus, and then wait another 15 or so seconds and the preview window finally shows the animation.

Does anyone have any idea what would cause the delay here ? Did I do something wrong or miss something ?

It sounds similar to the problem description in <A TARGET="_NEW" HREF="viewtopic.php?t=12360&highlight=%2Amovie%2A">this post.</A>

Any help would be appreciated. Thank you.

To test, compile to .EXE and then rename to .SCR. Then copy the .SCR to \WINNT or \WINDOWS. It will appear in the list of screensavers as "preview".

You can get the BMP referenced in the code <A HREF="http://www.tuvell.com/tsbs_logo_256.bmp">Here.</A>

Code: Select all

Enumeration
  #mywindow
  #logo_image
EndEnumeration

If LCase(Left(ProgramParameter(), 2)) <> "/p" ; This program was selected in the screen saver dialog, show preview
  End
EndIf

whandle.l = Val(ProgramParameter()) ; Handle of Screensaver Preview Window, second parameter passed by windows

preview_window_dims.RECT ; RECT structure to hold the dimensions of the preview window
GetClientRect_(whandle, @preview_window_dims) ; Get dims of preview window

x.l = preview_window_dims\left
y.l = preview_window_dims\top
w.l = preview_window_dims\right - preview_window_dims\left
h.l = preview_window_dims\bottom - preview_window_dims\top

OpenWindow(#mywindow,x,y,w,h, #PB_Window_BorderLess | #PB_Window_Invisible, "SCR-Preview")

; Step 1: Make my window a child window
SetWindowLong_(WindowID(#mywindow), #GWL_STYLE, GetWindowLong_(WindowID(#mywindow),#GWL_STYLE) | #WS_CHILD )
; Step 2: Set my window's parent
SetParent_(WindowID(#mywindow), whandle)
  
CatchImage(#logo_image, ?logo) ; Get ready to display bitmap

; This is the only way to catch events now, windowevent() doesn't work in this case.
Procedure MyWindowCallback(WindowID, Message, wParam, lParam) 
  Result = #PB_ProcessPureBasicEvents 
   If Message = #WM_CLOSE ; Could probably use #WM_QUIT instead ?
     End
   EndIf
  ProcedureReturn Result 
EndProcedure 
SetWindowCallback(@MyWindowCallback()) 

HideWindow(#mywindow, 0) ; Show the preview window

i.l = 0
Repeat ; Slide the images right to left
  StartDrawing(WindowOutput())
    DrawImage(UseImage(#logo_image), i,0,w,h) 
    DrawImage(UseImage(#logo_image), i+w,0,w,h)     
  StopDrawing()
  FlipBuffers()
  i = i - 1
  If i < 0-w
    i = 0
  EndIf
  Delay(5) 
ForEver ; Just keep drawing until we receive a #WM_CLOSE in the callback

End ; This will never execute

DataSection
  logo:
  IncludeBinary "tsbs_logo_256.bmp"
EndDataSection 

Posted: Fri Sep 10, 2004 12:04 am
by GreenGiant
Do a quick search for screensaver and preview. There are a number of topics such as this viewtopic.php?t=8891&highlight=screensaver+preview for previewing them. See if any of the search result pages have examples that work.

Posted: Fri Sep 10, 2004 12:37 am
by Kale
Heres the full source to a screensaver i wrote entirely in PB:

http://www.garyw.uklinux.net/PB/Screens ... Source.zip

I used the WinAPI to display a graphic in the preview window when the 'P' parameter is passed to the program (i.e. preview).

Posted: Fri Sep 10, 2004 3:14 pm
by upnorth
GreenGiant & Kale:

Thank you both for your help. I will review the examples you indicated and see what I can find out.

Posted: Tue Apr 12, 2005 11:45 pm
by GeoTrail
Kale wrote:Heres the full source to a screensaver i wrote entirely in PB:

http://www.garyw.uklinux.net/PB/Screens ... Source.zip

I used the WinAPI to display a graphic in the preview window when the 'P' parameter is passed to the program (i.e. preview).
Kale, do you still have that source?
I'd really like to check it out :)

Posted: Wed Apr 13, 2005 12:26 pm
by benny
@GeoTrail:

Did you already have a search on http://www.purearea.net :?:

These two sources could be of some interest for you :


http://www.purearea.net/pb/german/sr_vi ... enSaver.pb

http://www.purearea.net/pb/german/sr_vi ... Preview.pb

Posted: Wed Apr 13, 2005 12:31 pm
by GeoTrail
Hi Benny, I found the source in another post on this forum ;)

Posted: Wed Apr 13, 2005 12:31 pm
by Kale