main.pas
上传用户:hlshsb
上传日期:2007-04-04
资源大小:193k
文件大小:3k
源码类别:

系统/网络安全

开发平台:

Delphi

  1. {********************************************************
  2. ***                                                   ***
  3. ***                        破天惊工作室
  4. ***  名称:嵌入窗体之桌面嵌入
  5. ***  日期:12.9.2004
  6. ***  环境:Delphi6+WinXP
  7. ***  作者:破天惊
  8. ***  E-Mail:Tresss@sohu.com
  9. ***  HomePage:http://tresss.com
  10. ***
  11. ***  说明:
  12. ***                                                   ***
  13. *********************************************************}
  14. unit main;
  15. interface
  16. uses
  17.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  18.   Dialogs, StdCtrls, ExtCtrls;
  19. type
  20.   TFrmMain = class(TForm)
  21.     Btn1: TButton;
  22.     Timer1: TTimer;
  23.     Edt1: TEdit;
  24.     BtnOwner: TButton;
  25.     Label1: TLabel;
  26.     Btn2: TButton;
  27.     Edt2: TEdit;
  28.     Label2: TLabel;
  29.     Btn3: TButton;
  30.     Edt3: TEdit;
  31.     Label3: TLabel;
  32.     BtnRnd: TButton;
  33.     procedure Timer1Timer(Sender: TObject);
  34.     procedure BtnOwnerClick(Sender: TObject);
  35.     procedure FormCreate(Sender: TObject);
  36.     procedure Btn1Click(Sender: TObject);
  37.     procedure Btn2Click(Sender: TObject);
  38.     procedure Btn3Click(Sender: TObject);
  39.     procedure BtnRndClick(Sender: TObject);
  40.   private
  41.     { Private declarations }
  42.   public
  43.     { Public declarations }
  44.   end;
  45. var
  46.   FrmMain: TFrmMain;
  47.   TmpHandle:THandle;
  48. implementation
  49. {$R *.dfm}
  50. procedure TFrmMain.Timer1Timer(Sender: TObject);
  51. begin
  52.   FrmMain.ParentWindow:=0;
  53. end;
  54. procedure TFrmMain.BtnOwnerClick(Sender: TObject);
  55. begin
  56.   FrmMain.ParentWindow:=0;
  57. end;
  58. procedure TFrmMain.FormCreate(Sender: TObject);
  59. begin
  60.   TmpHandle:=FindWindow('Progman',Nil);
  61.   If TmpHandle<>0 Then
  62.   Begin
  63.     Edt3.Text:=IntToStr(TmpHandle);
  64.     TmpHandle:=GetWindow(TmpHandle,GW_CHILD);
  65.     Edt2.Text:=IntToStr(TmpHandle);
  66.     TmpHandle:=GetWindow(TmpHandle,GW_CHILD);
  67.     Edt1.Text:=IntToStr(TmpHandle);
  68.   End
  69.   Else
  70.     ShowMessage('找不到桌面,可能是Explorer已结束!');
  71. end;
  72. procedure TFrmMain.Btn1Click(Sender: TObject);
  73. begin
  74.   If Edt1.Text<>'' Then
  75.   Begin
  76.     FrmMain.ParentWindow:=StrToInt(Edt1.Text);
  77.     BringWindowToTop(FrmMain.Handle);
  78.   End;
  79. end;
  80. procedure TFrmMain.Btn2Click(Sender: TObject);
  81. begin
  82.   If Edt2.Text<>'' Then
  83.   Begin
  84.     FrmMain.ParentWindow:=StrToInt(Edt2.Text);
  85.     BringWindowToTop(FrmMain.Handle);
  86.   End;
  87. end;
  88. procedure TFrmMain.Btn3Click(Sender: TObject);
  89. begin
  90.   If Edt3.Text<>'' Then
  91.   Begin
  92.     FrmMain.ParentWindow:=StrToInt(Edt3.Text);
  93.     BringWindowToTop(FrmMain.Handle);
  94.   End;
  95. end;
  96. procedure TFrmMain.BtnRndClick(Sender: TObject);
  97. begin
  98.   If (Edt3.Text<>'') and (Edt2.Text<>'') Then
  99.   Begin
  100.     FrmMain.ParentWindow:=StrToInt(Edt3.Text);
  101.     BringWindowToTop(FrmMain.Handle);
  102.     FrmMain.Left:=0;
  103.     MoveWindow(StrToInt(Edt2.Text),170,0,screen.Width-170,screen.Height,False);
  104.   End; 
  105. end;
  106. end.