看破天惊的小程序就明白了。。。[
]
main.pas单元
--------------------
{********************************************************
*** ***
*** 破天惊工作室
*** 名称:嵌入窗体之桌面嵌入
*** 日期:12.9.2004
*** 环境
elphi6+WinXP
*** 作者:破天惊
*** E-Mail:Tresss@sohu.com
*** HomePage:http://tresss.com
***
*** 说明:
*** ***
*********************************************************}
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TFrmMain = class(TForm)
Btn1: TButton;
Timer1: TTimer;
Edt1: TEdit;
BtnOwner: TButton;
Label1: TLabel;
Btn2: TButton;
Edt2: TEdit;
Label2: TLabel;
Btn3: TButton;
Edt3: TEdit;
Label3: TLabel;
BtnRnd: TButton;
procedure Timer1Timer(Sender: TObject);
procedure BtnOwnerClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Btn1Click(Sender: TObject);
procedure Btn2Click(Sender: TObject);
procedure Btn3Click(Sender: TObject);
procedure BtnRndClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmMain: TFrmMain;
TmpHandle:THandle;
implementation
{$R *.dfm}
procedure TFrmMain.Timer1Timer(Sender: TObject);
begin
FrmMain.ParentWindow:=0;
end;
procedure TFrmMain.BtnOwnerClick(Sender: TObject);
begin
FrmMain.ParentWindow:=0;
end;
procedure TFrmMain.FormCreate(Sender: TObject);
begin
TmpHandle:=FindWindow('Progman',Nil);
If TmpHandle<>0 Then
Begin
Edt3.Text:=IntToStr(TmpHandle);
TmpHandle:=GetWindow(TmpHandle,GW_CHILD);
Edt2.Text:=IntToStr(TmpHandle);
TmpHandle:=GetWindow(TmpHandle,GW_CHILD);
Edt1.Text:=IntToStr(TmpHandle);
End
Else
ShowMessage('找不到桌面,可能是Explorer已结束!');
end;
procedure TFrmMain.Btn1Click(Sender: TObject);
begin
If Edt1.Text<>'' Then
Begin
FrmMain.ParentWindow:=StrToInt(Edt1.Text);
BringWindowToTop(FrmMain.Handle);
End;
end;
procedure TFrmMain.Btn2Click(Sender: TObject);
begin
If Edt2.Text<>'' Then
Begin
FrmMain.ParentWindow:=StrToInt(Edt2.Text);
BringWindowToTop(FrmMain.Handle);
End;
end;
procedure TFrmMain.Btn3Click(Sender: TObject);
begin
If Edt3.Text<>'' Then
Begin
FrmMain.ParentWindow:=StrToInt(Edt3.Text);
BringWindowToTop(FrmMain.Handle);
End;
end;
procedure TFrmMain.BtnRndClick(Sender: TObject);
begin
If (Edt3.Text<>'') and (Edt2.Text<>'') Then
Begin
FrmMain.ParentWindow:=StrToInt(Edt3.Text);
BringWindowToTop(FrmMain.Handle);
FrmMain.Left:=0;
MoveWindow(StrToInt(Edt2.Text),170,0,screen.Width-170,screen.Height,False);
End;
end;
end.
main.dfm窗体
----------------------------
object FrmMain: TFrmMain
Left = 324
Top = 132
Width = 225
Height = 293
Caption = '嵌入桌面'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 9
Top = 9
Width = 125
Height = 13
AutoSize = False
Caption = '第一层:'
end
object Label2: TLabel
Left = 9
Top = 66
Width = 125
Height = 13
AutoSize = False
Caption = '第二层:'
end
object Label3: TLabel
Left = 9
Top = 123
Width = 125
Height = 13
AutoSize = False
Caption = '第三层:'
end
object Btn1: TButton
Left = 113
Top = 28
Width = 68
Height = 30
Caption = '嵌入'
TabOrder = 0
OnClick = Btn1Click
end
object Edt1: TEdit
Left = 9
Top = 28
Width = 96
Height = 21
ImeName = '紫光拼音输入法'
TabOrder = 1
Text = 'http://tresss.com'
end
object BtnOwner: TButton
Left = 9
Top = 217
Width = 172
Height = 30
Caption = '取消嵌入'
TabOrder = 2
OnClick = BtnOwnerClick
end
object Btn2: TButton
Left = 113
Top = 85
Width = 68
Height = 30
Caption = '嵌入'
TabOrder = 3
OnClick = Btn2Click
end
object Edt2: TEdit
Left = 9
Top = 85
Width = 96
Height = 21
ImeName = '紫光拼音输入法'
TabOrder = 4
Text = 'http://tresss.com'
end
object Btn3: TButton
Left = 113
Top = 142
Width = 68
Height = 29
Caption = '嵌入'
TabOrder = 5
OnClick = Btn3Click
end
object Edt3: TEdit
Left = 9
Top = 142
Width = 96
Height = 21
ImeName = '紫光拼音输入法'
TabOrder = 6
Text = 'http://tresss.com'
end
object BtnRnd: TButton
Left = 9
Top = 180
Width = 172
Height = 29
Caption = '嵌入并限制桌面大小'
TabOrder = 7
OnClick = BtnRndClick
end
object Timer1: TTimer
Interval = 20000
OnTimer = Timer1Timer
Left = 56
Top = 96
end
end