进入旧版 | 服务项目 | 成功案例 | 联系方式 | 过客留言 | 友情链接
   
设为首页
加入收藏
联系我们
网站首页 | 新闻资讯 | 操作系统 | 办公软件 | 网络软件 | 工具软件 | 媒体动画 | 网页制作 | 网站开发 | 程序开发 | 平面设计
Photoshop视频教程 | Word入门 | Flash入门 | JScript | VBScript | ASP | PHP | ADO | 网页特效 | 3DS MAX6.0命令 | 系统进程
您当前的位置:GOODSGY电脑学习网 -> 程序开发 -> DLEPHI -> 文章内容  
用Delphi开发屏幕保护预览程序

用Delphi开发屏幕保护预览程序 
整理编辑:China ASP

---- 大 家 都 知 道windows 屏 幕 保 护 程 序 的 作 用, 而 且 新 的 屏 幕 保 护 程 序 越 来 越 漂 亮. 如 果 在win95 的 桌 面 右 键 菜 单 选 属 性, 就 弹 出 显 示 器 设 置 界 面, 有 一 个 标 签 是 设 置 屏 幕 保 护 程 序 的.

---- 在 该 页 的 画 面 上, 有 一 个 显 示 器 图 案, 如 果 你 选 择win95 所 带 的 屏 幕 保 护 程 序, 这 个 屏 幕 保 护 程 序 就 会 在 这 个 小' 显 示 器' 上 自 动 运 行, 你 可 以 直 接 看 到 运 行 效 果. 这 功 能 大 大 方 便 了 屏 幕 保 护 程 序 的 选 择, 这 就 是win95 对 屏 幕 保 护 程 序 的 新 增 接 口: 预 览 功 能.

---- 目 前 大 多 数 新 推 出 的 屏 幕 保 护 程 序 都 支 持 这 个 接 口.

---- 屏 幕 保 护 程 序 从 它 的 诞 生 那 时 起, 在 同 一 时 刻 只 能 运 行 一 个, 不 能 多 个 同 时 运 行, 然 而 预 览 接 口 的 推 出, 使 同 时 预 览 多 个 屏 幕 保 护 程 序 成 为 可 能, 本 文 将 向 读 者 介 绍 如 何 用Delphi 开 发 这 样 一 个 程 序.

---- 1. 屏 幕 保 护 预 览 接 口
---- 屏 幕 保 护 预 览 接 口 的 使 用 很 简 单, 这 是 通 过 传 给 屏 幕 保 护 程 序 的 命 令 行 参 数 来 实 现 的, 该 命 令 行 参 数 格 式 为:

---- screensaver.exe /p #####

---- 其 中##### 为 一 个 有 效 的 窗 口 句 柄 的10 进 制 表 示.

---- 这 个 窗 口 我 们 可 以 称 之 为 预 览 窗 口.

---- 实 际 上, 支 持 预 览 接 口 的 屏 幕 保 护 程 序 将 自 己 的 窗 口 创 建 为 预 览 窗 口 的 子 窗 口 来 实 现 预 览 功 能 的.

---- 2. 画 面 布 局
---- 我 们 这 个 程 序 的 窗 口 分 为 3 部 分, 为 倒' 品' 字 形, 上 左 部 分 列 出 所 有 可 用 的 屏 幕 保 护 程 序, 上 右 部 分 列 出 所 有 预 览 的 屏 幕 保 护 程 序, 下 面 当 然 是 预 览 窗 口 了.

---- 用Delphi 实 现 时, 首 先 在Form 里 放2 个TPanel 组 件, Panel1 对 齐 方 式 为 顶 部 对 齐,Panel2 为 撑 满 用 户 区, 再 在Panel1 中 放1 个TFileListBox 组 件 和 一 个TListBox 组 件,FileListBox1 左 对 齐, ListBox1 撑 满 用 户 区.

---- 这 样, FileListBox1 为 屏 幕 保 护 列 表, ListBox1 为 预 览 列 表, Panel2 为 预 览 窗 口.

---- 3. 列 出 屏 幕 保 护 程 序.
---- 将FileListBox1 的Mask 属 性 设 为'*.scr', 这 是 屏 幕 保 护 程 序 的 扩 展 名.

