Link to home
Start Free TrialLog in
Avatar of David_Ward
David_WardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

preview screen saver

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 ....

Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

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.
Avatar of David_Ward

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
I pieced it together from several sources, including MSDN and some screensaver code from various sources.
Thanks guys,

both of you provided useful hints and it is all "good" now.
So would you mind posting your final solution as help to others?