Link to home
Start Free TrialLog in
Avatar of titz
titz

asked on

screensaver

I have written a screensaver in delphi3. It works well, but I have a question.
In the screensaver-configuration-menu under WIN95/NT4.0 is shown a small monitor. How can I show a picture there while my screensaver is configured ?
Avatar of rigansen
rigansen

Are you running out of points ??  :)

I wrote a screensaver in delphi 2.0 which I think should work fine using Delphi3. As there's a general procedure that is called every time you need to deal with the password, there's is one for handling the preview window : ExecPreview.

this code is not exactly mine, can't remember where I took it from...

//This executes the preview window,and goes into a message loop to keep it running
procedure ExecPreview;
var PreviewCanvas:TCanvas;
    WndClass:TWndClass;
    Atom:TAtom;
    DC:hDC;
    MyWnd:hWnd;
    Msg:TMsg;
begin //create a new window class
  PreviewMode:=True;
  with WndClass do begin
    style:=CS_PARENTDC;
    lpfnWndProc:=@MyWndProc;
    cbClsExtra:=0;
    cbWndExtra:=0;
    hIcon:=0;
    hCursor:=0;
    hbrBackground:=0;
    lpszMenuName:=NIL;
    lpszClassName:='Delphi2ScreenSaverPreview';
  end;
  WndClass.hInstance:=hInstance;
  Atom:=Windows.RegisterClass(WndClass);
  //get some info on parent window
  GetWindowRect(ParamHandle, PrevRect);
  PrevRect.Right:=PrevRect.Right-PrevRect.Left;
  PrevRect.Bottom:=PrevRect.Bottom-PrevRect.Top;
  PrevRect.Left:=0;
  PrevRect.Top:=0;
  //and now create the window as child of the window given in ParamHandle
  MyWnd:=CreateWindow('Delphi2ScreenSaverPreview','FunSaver',WS_CHILD or
     WS_DISABLED or WS_VISIBLE,0,0,PrevRect.Right,PrevRect.Bottom,
     ParamHandle,0,hInstance,nil);
  //get the DC for the new created window
  DC:=GetDC(MyWnd);
  PreviewCanvas:=TCanvas.Create;
  PreviewCanvas.Handle:=DC;
  MyThread:=TSaverThread.Create(PreviewCanvas,PrevRect);
  //and now do the message loop, I think I can't use any predifined loop here
  while GetMessage(Msg,0,0,0) do begin
    TranslateMessage(Msg);
    DispatchMessage(Msg);
  end;
  MyThread.Terminate; //I don't care about other resources here, as my app
  PreviewCanvas.Free; //terminates immediately and NT/Win95 cleans up
end;


hope this shows you the way to go...

regards, rigansen.

Avatar of titz

ASKER

What is about the variable "ParmHandle" ??
Where did you get it from ??

ASKER CERTIFIED SOLUTION
Avatar of rigansen
rigansen

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