Solved

Unload Screensaver in NT4 svp3??

Posted on 1998-07-17
3
237 Views
Last Modified: 2010-05-03
I created a "slide-show" type screensaver in VB3 a long time ago.
 It basically loads a form with a picturebox and then loads a series of 10
bitmaps one after the other with a series of transition effects (fade, wipe, etc). It has
always worked great in Win 3.x, and then also in Win95. I created a VB4 32bit
version of it last year and have used it also without any problems on Windows 95.

This week I put it on my NT4 workstation and was suprised to see that when I
move the mouse or hit a key to clear the screensaver, it does not return me
to my desktop, but leaves me with a blank screen (like it didn't refresh or something).
To restore the screen I only need to CTRL ALT DEL and then cancel.

Something is preventing the screensaver from totally unloading. This same problem
happens with my VB3 and my VB4 32bit version. I downloaded a couple of the sample codes floating around the Net for ssavers in VB4 and added my "slideshow" code into it and got the same results.

Has anyone else experienced this same problem? Or am I missing something new that NT is doing? Maybe a new way to unload a ssaver?

Any help, information or sample code would be greatly appreciated.

Sincerely,

-S
0
Comment
Question by:summerset
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
gissing earned 100 total points
ID: 1466077
NT 4 screensavers don't work the same as they do on 16 bit windows or windows 95. They don't run on the main desktop, they run on a special desktop all of their own. Although I have never written a screensaver myself, I have written an application which has had to terminate a screensaver if it was running. My application had to work on 95 and NT 4. Here is my code:

/// KillScreenSaverFunc ////////////////////////////////////////////////////////
//
//
////////////////////

static BOOL CALLBACK KillScreenSaverFunc( HWND hwnd, LPARAM lParam )
{
    PostMessage( hwnd, WM_CLOSE, 0, 0 );
    return TRUE;
}


/// CMBSClientApp::KillScreenSaver /////////////////////////////////////////////
//
//  Purpose:
//      kill the screensaver if it is currently running
//  Note:
//      handles NT/95 differences
//
////////////////////

void CMBSClientApp::KillScreenSaver()
{
    //
    //  are we on Windows 95?
    //

    if( m_osVersion.IsWin95() )
    {
        //
        //  yes, so kill the screensaver appropriately
        //
   
        LogDbg( "Killing Windows 95 screensaver" );
       
        HWND hwndSS = FindWindow( "WindowsScreenSaverClass", NULL );
        if( hwndSS )
            SendMessage( hwndSS, WM_CLOSE, 0, 0L );
    }
    else
    {
        LogDbg( "Killing Windows NT screensaver" );

        //
        //  no, assume NT and killing the screensaver is
        //  a bit more involved
        //

        HDESK hdesk;    //  handle to the screensaver desktop

        //
        //  Attempt to get a handle to the screensaver desktop
        //

        hdesk = OpenDesktop( TEXT("Screen-saver"),
                             0,
                             FALSE,
                             DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);

        //
        //  bundle through the windows in the screensaver desktop and close them all
        //

        if( hdesk )
        {
            EnumDesktopWindows(hdesk, (WNDENUMPROC)KillScreenSaverFunc, 0);
            CloseDesktop(hdesk);
        }
    }
}

Although the code is in C++, I'm sure you'll get the idea.

i hope this helps.
0
 

Author Comment

by:summerset
ID: 1466078
Thanks for the lead. It helped me find more information which helped me to solve the problem. Check out MS KB Article Q140723. I was also suprised that there wasn't more documentation on this. Also -- I had to rebuild the program in VB5 before It would work. I assume this is VB4's limitations on callbacks.

I gave you a "B" because your sample was in C not VB.

Thanks again!!

-S
0
 

Author Comment

by:summerset
ID: 1466079
Thanks for the lead. It helped me find more information which helped me to solve the problem. Check out MS KB Article Q140723. I was also suprised that there wasn't more documentation on this. Also -- I had to rebuild the program in VB5 before It would work. I assume this is VB4's limitations on callbacks.

I gave you a "B" because your sample was in C not VB.

Thanks again!!

-S
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question