473,473 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to Use a Screen Saver app within My Application?

Hey All,

I was wondering if anyone has done or knows how to use a screen saver within
a VB app (i.e. display a running screen saver on a form or child window like
the 'Preview' functionality in the Control Panel)?

Thanks & Regards,

TC
May 24 '06 #1
11 1467
On Wed, 24 May 2006 06:26:52 -0400, "TCook" <ge**********@yahoo.com>
wrote:

I was wondering if anyone has done or knows how to use a screen saver within
a VB app (i.e. display a running screen saver on a form or child window like
the 'Preview' functionality in the Control Panel)?


Try starting the screensaver app with ' /p nnnn' as command tail,
where nnnn is the hwnd of the "preview" window, i.e.
Shell "MySaver.scr /p " & Me.hwnd

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)
May 24 '06 #2
TCook wrote:
I was wondering if anyone has done or knows how to use a screen saver
within a VB app (i.e. display a running screen saver on a form or
child window like the 'Preview' functionality in the Control Panel)?


Here ya go:

Shell "sspipes.scr /p " & CStr(Picture1.hWnd)

--
Working without a .NET?
http://classicvb.org/
May 24 '06 #3
Thanks a bunch guys!
"Karl E. Peterson" <ka**@mvps.org> wrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
TCook wrote:
I was wondering if anyone has done or knows how to use a screen saver
within a VB app (i.e. display a running screen saver on a form or
child window like the 'Preview' functionality in the Control Panel)?


Here ya go:

Shell "sspipes.scr /p " & CStr(Picture1.hWnd)

--
Working without a .NET?
http://classicvb.org/

May 24 '06 #4
Once launched, how can the screensaver be terminated programmatically?


"Karl E. Peterson" <ka**@mvps.org> wrote in message
news:OQ**************@TK2MSFTNGP04.phx.gbl...
TCook wrote:
I was wondering if anyone has done or knows how to use a screen saver
within a VB app (i.e. display a running screen saver on a form or
child window like the 'Preview' functionality in the Control Panel)?


Here ya go:

Shell "sspipes.scr /p " & CStr(Picture1.hWnd)

--
Working without a .NET?
http://classicvb.org/

May 25 '06 #5
Once launched, how can the screensaver be terminated programmatically?

"Tom Esh" <tj************@suscom.net> wrote in message
news:52********************************@4ax.com...
On Wed, 24 May 2006 06:26:52 -0400, "TCook" <ge**********@yahoo.com>
wrote:

I was wondering if anyone has done or knows how to use a screen saver
within
a VB app (i.e. display a running screen saver on a form or child window
like
the 'Preview' functionality in the Control Panel)?


Try starting the screensaver app with ' /p nnnn' as command tail,
where nnnn is the hwnd of the "preview" window, i.e.
Shell "MySaver.scr /p " & Me.hwnd

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)

May 25 '06 #6
Interesting, can we do the same for an application? Kind of make like a
container for our executed application?

"Tom Esh" <tj************@suscom.net> wrote in message
news:52********************************@4ax.com...
On Wed, 24 May 2006 06:26:52 -0400, "TCook" <ge**********@yahoo.com>
wrote:

I was wondering if anyone has done or knows how to use a screen saver
within
a VB app (i.e. display a running screen saver on a form or child window
like
the 'Preview' functionality in the Control Panel)?


Try starting the screensaver app with ' /p nnnn' as command tail,
where nnnn is the hwnd of the "preview" window, i.e.
Shell "MySaver.scr /p " & Me.hwnd

-Tom
MVP - Visual Basic
(please post replies to the newsgroup)

May 25 '06 #7
+Vice wrote:
I was wondering if anyone has done or knows how to use a screen
saver within
a VB app (i.e. display a running screen saver on a form or child
window like
the 'Preview' functionality in the Control Panel)?


Try starting the screensaver app with ' /p nnnn' as command tail,
where nnnn is the hwnd of the "preview" window, i.e.
Shell "MySaver.scr /p " & Me.hwnd


Interesting, can we do the same for an application? Kind of make
like a container for our executed application?


Depends. It's in the screensaver spec, that if they're passed /p and an
hWnd, they are supposed to show a "preview" of their handicraft there. If
other apps are written to do similar, then sure. (Since I'm not aware of
any other application category that behaves similarly, though, I'm sure the
answer is most likely "probably not.")
--
Working without a .NET?
http://classicvb.org/
May 25 '06 #8
TCook wrote:
Once launched, how can the screensaver be terminated programmatically?


Easiest way: Close the window to which it's attached.

Another likely way: Many screensavers will create their own window to draw
upon, and make this a child of the window passed on the command line when
invoked in preview mode. You could try enumerating the children of the
passed window, and sending WM_CLOSE.
--
Working without a .NET?
http://classicvb.org/
May 25 '06 #9
Hey Karl,

I actually need the window to stay open so closing the form wouldn't work.
I tried sending WM_CLOSE but to the PictureBox and it closed the form and
closed my application with it ;-)

What I was hoping to do was simply end the process similar to ending the
process from the task manager but APIs I tried didn't stop it. Any ideas
there?

Thanks,

TC

"Karl E. Peterson" <ka**@mvps.org> wrote in message
news:e0**************@TK2MSFTNGP04.phx.gbl...
TCook wrote:
Once launched, how can the screensaver be terminated programmatically?


Easiest way: Close the window to which it's attached.

