Hi all, I've been trying to get DBPro to behave properly in Windows when a compiled exe is turned in to a screen saver. I've has some success and posted this little demo. Read the code comment for more info!!
rem * DEMO SCREEN SAVER - BY GARY CROOK [AKA DOOMJUDGE] SEPT 2002 *
rem This code should be compiled with DBPro's Display Settings = Hidden
rem Once compiled into a '.exe' rename the file extension to '.scr'
rem Right-click on the filename and select 'Install' to install the .scr as a screen saver
rem Tested on Windows 98 and Windows XP
rem We don't show anything until we have checked if this program can run or not
rem Grab the option from the command line that Windows passes in
cmd$ = upper$(left$(CL$(),2))
saverMode = 3
if cmd$ = "" or cmd$ = "/S" then saverMode = 1
if cmd$ = "/C" then saverMode = 2
rem Check the registry to find out if this program is already running
regValue = get registry("Software\Dark Basic\Misc\ScreenSaver1", "Running")
if regValue = 0
rem There is not another instance of the screen saver running so we can progress
select saverMode
case 1
rem /S = start saver main loop
rem Write to the registry to say this program is running
regWrite(1)
rem The main saver window can be shown
setWindowProps()
rem Store the mouse position
Xmouse = mouseX()
Ymouse = mouseY()
rem Make a quick object for this demo
make object cube 1,300
rotAngleX# = 0.0
rotAngleY# = 0.0
do
rem ********** Your own screen saver code goes here ************************************
set cursor 0,0
print "MAIN MODE"
xrotate object 1,wrapvalue(rotAngleX#)
yrotate object 1,wrapvalue(rotAngleY#)
rotAngleX# = rotAngleX# - 0.2
rotAngleY# = rotAngleY# + 0.2
rem ************************************************************************************
if mouseX() Xmouse or mouseY() YMouse or scancode() 0
rem The mouse moved or a key was pressed, so inform the registry and end the program
regWrite(0)
end
endif
sync
loop
endcase
case 2
rem /C = configure saver
rem Show the configuration page
setWindowProps()
do
cls
set cursor 0,0
print "CONFIGURATION MODE - put your own options on this screen"
set cursor 0,20
print "Press ESC to quit"
sync
loop
endcase
case 3
rem Either /P (show mini-preview) or /A (password protect) modes (not implemented).
rem /P passes in the hWnd to the mini-preview 'monitor screen' on the Windows Screen Saver tab
rem If anyone knows how to pass data back from DBPro to that screen via a DLL or otherwise, please let me know!
rem If this app wasn't set to hidden at this point, Windows would re-run it visibly as it's trying to get its mini-preview
end
endcase
endselect
else
rem Quit immediately as another instance is running
end
endif
function setWindowProps()
sync on
sync rate 0
set window layout 0,0,0
maximize window
show window
sleep 1000
endfunction
function regWrite(intValue)
write to registry "Software\Dark Basic\Misc\ScreenSaver1", "Running", intValue
endfunction