---- 在FormCreate 方 法 中 将FileListBox1.directory 设 为windows 系 统 目 录GetSystemDirectory;

---- 4. 预 览 屏 幕 保 护 程 序.
---- 在FileListBox1DblClick 方 法 中 运 行 该 屏 幕 保 护 程 序, 并 将Panel2 的 窗 口 句 柄 传 给 它.
  ---- WinExec(pchar(FileListBox1.FileName + ' /p ' + inttostr(Panel2.handle)), SW_Show);

---- 运 行 程 序, 怎 么 样? COOL!

---- 5. 增 加 一 些 新 特 性: 隐 藏/ 显 示/ 关 闭.
---- 增 加2 个 函 数: 用 于 更 新ListBox1.
function EnumProc(
        h : HWND  ;// handle of child window
        l : integer// application-defined value
      ): boolean;stdcall;
var
    buf : array[0..255] of char;
begin
  GetWindowText(h, buf, sizeof(buf)- 1);
  if iswindowvisible(h) then
      Form1.ListBox1.items.add(' ' +strpas(buf) + ' : ' + inttostr(h))
  else
      Form1.ListBox1.items.add('-' +strpas(buf) + ' : ' + inttostr(h));
  Result := true;
end;

procedure TForm1.Fresh1;
begin
  ListBox1.clear;
  enumChildwindows(Panel2.handle,
TFNWndEnumProc(@enumproc), 0);
end;

---- 增 加 一 个 弹 出 菜 单Popupmenu1, 3 个 菜 单 项, 'Show, Hide, Close', 将ListBox1.popupmemu 指 向Popupmenu1.
---- Hide 的 处 理 函 数 是:
procedure TForm1.Hide1Click(Sender: TObject);
var
    h : integer;
    s : string;
begin
  if ListBox1.itemindex = -1 then exit;
  s := Listbox1.items[ListBox1.itemindex];
  h := strtoint(copy(s, pos(':', s) + 1, length(s)));
  ShowWindow(h, SW_HIDE);
  Fresh1;
end;

Show 的 处 理 函 数 是:
procedure TForm1.Show1Click(Sender: TObject);
var
    h : integer;
    s : string;
begin
  if ListBox1.itemindex = -1 then exit;
  s := Listbox1.items[ListBox1.itemindex];
  h := strtoint(copy(s, pos(':', s) + 1, length(s)));
  ShowWindow(h, SW_SHOW);
  Fresh1;
end;

Close 的 处 理 函 数 是:
procedure TForm1.Close1Click(Sender: TObject);
var
    h : integer;
    s : string;
begin
  if ListBox1.itemindex = -1 then exit;
  s := Listbox1.items[ListBox1.itemindex];
  h := strtoint(copy(s, pos(':', s) + 1, length(s)));
  PostMessage(h, WM_QUIT, 0, 0);
  Fresh1;
end;

---- 本 程 序 在Delphi 3.0 下 调 试 通 过, 应 该 能 用Delphi 1.0 / 2.0 编 译.

---- 完 整 程 序 如 下:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,  StdCtrls, FileCtrl, ExtCtrls, Menus;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    FileListBox1: TFileListBox;
    ListBox1: TListBox;
    PopupMenu1: TPopupMenu;
    Hide1: TMenuItem;
    Show1: TMenuItem;
    Close1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure FileListBox1DblClick(Sender: TObject);
    procedure Hide1Click(Sender: TObject);
    procedure Show1Click(Sender: TObject);
    procedure Close1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure Fresh1;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
function EnumProc(
    h : HWND  ;// handle of child window
    l : integer// application-defined value
  ): boolean;stdcall;
var buf : array[0..255] of char;
begin
  GetWindowText(h, buf, sizeof(buf)- 1);
  if iswindowvisible(h) then
      Form1.ListBox1.items.add(' ' +strpas(buf) + ' : ' + inttostr(h))
  else
      Form1.ListBox1.items.add('-' +strpas(buf) + ' : ' + inttostr(h));
  Result := true;
end;

procedure TForm1.Fresh1;
begin
  ListBox1.clear;
  enumChildwindows(Panel2.handle, TFNWndEnumProc(@enumproc), 0);
end;

