Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Akow, tomaslolo), 1,536 guests, and 12 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Print Thread
Rate Thread
Change your Project into a Screen-Saver !! #266111
05/16/09 02:58
05/16/09 02:58
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
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.

Click to reveal..
Code:
/////////////////////////////////////////////////////////////////////////////////////////
#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.
Code:
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.



Last edited by EvilSOB; 11/18/09 21:04. Reason: Missing a bit of code for some reason...

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Change your Project into a Screen-Saver !! [Re: EvilSOB] #266144
05/16/09 10:11
05/16/09 10:11
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
This is an excellent contribution! It answers many questions I had with screensavers.

Only one question, why have you defined this:

long WINAPI Get_Foreground_Window();
#define PRAGMA_API Get_Foreground_Window;user32!GetForegroundWindow

In the windows.h file, there is already a GetForegroundWindow function, cant you use it directly?

Re: Change your Project into a Screen-Saver !! [Re: Spirit] #266173
05/16/09 12:13
05/16/09 12:13
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Because for some reason, in windows.h, A7 defines Get_Foreground as
long WINAPI Get_Foreground_Window(void);
And I couldnt get it to work that way.
So I just Bulldozed over it with the above lines...

Last edited by EvilSOB; 05/16/09 12:13.

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Change your Project into a Screen-Saver !! [Re: EvilSOB] #266183
05/16/09 13:01
05/16/09 13:01
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cool! Thanks! smile


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1