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

1)

or
2)

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