procedure TForm1.FormCreate(Sender: TObject);
var buf : array[0..256] of char;
begin
  GetSystemDirectory(buf, sizeof(buf) - 1);
  FileListBox1.directory := strpas(buf);
  ListBox1.popupmenu := Popupmenu1;
end;

procedure TForm1.FileListBox1DblClick(Sender: TObject);
begin
  WinExec(pchar(FileListBox1.FileName + ' /p ' + inttostr(Panel2.handle)),    SW_Show);
  Fresh1;
end;

procedure TForm1.Hide1Click(Sender: TObject);
var
    h : integer;
    s : string;
begin
  if ListBox1.itemindex = -1 then exit;
  s := Listbox1.items[ListBox1.itemindex];
  h := strtoint(copy(s, pos(':', s) + 1, length(s)));
  ShowWindow(h, SW_HIDE);
  Fresh1;
end;

procedure TForm1.Show1Click(Sender: TObject);
var
    h : integer;
    s : string;
begin
  if ListBox1.itemindex = -1 then exit;
  s := Listbox1.items[ListBox1.itemindex];
  h := strtoint(copy(s, pos(':', s) + 1, length(s)));
  ShowWindow(h, SW_SHOW);
  Fresh1;
end;

procedure TForm1.Close1Click(Sender: TObject);
var
    h : integer;
    s : string;
begin
  if ListBox1.itemindex = -1 then exit;
  s := Listbox1.items[ListBox1.itemindex];
  h := strtoint(copy(s, pos(':', s) + 1, length(s)));
  PostMessage(h, WM_QUIT, 0, 0);
  Fresh1;
end;

end.

在百度中搜索:用Delphi开发屏幕保护预览程序
在Google中搜索:用Delphi开发屏幕保护预览程序
在Yahoo中搜索:用Delphi开发屏幕保护预览程序

收藏到网摘:新浪VIVI 365key 我摘 POCO网摘 博采中心 YouNote 和讯网摘 天天收藏
[] [返回上一页] [打 印] [收 藏]

 相关文章    最新文章
· 写给喜欢用DW编写CSS人的一些建议
· 用DW预定义框架集为网页添加框架
· [图文] 用DW8制作网页中常用的过度效果
· 小技巧:如何用Delphi创建快捷方式
· 利用Dreamweaver批量做web网页
· [组图] 巧用Dreamweaver轻松制作网页页内连..
· javascript通过调用doPostBack回传页面
· [图文] 利用Dreamweaver的插件制作动态下拉..
· [图文] 利用Dreamweaver的插件制作动态下拉..
· [组图] 用Dreamweaver实现全景图浏览效果
 
· 小技巧:如何用Delphi创建快捷方式
· Delphi版模仿熊猫烧香病毒核心源码
· Delphi“判断服务器路径”与“清空日志文..
· 应用程序敏感键的实现
· 用Delphi实现远程屏幕抓取
· 用DEPHI为应用软件建立注册机制
· 利用Hook技术实现键盘监控
· Delphi编程实现Ping操作
· 通用Delphi数据库输入控件DBPanel的实现
· 用Delphi开发屏幕保护预览程序

∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论…]
站内搜索

精彩图文
  网站导航  
操作系统 办公软件 网络软件
Vista Windows2003 WindowsXP Windows2000/NT Windows9X/ME Linux 其他 Word Excel Powerpoint Outlook 金山系列 其他 网页浏览 上传下载 联络聊天 邮件工具 服务器软件 网络辅助
工具软件 媒体动画 网页制作
系统工具 媒体工具 压缩工具 图文处理 文件管理 其他 3DMAX Authorware Director Maya 视频处理 其他 Flash Dreamweaver FireWorks FrontPage LiveMotion Golive HTML/CSS 其它
网站开发 平面设计 程序设计
ASP JSP PHP CGI JavaScript VBScript XML/SOAP Web服务器 Photoshop PhotoImpact CorelDraw Illustrator Freehand 设计欣赏 其他 VB VC .NET C/C++ DELPHI JAVA

冀ICP备05019428号
Copyright © 2004-2008 电脑学习网 Inc.All rights reserved.
TEL:13832340607
QQ:39873155
E_Mail:goodsgy(#)hotmail.com   (把(#)替换成@)
MSN:goodsgy(#)hotmail.com   (把(#)替换成@)