麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > Delphi > 正文

用Delphi開發屏幕保護預覽程序

2019-11-18 19:00:31
字體:
來源:轉載
供稿:網友
用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.



Copyright © 上海聚聲計算機系統工程有限責任公司 1999-2000, All Rights Reserved

上一篇:"Delphi之完全漢語"終結版

下一篇:通用Delphi數據庫輸入控件DBPanel的實現

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 亚洲日本欧美 | 5xsq在线视频 | 免费一级毛片在线播放视频 | 久久精品女人天堂av | h视频免费看 | 九九热色 | 免看黄大片aa | 久久第四色 | 国产精品成人av片免费看最爱 | 国产高潮国产高潮久久久91 | 黄视频网站免费观看 | 亚洲最新色 | 中文国产在线视频 | 极品xxxx欧美一区二区 | 色屁屁xxxxⅹ免费视频 | 国产精品视频中文字幕 | 久久精品探花 | 九九热视频在线免费观看 | 99视频有精品 | 久久99精品久久久久久秒播放器 | 国产99久久久久 | 国产 视频 一区二区 | 色婷婷久久久亚洲一区二区三区 | 亚洲视频在线免费看 | 国产成人精品免费视频大全最热 | 成人超碰| 亚洲精中文字幕二区三区 | 91美女视频在线观看 | 久草在线最新免费 | 亚洲电影在线播放 | 日本一级黄色大片 | 亚洲最新无码中文字幕久久 | 综合网天天射 | 全黄性性激高免费视频 | 国产女厕一区二区三区在线视 | 日日草天天干 | 国产精品剧情一区二区三区 | 国产精品久久久不卡 | 一级免费黄色免费片 | 羞羞答答视频 | 欧美日韩亚洲国产精品 |