Another likely way: Many screensavers will create their own window to draw
upon, and make this a child of the window passed on the command line when
invoked in preview mode. You could try enumerating the children of the
passed window, and sending WM_CLOSE.
--
Working without a .NET?
http://classicvb.org/

May 25 '06 #10
TCook wrote:
Once launched, how can the screensaver be terminated
programmatically?
Easiest way: Close the window to which it's attached.

Another likely way: Many screensavers will create their own window
to draw upon, and make this a child of the window passed on the
command line when invoked in preview mode. You could try
enumerating the children of the passed window, and sending WM_CLOSE.


I actually need the window to stay open so closing the form wouldn't
work. I tried sending WM_CLOSE but to the PictureBox and it closed
the form and closed my application with it ;-)


Don't send it to the picture box! Send it to the *child* of the picture
box. You'll need to use EnumChildWindows to find this. Or, probably just
as easily, GetWindow -- *assuming* you're not dealing with a VB-authored
screensaver. It's certainly possible that multiple windows may be parented
to your picturebox, although this is unlikely unless you're totally not
paying attention. (Not sure why I felt the need to say that. <g>) At any
rate, this works here:

Option Explicit

Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long,
ByVal wCmd As Long) As Long
Private Const GW_CHILD As Long = 5

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Const WM_CLOSE As Long = &H10

Private Sub cmdStart_Click()
Shell "sspipes.scr /p " & CStr(Picture1.hWnd)
End Sub

Private Sub cmdStop_Click()
Dim hWndPreview As Long
hWndPreview = GetWindow(Picture1.hWnd, GW_CHILD)
SendMessage hWndPreview, WM_CLOSE, 0&, ByVal 0&
End Sub
What I was hoping to do was simply end the process similar to ending
the process from the task manager but APIs I tried didn't stop it.
Any ideas there?


DON'T DO THAT! Huge Hammer; Petty Problem.

Later... Karl
--
Working without a .NET?
http://classicvb.org/
May 25 '06 #11
Hey Karl,

Go it! Thanks for the help ;-)

Regards,

TC

"Karl E. Peterson" <ka**@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
TCook wrote:
Once launched, how can the screensaver be terminated
programmatically?

Easiest way: Close the window to which it's attached.

Another likely way: Many screensavers will create their own window
to draw upon, and make this a child of the window passed on the
command line when invoked in preview mode. You could try
enumerating the children of the passed window, and sending WM_CLOSE.


I actually need the window to stay open so closing the form wouldn't
work. I tried sending WM_CLOSE but to the PictureBox and it closed
the form and closed my application with it ;-)


Don't send it to the picture box! Send it to the *child* of the picture
box. You'll need to use EnumChildWindows to find this. Or, probably just
as easily, GetWindow -- *assuming* you're not dealing with a VB-authored
screensaver. It's certainly possible that multiple windows may be
parented
to your picturebox, although this is unlikely unless you're totally not
paying attention. (Not sure why I felt the need to say that. <g>) At any
rate, this works here:

Option Explicit

Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long,
ByVal wCmd As Long) As Long
Private Const GW_CHILD As Long = 5

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long
Private Const WM_CLOSE As Long = &H10

Private Sub cmdStart_Click()
Shell "sspipes.scr /p " & CStr(Picture1.hWnd)
End Sub

Private Sub cmdStop_Click()
Dim hWndPreview As Long
hWndPreview = GetWindow(Picture1.hWnd, GW_CHILD)
SendMessage hWndPreview, WM_CLOSE, 0&, ByVal 0&
End Sub
What I was hoping to do was simply end the process similar to ending
the process from the task manager but APIs I tried didn't stop it.
Any ideas there?


DON'T DO THAT! Huge Hammer; Petty Problem.

Later... Karl
--
Working without a .NET?
http://classicvb.org/

May 26 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Card.Starzinger | last post by:
Hi! I need help to simulate programmatically user interaction on WinNT 4.0, to avoid screen saver activation. I try with key injection event. SendInput API and keybd_event API work...
2
by: Dwight Trumbower | last post by:
When doing a SaveAS on workbook, within a c# program, and the screen saver has activated, I always get the error message: "Excel cannot complete this task with available resources". I've looked...
2
by: Jon Davis | last post by:
I'd like to use the Screen Saver template (and any other templates) in C# Express, but I have the enterprise version of Whidbey installed instead and would rather use that. Are templates...
2
by: HumptyDumpty | last post by:
Does anyone know if there is a problem with re-enabling the Screen Saver after it has been disabled programmatically. I am using the SystemParametersInfo function within User32.dll, and have...
0
by: Jeffery Tyree | last post by:
I have a machine that will be used to demo some Excel spreadsheets at a convention. Because I did not author the spreadsheets and attendees will be allowed to play with the spreadsheets, I needed...
1
by: Mark van Dijk | last post by:
Hi there, I have a farely simple question that I can't seem to find the answer to. I've got a C# Winforms application that after building results in an executable. This executable is then...
1
by: ashwiniappajigowda | last post by:
Hi, I have an simple MFC dialog based application. On launch of that application 'Password protected screen saver' is not getting activated after the screen saver timeout. If 'On resume,...
3
by: KK | last post by:
Dear All I want to prevent the screen saver getting activated when my application is running. I have the following code, but still screen saver is activated. What corrections I should make to...
0
by: rehanrana | last post by:
I built application in VB6, my application appear in system tray, when I double click on icon of my application, it run screen saver, my screen saver shows images and news. Screen saver...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.