回复 18 楼 kongxc
透明窗口嵌入桌面的实例见过不少。
用VFP写代码,试了怪招应该还是可行:
* 将透明窗口嵌入桌面
_SCREEN.Visible = .F.
SET TALK OFF
CLEAR
DECLARE LONG GetDesktopWindow IN User32
DECLARE LONG FindWindowEx IN User32 LONG, LONG, STRING@, STRING@
DECLARE LONG SetParent IN User32 LONG, LONG
DECLARE LONG SetWindowLong IN user32 LONG, LONG, LONG
DECLARE LONG GetWindowLong IN user32 LONG, LONG
DECLARE LONG SetLayeredWindowAttributes IN user32 LONG, LONG, LONG, LONG
DECLARE LONG SetFocus IN user32 LONG
PUBLIC oForm1, oForm2
oForm1 = NEWOBJECT("Form1")
oForm2 = NEWOBJECT("Form2")
oForm1.Show
oForm2.Show
READ EVENTS
CLEAR DLLS
_SCREEN.Visible = .T.
RETURN
DEFINE CLASS Form1 As Form
Height = 300
Width
= 400
ShowWindow = 2
WindowType = 1
AutoCenter = .T.
BorderStyle = 0
TitleBar = 0
hParent = 0
PROCEDURE Load
*SetWindowLong(this.hWnd, -20, 0x80000)
SetWindowLong(this.hWnd, -20, BITOR(GetWindowLong(this.hWnd, -20), 0x80000))
ENDPROC
PROCEDURE Init
hDesktop = FindWindowEx(GetDesktopWindow(), 0, "Progman", NULL)
hDesktop = FindWindowEx(hDesktop, 0, "SHELLDLL_DefView", NULL)
hDesktop = FindWindowEx(hDesktop, 0, "SysListView32", NULL)
this.hParent = SetParent(this.hWnd, hDesktop)
ENDPROC
PROCEDURE Activate
IF EMPTY(this.Tag)
this.Tag = "1"
LOCAL n透明度
n透明度 = 125
&& 0--255
SetLayeredWindowAttributes(thisform.HWnd, 0, n透明度, 2)
&& 透明背景颜色值无效,透明度有效。
ELSE
SetFocus(oForm2.hWnd)
ENDIF
ENDPROC
PROCEDURE Destroy
SetParent(this.hWnd, this.hParent)
CLEAR EVENTS
ENDPROC
ENDDEFINE
DEFINE CLASS Form2 As Form
Height = 300
Width
= 400
ShowWindow = 2
WindowType = 1
AutoCenter = .T.
BorderStyle = 0
TitleBar = 0
hParent = 0
Add Object Command1 As CommandButton WITH Top=100, Left=100, Width=80, Height=30, Caption="关闭"
PROCEDURE Load
*SetWindowLong(this.hWnd, -20, 0x80000)
SetWindowLong(this.hWnd, -20, BITOR(GetWindowLong(this.hWnd, -20), 0x80000))
ENDPROC
PROCEDURE Init
hDesktop = FindWindowEx(GetDesktopWindow(), 0, "Progman", NULL)
hDesktop = FindWindowEx(hDesktop, 0, "SHELLDLL_DefView", NULL)
hDesktop = FindWindowEx(hDesktop, 0, "SysListView32", NULL)
this.hParent = SetParent(this.hWnd, hDesktop)
ENDPROC
PROCEDURE Activate
IF EMPTY(this.Tag)
this.Tag = "1"
SetLayeredWindowAttributes(this.HWnd, this.BackColor, 0, 1)
ENDIF
ENDPROC
PROCEDURE Moved
oForm1.Top = this.Top
oForm1.Left = this.Left
ENDPROC
PROCEDURE Destroy
SetParent(this.hWnd, this.hParent)
oForm1.Release
ENDPROC
PROCEDURE Command1.Click
thisform.Release
ENDPROC
ENDDEFINE