Im looking for help getting these instructions multi-language friendly,
AND they've only been tested on commercial, so pro-users can comment too please.
Any help/suggestions for these instructions (or the code) will be appreciated.
/////////////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
long WINAPI Get_Foreground_Window();
#define PRAGMA_API Get_Foreground_Window;user32!GetForegroundWindow
/////////////////////////////////////////////////////////////////////////////////////////
//
// Application: Screen_Saver_Template
// Author: EvilSOB
// Created: 16-05-2009
//
/////////////////////////////////////////////////////////////////////////////////////////
// FYI : Parameters Passed by windows to THIS application when acting as a screensaver //
/////////////////////////////////////////////////////////////////////////////////////////
// //
// Passed from Display Properties panel //
// /p hWnd Auto ::Show in little Monitor. hWnd=Preview D3DWindow hWnd //
// /s Preview Button ::Execute Screensaver //
// /c:hWnd Configure Button ::Open Control Panel. hWnd=Screensaver Control hWnd //
// //
// Passed from Right-Click Menu //
// /S Test ::Execute Screensaver //
// none Configure ::Open Control Panel - no hWnd passed //
// not called Install ::Just opens the Display Properties/ScreenSaver Control //
// //
// Passed from Windows when Idle-time expires //
// /S ::Execute Screensaver //
// //
// //
/////////////////////////////////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//Open a mini-screensaver version to display the the "virtual" //
//monitor in the Display Properties / ScreenSaver panel. //
/////////////////////////////////////////////////////////////////////////////////////////
//Ive never sucessfully tried anything like this before from liteC, but its reasonable //
//Known Problems: //
// Steals Mouse/Keyboard focus away from the Display Properties panel. //
// Still draws ON-TOP-OF the task-bar of windows. //
// Still has a screen-twitch when entering mini-preview mode. Probably incurable. //
/////////////////////////////////////////////////////////////////////////////////////////
void mini_preview() //
{ //
RECT rct; long pWnd = str_to_int((command_str.chars)[str_stri(command_str,"/p")+2]);
while(1)
{ if(!IsWindowVisible(pWnd)) sys_exit(""); //preview window no longer alive
if(Get_Foreground_Window()==hWnd) SetForegroundWindow(pWnd);
GetWindowRect(pWnd,&rct); video_set(0,0,0,2); video_window(NULL,NULL,1,0);
SetWindowPos(hWnd,-1,rct.left,rct.top,rct.right-rct.left,rct.bottom-rct.top,0);
wait(1);
}
}
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//open a configuration panel of some kind //
/////////////////////////////////////////////////////////////////////////////////////////
//remember to do a level_load unless you are using APIs //
//also, the hWnd of the display properties MAY be available. //
//(if "cWnd" below is not NULL, it is the hWnf of the properties panel //
//on the command line so you can get a window-position //
/////////////////////////////////////////////////////////////////////////////////////////
void config_panel() //#### INCOMPLETE ####//
{
RECT rct; long cWnd = str_to_int((command_str.chars)[str_stri(command_str,"/p")+2]);
wait(1); sys_exit("");
}
//
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
function main() { var allow_compile=2; }
//
function ScreenSaver_startup()
{
add_folder(app_name); //look in sub-folder with app_name for all files
proc_kill((void*)main); //kill real main, we'll restart it later if we need to.
if((str_stri(command_str,"/c"))||(!str_stri(command_str,"/")))
{ config_panel(); return; } //run config and exit from there
if(str_stri(command_str,"/p"))
{ mini_preview(); main(); return; } //run mini-preview and exit from there
//
video_set(sys_metrics(0),sys_metrics(1),0,1); //set full-screen / same-resolution
main(); //run main as scrensaver
//
wait(5); VECTOR old_mouse; vec_set(old_mouse, mouse_cursor);
while(1)
{ if(integer(vec_dist(old_mouse,mouse_cursor))) break; //exit on mouse-movement
if(key_any) break; //exit on ANY keypress, including mouse-buttons
wait(1);
}
sys_exit("");
//////////////////////////////////////////////////////////////////////////////////////
}
//
//
0> copy the above
Scr_Saver.h file to your project folder.
1> Insert
#include "Scr_Saver.h" at the start of your main script.
2> Insert
wait(1); at the VERY start of your
main function.
3> Highly Suggested :: Disable any video setting functions in your code.
4> Compile...
Then, in your CD folder, create the file
%MyProject%.WDL, and insert the following lines.
var video_screen = 0;
var video_mode = 0;
PLUGINDIR = "NULL";
Alternatively, if it already has a startup WDL, just insert the lines at its start.
Still in your CD folder, rename your
%MyProject%.EXE file to
%MyProject%.SCR and
move ALL project files to a new folder called %MyProject%
Eg ...\MyProject.cd\MyProject\*.*
The only files to keep in the CD folder will be %MyProject%.SCR, %MyProject%.WDL and acknex.dll
Everything else should be in the %MyProject% folder.
Eg
...\ScreenSav.CD\ScreenSav.SCR
...\ScreenSav.CD\ScreenSav.WDL
...\ScreenSav.CD\acknex.dll
...\ScreenSav.CD\ScreenSav\*.*
Screensaver project is now complete.
To test that all went well, just double-click on the SCR file to test it.
(this test wont work if its still named as an EXE !)To test its running mode, right-click the SCR and select TEST.
To test its config panel, right-click the SCR and select CONFIGURE.
To test its preview mode, right-click the SCR and select INSTALL.
Remember to select NONE and OK from the install panel, or windows will
leave it installed and running from its current location!If all goes well, just copy the whole contents of the CD folder,
three files and the one folder as listed above, and paste the whole set
to either your WINDOWS folder, or your WINDOWS\SYSTEM32 folder.
Now your
screensaver is "installed" into windows.
Enjoy
Any suggestions or questions are welcome.
If you look in my code, the control panel doesnt exist at all, so its not very tested.
And the preview panel still has a couple of minor flaws listed in the code.
Any help sorting out any known or unknown issues will be appreciated.