1.设置密码保护<br>见我以前的回答:<br>http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=130130<br><br>2.小窗口预览:<br>这个问题我曾经回答过,但找不到了,再把代码写一遍,有些变量是我自己<br>程序里面的,你自己斟酌...<br><br>当paramstr[1]的前2个字符为'/P',则需要在小窗口里面预览<br><br>//先定义一个函数,用来处理窗口消息<br>function MyWndProc(Wnd:HWnd; Msg:Integer; wParam:Word; lParam:Integer):Integer; far; stdcall;<br>begin<br> //如果需要关闭,则close<br> if (Msg=WM_DESTROY) or (Msg=WM_CLOSE) then<br> frmscreensaver.close<br> else<br> if Msg=WM_PAINT then<br> begin<br> //如果需要刷新,则画canvas....<br> end;<br> //调用默认WndProc<br> DefWindowProc(Wnd,Msg,wParam,lParam);<br>end;<br><br>procedure ExecPreview;<br>var WndClass:TWndClass;<br> Atom:TAtom;<br> DC:hDC;<br> MyWnd:hWnd;<br> Msg:TMsg;<br>begin <br> //第二个参数就是窗口句柄<br> ParamHandle:=StrToInt(ParamStr(2));<br> //定义一个窗口class<br> with WndClass do begin<br> style:=CS_PARENTDC;<br> lpfnWndProc:=@MyWndProc; //该类的WndProc指向自己定义的MyWndProc<br> cbClsExtra:=0;<br> cbWndExtra:=0;<br> hIcon:=0;<br> hCursor:=0;<br> hbrBackground:=0;<br> lpszMenuName:=NIL;<br> lpszClassName:='ScreenSaverClass';<br> end;<br> WndClass.hInstance:=hInstance;<br> //注册该class<br> Atom:=Windows.RegisterClass(WndClass);<br> //得到父窗口信息<br> GetWindowRect(ParamHandle, PrevRect);<br> pw:=(prevrect.right-prevrect.left);<br> ph:=(prevrect.bottom-prevrect.top);<br> Staticrect:=GetStretchRect(frmscreensaver.img0.width,frmscreensaver.img0.height);<br><br> PrevRect.Right:=PrevRect.Right-PrevRect.Left;<br> PrevRect.Bottom:=PrevRect.Bottom-PrevRect.Top;<br> PrevRect.Left:=0;<br> PrevRect.Top:=0;<br> //创建该父窗口的一个字窗口,将用来显示屏保画面<br> MyWnd:=CreateWindow('ScreenSaverClass','Window of the world',WS_CHILD or<br> WS_DISABLED or WS_VISIBLE,0,0,PrevRect.Right,PrevRect.Bottom,<br> ParamHandle,0,hInstance,nil);<br> //得到新建窗口的DC<br> DC:=GetDC(MyWnd);<br> //定义一个全局的canvas,用来在上面draw画面<br> PreviewCanvas:=TCanvas.Create;<br> PreviewCanvas.Handle:=DC; //将canvas属于该窗口<br> PreviewCanvas.brush.Color:=clblack;<br> PreviewCanvas.fillrect(prevrect);<br> logomode:=true;<br> PreviewCanvas.StretchDraw(staticrect,frmscreensaver.img0.picture.graphic);<br><br> //开始消息循环,所有消息将送到MyWndProc处理<br> while GetMessage(Msg,0,0,0) do begin<br> TranslateMessage(Msg);<br> DispatchMessage(Msg);<br> end;<br>end;<br><br><br>3.设置选项<br>当paramstr[1]的前2个字符为'/C',则需要进行设置,show你自己的setup form即可.<br><br>