|
|
Comments and Discussions
|
|
 |

|
I'm writing a screen saver, but when the mini-preview is presented, if the user choose other screen saver, my mini-preview is still presented in the background.
How can I know that I should close the mini-preview?
Thanks!
|
|
|
|

|
Sorry it's been so long since your question. My first guess is to hook into the lost focus event. I'm sure there is some sort of mechanism for this, but since I've not done any screen savers lately I don't know off the top of my head. I would google around before using the lost focus event, as I'm pretty sure there's a better way. There are other issues with this code that now apply to windows 7 which preclude the program from being able to save the configurations. The configuration code really needs to be reworked due to changes in security with vista/windows 7
Been there, done that, forgot why!
|
|
|
|

|
Sometimes when I resume Windows from hibernation I see minimized SwartScreenSaverForm on task bar. It doesn't interact so I can only kill screen saver process.
|
|
|
|

|
We would all do well to remember that windows also has shell menu options that although have the same names as in the screen saver tab of the display settings, they send different parameters, and for good reason.
the "config" option in the shell menu when you right click a .scr file does NOT send any parameters, but the default double click option is "test" and sends /s. so the "no arguments" option should open the configuration form, that way when the screen saver is outside of the screen saver tab, it still functions correctly.
reason being, is the /c: parameter is intended for creating the settings form as a child of the display settings dialog box.
Happy Coding
|
|
|
|

|
Hi, I have used your code to get my pitiful attempt at a screensaver to show on multiple monitors. That is working, and I just have it so either some default images show in a picture box that bounces around the screen, or it shows a web-based slide show in a web browser control that also bounces (slowly so the stuff can be read) around the screen. What I've noticed though, is that it has 80%+ CPU usage when I look in task manager so I redownloaded and compiled yours to see what it came up with and it hovered right around 80% CPU usage also. So then I started looking at some of the ones that came with XP and depending on the screensaver, it seems to vary from 5% for some up to 30%.
Do you know why the high CPU usage? I would like to figure this out I'm just not sure where to start. Perhaps with the threading? (Attempting this screensaver is the first windows application I've ever done, previous stuff has all been web-based so I am a bit lost yet...)
|
|
|
|

|
That the display with the lower display number is *actually* to the left of the display with the higher display number?
I ask because that assumption is false on my system, and I only get output on the right-most monitor - when I get non-crashing output at all.
Thanks a bunch for all of the effort though - I'm just starting to learn about Screens and all that - this is a great resource.
|
|
|
|

|
Hello, How to lock workstation when a screensaver starts, I actually used LockWorkstation(), user32.dll function, it works fine aslong as i am running it as exe but it doesn't seem to bother when the screensaver(.scr) is automatically kicked off. Beating my head against wall to solve it. Any help is appreciated.
Venkat
|
|
|
|

|
This is an option on the Windows screen saver selection dialog box. Just set the option "On resume, display logon screen".
|
|
|
|

|
Hi!
Great article! Tackles several issues usually ignored with screen saver designs. However I am still not satisfied with the way configuration form is handled. Is there truly no way in C# of making the configuration window a modal dialog of the underlying system window (handled by Win) rather than pretending that it is one? Surely Microsoft's savers do the trick correctly.
Marcin Floryan (MCAD)
|
|
|
|

