Solved

Delphi Programming question

Posted on 1997-07-09
6
158 Views
Last Modified: 2010-04-06
null
0
Comment
Question by:mobius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Expert Comment

by:CyberWolf
ID: 1338504
Hi Catherine,

Here is a (short) explanation:

Screensavers are executed by Windows in two ways: either when an interval of inactivity causes Windows to execute the screensaver, or when it is being configured in Control Panel. In Windows 95, screensavers have four modes of execution and these are selected by command line parameters:

1. Preview mode.

When you select the saver in Control Panel, Windows sends two parameters, /p HWND, to select preview mode and to pass the handle of the preview window.

2. Configuration mode.

When you click Settings, Windows sends a parameter, /c, to select configuration mode. The saver responds by presenting a configuration dialogue.

3. Password mode.

When you click to change the password, Windows sends two parameters, /a HWND, to select password mode and to pass the handle of the parent window for your password dialogue.

4. Start mode.

When you click Preview, or when the saver is called for real, Windows sends a parameter, /s, to select start mode.

The application should check the command line parameters to see whether it should draw in the preview window or present a configuration dialogue. Screensaver security is treated in different ways by Windows 95 and Windows NT. Under Windows 95, most screensavers call the Windows Master Password Router. This is a DLL called MPR.DLL which exports password functions like PwdChangePassword. They are usually called via another DLL, PASSWORD.CPL, which works as an extension to the Control Panel. Neither of these libraries are fully documented in the Windows SDK, but some have worked out how to use them. The alternative is to implement your own password checking and throw up your own password dialogue when the saver is called in password mode. Windows NT is different. Passwords for NT screensavers are the same as those used for logging on to Windows. The Control Panel marks a registry entry to indicate a secure screensaver:
HKEY_CURRENT_USER\Control
Panel\Desktop\ScreenSaverIsSecure
Finally, there is the matter of the description line. Confusingly, Microsoft has devised three ways of identifying this. Originally, it was the module description entry, which had to be of the form
“SCRNSAVE : My Description.”
Under Windows 95 and NT it became a resource string with an ID of 1 — and yes, Delphi can use standard Windows resources. This is the documented way; but actually, Windows 95 does not use it. It simply uses the long filename, less the .SCR extension. By the way, Windows will find any screensaver, identified by a .SCR extension, in the Windows or System folders, so at least installation is easy.

I hope this will help you and that your problems will be solved !

See ya,

CyberWolf  
0
 

Author Comment

by:mobius
ID: 1338505
Thanks Cyberwolf.

I'm not rejecting your reply because I don't like it (which I do, I think it's very good indeed!), but simply to keep the question 'open'. BTW, how long is the long explanation?

I didn't know about the other parameter options, so now I can build them into the main form, but as my savers work by having a full-screen-size form on which everything is drawn, how can this be re-directed to the handle of the preview window so the output appears there? I admit this isn too great an issue for me as I'm more interested in getting the savers to work properly to begin with, but it would be nice

My final question: what is the resource string you're referring to in the last paragraph and where is it located in the .dpr/.pas?

Thanks,
Catherine

0
 
LVL 1

Expert Comment

by:kevinb062397
ID: 1338506
There is a good example at:
http://carbohyd.siobc.ras.ru/torry/samples/weber.zip

It might help.


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
CyberWolf earned 0 total points
ID: 1338507
Hi Catherine,

This time a very very short explanation:

To use the hwnd parameter for the preview, I recommend not to use a TForm. It's a large dcu (150 K) entirely linked to your executable. If you use the windows API, everything you need will be done with less than 15 K. (Instead of 150K !!)

Using the windows API seems a bit difficult in the beginning, but I can tell you that it's easier than it sounds !

Of course, you can use some trick to overcome this problem. You can simply paint a static bitmap on the small preview window. (Just retrieve the hdc and associate it with a TCanvas handle. Then simply draw a bitmap on it as you usualy do !) The use of a TForm for the full screen window will no longer be a problem.

Ok, now your question about the resource string.

Each delphi file is linked with a file that has the same name as the original but with the extension turned into 'res'. (Ex.:main.pas main.res) 'Res' stands for resource. However, these resource files are already compiled. (They can hold bitmaps,videos,version information,... and also strings !)

You can also create your own resource files. (.rc files that you compile with brcc32.exe located in the bin dir) You can use a simple text editor such as notepad to create them. Here is an example of what you should need:

myscreensavercustomresource.rc:

   stringtable
   begin
     1,"Replace this in order to get a decent name for your screensaver"
   end

generating myscreensavercustomresource.res --> brcc32 -r myscreensavercustomresource.rc

linking with delphi project --> add the following line to your dpr : {$R myscreensavercustomresource.res}

(I don't want you to know how the long explanation can be ... so I won't cover this more in detail, but if you want some additional information on how to write rc files, simply ask and I'll be there for you ...)

See ya,

CyberWolf

0
 

Author Comment

by:mobius
ID: 1338508
Thanks Cyberwolf.
As you probably realised I'm still quite new to all this, and yes, everything I've done so far is on a TForm. The resource string description has gone straight over my head at the moment, but it will probably make sense once I've tried it.
I'm still having trouble with the /c option, as even though it's parsed correctly and works as a parameter from file manager to display the saver's controls, as soon as the .scr file is accessed by desktop\screensavers\configure, all that happens is the screen blinks. There's obviously a fundamental flaw in my program somewhere, as everyone else's work OK, but you've been very helpful and I don't want to impose too much.
Thanks again for the help,
Ccatherine.
0
 

Expert Comment

by:CyberWolf
ID: 1338509
Hi Catherine,

It was a pleasure to me to help you. If you want, I have some examples of screensavers and a help file which explains screen savers in detail. I will send them to your mailbox if you give me your e-mail address. If you want I can also explain you how to deal with resources more in detail ?

See ya,

CyberWolf (cyberwolf_cool@hotmail.com)

P.S.:Please, send me a copy of your screensaver when it's finished !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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