Solved

preview screen saver

Posted on 2007-03-23
10
1,610 Views
Last Modified: 2012-06-27
How to preview screen saver in tiny box(Like Control Panel--->Desktop does) ?

I can launch screensavers in preview mode, but, they go full screen, instead of confining themselves to the handle of the object I supply.

I am using:

ShellExec(application.handle,
nil,
pchar('?:\path\ssname.scr'),
pchar(' /p '+IntToStr(MyHandle)),
nil,
SW_SHOWNORMAL)

where:

MyHandle:=Image1.Canvas.Handle; // this is a typical example

When I execute the SHellExec line IMage1 changes colour (it goes white instead of the initial grey), but, the chosen screen saver previews itself in full screen mode.


Give me a clue, somebody, anybody, please ....

0
Comment
Question by:David_Ward
  • 5
  • 3
  • 2
10 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 18780313
SW_SHOWNORMAL means that screensaver will be run in its normal mode which is full screen

screen savers are normal applications (see: http://www.mindspring.com/~cityzoo/scrnsavr.html how to do it in delphi)
so to preview you might try with MoveWindow() to resize/move to desired position

ziolko.
0
 
LVL 4

Author Comment

by:David_Ward
ID: 18780638
No,

the nShowCommand parameter serves absolutely no purpose for ScreenSavers, but it has to be set to -something- to keep the ShellExec command happy.

However, just to be on the safe side, I have tested each and every available value and the behaviour of my test program is the same, irrespective of that setting.


Remember, I am NOT writing ScreenSavers, I just want to execute ScreenSavers from my Delphi app and have the selected ScreenSaver execute within the confines of a component in a form of that same Delphi app.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 250 total points
ID: 18780770
yeah i know you're not writting ss, i just wanted to point where problem might be.

another idea, use CreateProcess instead ShellExecute()
theres param lpStartupInfo which is pointer to record: STARTUPINFO
try setting:
  dwX;  dwY;  dwXSize;  dwYSize

maybe this will display ss in place you want with desired size

ziolko.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18781279
I know how to open the CP Screensavers page:
  ShellExecute(Handle, PChar('open'), PChar('rundll32.exe'),
                       PChar( 'shell32.dll,Control_RunDLL desk.cpl,,1'), nil, SW_NORMAL);

How to run a scr in preview mode, I don't think you can do that.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18781413
Apparently, you have to pass the handle of the window where you want to show the preview:

The Preview Mode
As you might have noticed the Preview command has a slight catch. This is the tricky part of the project. We need to show the screen saver in the small preview window in the Display properties dialog. The "/p" command sends a number which is the hWnd of the Display properties dialog. hWnd is a number that is used in Win API to identify each window. The best way to implement the preview mode, is to display the screen saver window as a child to the Display properties. That is what all those API does in the code!

But, it must be the handle of the display properties dialog or you have to create a window with a specific classname.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 250 total points
ID: 18781476
Now, this shows the display properties dialog with the passed screensaver in the preview window:

  ShellExecute(Handle, PChar('open'), PChar('rundll32.exe'),
               PChar( 'desk.cpl,InstallScreenSaver c:\win\system\Flying Windows.scr),
               nil, SW_NORMAL);
0
 
LVL 4

Author Comment

by:David_Ward
ID: 18791333
Hi Eddie,

>>But, it must be the handle of the display properties dialog or you have to create a window with a specific classname.

Where did you get this info?
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18792488
I pieced it together from several sources, including MSDN and some screensaver code from various sources.
0
 
LVL 4

Author Comment

by:David_Ward
ID: 18814813
Thanks guys,

both of you provided useful hints and it is all "good" now.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 18815152
So would you mind posting your final solution as help to others?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now