|
I am a perfectionist like you and this bothered me too . I solved it in the end, with some inspiration from this page: Creating a IWin32Window from a Win32 Handle.
Using MS Spy++, I realised that the handle Windows passes us is actually that of the "Screen Saver" tab, not the "Display Properties" dialog. Following a clue from the above page, I tried a simple MessageBox instead of my own form, and that actually worked with the tab's handle, ie it was modal to the entire dialog. When I manually entered the "Display Properties" dialog's handle in my code, my form was finally modal!
I was curious, so I looked at the "source code" of the System.Windows.Forms assembly (using the awesome .NET Reflector). Indeed, Form.ShowDialog() and MessageBox.Show( owner, ... ) behave differently. Both use the Windows API, but the MessageBox uses some more clever tricks.
Realising there's no avoiding the Windows API, I eventually ended up using the simple GetAncestor function. Passing the handle of any random control to it (and the GA_ROOT param), it will return the handle to the actual window that contains the control. See the code below:
public static class DotNETScreenSaverApp
{
private class WindowsAPIWrapper
{
public enum AncestorType : uint
{
Parent = 1, ParentWindow, Owner }
[DllImport( "user32.dll", ExactSpelling = true )]
public static extern IntPtr GetAncestor( IntPtr handle, AncestorType ancestorType );
}
private class Win32WindowHandleWrapper : IWin32Window
{
public IntPtr Handle
{
get
{
return handle;
}
set
{
handle = value;
}
}
private IntPtr handle;
}
static int Main( string[] args )
{
...
if ( args[0].StartsWith( "/c:", true, CultureInfo.InvariantCulture ) )
{
Application.EnableVisualStyles();
IntPtr windowsScreenSaverTabHandle =
new IntPtr( Convert.ToInt32( args[0].ToLower().Replace( "/c:", "" ) ) );
Win32WindowHandleWrapper windowsDisplayPropertiesDialogWrapper = new Win32WindowHandleWrapper();
windowsDisplayPropertiesDialogWrapper.Handle = WindowsAPIWrapper.GetAncestor( windowsScreenSaverTabHandle,
WindowsAPIWrapper.AncestorType.ParentWindow );
new SettingsForm().ShowDialog( windowsDisplayPropertiesDialogWrapper );
}
...
}
I hope this helps someone!
KostasVl
modified on Thursday, October 9, 2008 5:53 PM
|
|
|
|

|
I’m developing PDA application using C# window, how to exit Application if mouse is not moving around any form of Project? Is there any event to write code in the Project.
Please help me how to do it.
Thanks for advance
Rgds
Ramesh.
Hi
|
|
|
|

|
Moving
I’m developing PDA application using C# window, how to exit Application if mouse is not moving around any form of Project? Is there any event to write code in the Project.
Please help me how to do it.
Thanks for advance
Rgds
Ramesh.
|
|
|
|

|
I added the following lines to PaintMe so that pressing a shift key alone would cancel the screen saver:
After the line Refresh(); in PaintMe for ScreenSaverForm, add the following:
if (ModifierKeys != Keys.None)
ShuttingDownDel();
|
|
|
|

|
I am developing a C# windows application with 5 forms in it.The objective is to display the five forms in individual monitors when the program starts. 5 monitors are connected to a single CPU,with one primary monitor and remaining in 4 monitors connected through different VGA cards. Kindly help.waiting for reply. Vinay Vinay Varghese
|
|
|
|

|
I want to say that your work on this is amazing! I was trying coming up with a screen saver myself, but I would've given up long before I got anywhere near the stage you have achieved!
Regarding the problem when changing the file to .scr that someone posted below, here's what happens:
When I double click a .scr file, /S is passed in and not /s as you assumed. So in Entrypoint.cs, I suggest you use: switch (argPrefix.ToLower())
Also, when I right click a .scr file and choose Configure, no args are passed in! This is the only time I have managed to get an .scr file to start with no args. So, I suggest that you open the config form if no args are passed in. Perhaps add a preview button to the config form, just in case what the person really wants is to see the screen saver. If they are using it as a .exe file for some reason, no args will be passed in, so they would get the config form then too. You could check for .exe or .scr and handle them differently.
Another thing I think could be changed is the way the XML config works. I suggest starting from scratch. Create a simple object which contains all the config values as fields, and then use a magic thing called Serialization to save and load it!
Keep up the good work!
|
|
|
|

|
Thanks again for your suggestions. I got an email saying that you had also found that I was getting locked up in the waitany(timespan) line but only when double-buffering is activated. Strangely, I do not see that post here.
I have had so much grief with double-buffering bugs that it began to feel as painful as doing a root canal with a weedeater without anesthetic. I went about a month or more where I would run the probram for days or seconds before I got some mysterious crash and by the time I got it working without crashing, I could not even look at my computer without starting to shake in fury.
It is as if Microsoft has written the code specifically to torture people like me who want to use double-buffering because it is so awesome, but the bugs have made it not worth the effort of fighting it. I began to get so desperate I'd toss away my values of good programming practice and do the equivalent of patching it together with bubble-gum, duct tape and folding chairs. Microsoft has made double-buffering the pretty carrot in a dog race chasing the rabbit that is trying to get the carrot on the stick and through with chasing this carrot. I spent possibly 80 hours fighting this bug and I had it fixed, and now it's broken again.
I did solve the problems for my system for awhile, but by the time I did, I had every bit of what I could stand and one more second of dealing with the double-buffering bugs was going to be the last straw.
A few months later, some update caused it to start crashing again on other people's machine than mine.
I wish I could solve this but I am so sick of dealing with double-buffering bugs, that I am no longer willing to fight them. I am not a quitter, and this possibly is the first time in my entire programmming life that I am going to say I can't do this. I can't fix this problem. I'm finished fighting the carrot.
I really appreciate all the kind words from not just you but others who say its a fine piece of work, I accomplished what I wanted - to create a framework and example code where someone could create a screensaver that actually did the things it was supposed to do but I can't gain any of the benefits of it, because I hate the double-buffering carrot and my career of fighting it is over. I did more damage to myself trying to fix it than I would have done doing anything else.
It used to be that the parameters to a screensaver were consistant between windows versions, now the only consistancy is the inconsistancy.
I wish you the best of luck in solving the problem. In fact, if you ever solve the double-buffering issue, I'll change the article and make you co-author!
Sorry if I sound ranty and negative. I realize I'm over-reacting, but after being screwed over by updates, after suffering this intermittent bug for weeks, I feel like I have lost a large part of my sanity ala the inspector verses Cleauseau in the pink panther series. I've gotten myself all wound up just thinking about this.
I plan to some day tackle this problem by going to DXDirect 3D instead of ever using Double-Buffering again. I know its far more complicted than the regular drawing routines, but at least it seems to work instead of mutate.
-- Programming The art of entering instructions to a computer and getting the results the computer wants to give you.
Been there, done that, forgot why!
|
|
|
|

|
Thanks for the reply! The message of mine that you got an email about is below in a reply to one of your old messages in the previous thread.
I can't imagine I'll get my head around the double buffering issue as a whole, but I'll at least see if I can solve this locking-up problem... I'll keep you posted. I get the same problem at home and at work.
I'm intending to learn OpenGL at some point, I'm sure that would be a better option. Something using Mono or a Java IDE might give better results too.
|
|
|
|

|
Ok, I think I've solved the problem I was having. I spotted these two lines in ScreenSaver.cs:
sf[i].Show();
sf[i].PaintMe();
Show() is going to cause certain events to fire, so directly between those two lines I added an Application.DoEvents();
I've given it a couple of days, and it seems to have stopped the lock ups. My fingers are crossed!
|
|
|
|

|
Thanks, I tried it, yet for some reason I cannot test to see if it works on two monitors. It used to be that I could set my video card to have two monitors displaying separate things any more. This has something to do with the new NVidia drivers. Have you been able to test this? I think I remember trying this and it caused all the processing to go to one monitor and not to both.
Been there, done that, forgot why!
|
|
|
|

|
Yeah, I've been able to test it on dual monitors and it works just fine!
|
|
|
|

|
I tried this and it works great!!!
Thanks for your help Bloopy. I am a bit non-plaused that I cannot find my edit article link so I can give you credit and mention your great contribution at the very top. It seems that the article seems to take authorship from the name field. I'm logged in. Do you happen to see some link I'm missing or know how I can update the article so that I can give you credit?
What is your real name incase you wish to have your name in lights so to speak?
I'll check the FAQ when I have more time but until then, I wish to use this message as a public acknowledgement of your fine help!
Been there, done that, forgot why!
|
|
|
|

|
I would guess you can edit your articles if you go to the 'My Articles' link near the top right.
I don't think the top of your article is the right place to put the update. :P My real name is Paul Harvey.
|
|
|
|

|
I read the FAQ, They have moved the article to samples. Once it is moved, online editing is impossible and must be done by getting the html source code, modifying it, zipping it up as well as zipping up the source files and then emailing them to code project and then they modify the article for me. Trouble is, that if there is an error in the editing, that error may screw up the article, I don't trust them to fix errors but I could try I suppose.
What do you think? Should I try it? Personally, I think they are making a big mistake having moved articles set in stone. Just a few errors, and they would tire of posting my mods. I remember, having a harder time trying to get the article to behave, to get what the preview said I was getting to match reality was worse than the project itself.
Been there, done that, forgot why!
|
|
|
|

|
If you are modifying the html source code, at least you should be able to preview it in your browser to see that it looks alright. On the other hand, perhaps you can rely on people to read the comments here, which is a lot easier than trying to edit it!
|
|
|
|

|
As you're most likely aware, screensavers are basicly executibles with the .scr extension instead of .exe. The problem with swarm comes when you rename its output Swarm.exe to Swarm.scr
It creates a new xml file but fails to completely run the screensaver. The screen does not load. Any ideas?
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Example screensaver in source code. Does a mini-preview too!
| Type | Article |
| Licence | |
| First Posted | 31 May 2005 |
| Views | 185,347 |
| Bookmarked | 188 times |
|
|