Help with Screen Saver Preview

Windows specific forum
upnorth
User
User
Posts: 18
Joined: Wed Jul 21, 2004 8:54 pm
Location: California, USA

Help with Screen Saver Preview

Post 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 
GreenGiant
Enthusiast
Enthusiast
Posts: 252
Joined: Fri Feb 20, 2004 5:43 pm

Post 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.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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).
--Kale

Image
upnorth
User
User
Posts: 18
Joined: Wed Jul 21, 2004 8:54 pm
Location: California, USA

Post by upnorth »

GreenGiant & Kale:

Thank you both for your help. I will review the examples you indicated and see what I can find out.
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post 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 :)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post 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
regards,
benny!
-
pe0ple ar3 str4nge!!!
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Hi Benny, I found the source in another post on this forum ;)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

--Kale

Image
Post Reply