🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.nt
Article #105

Terminating screen saver programatically

#105
From: Jorn Erlend Aaberg Nygjerd
Date: Mon, 28 Apr 1997 00:00
43 lines
2741 bytes

I have created a screen saver which I want to terminate programatically
after a specified period of time.
When the screen saver is created (started by the operating system) I
create a timer inside my CWnd derived class:

UINT m_TimerID = SetTimer(1, 5000, NULL);

This creates a timer which posts a WM_TIMER message after 5 seconds.
This is what my OnTimer looks like.

void CDrawWnd::OnTimer(UINT nIDEvent) {
  if (nIDEvent == m_TimerID) {
    // Kill the timer
    KillTimer(m_TimerID);
    // Kill the application
    //SendMessage(WM_MOUSEMOVE);
    //SendMessage(WM_MBUTTONDOWN);
    //::SendMessage(HWND_BROADCAST, WM_MOUSEMOVE, 0, lParam);
    //SendMessage(WM_DESTROY);
    PostQuitMessage(0);
 }
 else
  CWnd::OnTimer(nIDEvent);
}

When the 5 seconds have elapsed I kill the timer to free system
resources, and then post or send a message which terminates the screen
saver (have tried different messages).  This works fine the first time,
but the screen saver never starts again.  Anotherwords, if my system is
set to start the screen saver after 1 minute, it does just that.  5
seconds later the screen saver exits and never appears again even if I
wait 1,2,3, ... minutes.

It seems some operating system timer is not reset (not affected by my
programatically way to end the screen saver), so the operating system
thinks my screen saver is still running.

Does anybode have an answer or tip to this question?

Joern Nygjerd
jorn.nygjerd@ffi.no
Technical Details
Message-ID: <3364852D.5477@ffi.no>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <01bc52bf$4ce15c00$fd66bdcc@darth>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb9cd,2bb66df01fbae739
X-Google-Attributes: gidfb9cd,public
X-Google-Thread: fa335,2bb66df01fbae739
X-Google-Attributes: gidfa335,public
X-Google-Thread: 1105ff,2bb66df01fbae739
X-Google-Attributes: gid1105ff,public
X-Google-Thread: 112bf7,2bb66df01fbae739
X-Google-Attributes: gid112bf7,public
X-Google-Thread: 113dfb,2bb66df01fbae739
X-Google-Attributes: gid113dfb,public
X-Google-Thread: f8083,2bb66df01fbae739
X-Google-Attributes: gidf8083,public
X-Google-Thread: f4307,2bb66df01fbae739
X-Google-Attributes: gidf4307,public
X-Google-Thread: fccee,2bb66df01fbae739
X-Google-Attributes: gidfccee,public
From: Jorn Erlend Aaberg Nygjerd <jorn.nygjerd@ffi.no>
Subject: Terminating screen saver programatically
Date: 1997/04/28
Message-ID: <3364852D.5477@ffi.no>
X-Deja-AN: 237893100
References: <01bc52bf$4ce15c00$fd66bdcc@darth>
X-Priority: 3 (Normal)
Organization: Forsvarets Forskningsinstitutt
Newsgroups: comp.os.ms-windows.nt,comp.os.ms-windows.nt.misc,comp.os.ms-windows.programmer,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.winhelp,comp.os.ms-windows.win95,fido.win32,microsoft.public.vc,microsoft.public.vc.events,microsoft.