Chinaunix首页 | 论坛 | 博客
  • 博客访问: 381478
  • 博文数量: 715
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 5005
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 14:46
文章分类

全部博文(715)

文章存档

2011年(1)

2008年(714)

我的朋友

分类:

2008-10-13 16:33:26

Option Explicit
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRECT As RECT) As Long

Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRECT As RECT) As Long

Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long

Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long

Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long

Const RGN_XOR = 3

Private Type POINTAPI

x As Long

Y As Long

End Type

Private Type RECT

Left As Long

Top As Long

Right As Long

Bottom As Long

End Type

Private rctClient As RECT, rctFrame As RECT

Private hClient As Long, hFrame As Long

Public Sub MakeTransparent(frm As Form)
Image1.Visible = False
GetFrameClientRgn frm

SetWindowRgn frm.hWnd, hFrame, True
Image1.Visible = True
End Sub

Private Sub GetFrameClientRgn(frm As Form)

GetWindowRect frm.hWnd, rctFrame

GetClientRect frm.hWnd, rctClient

'?怠?痻?Г?????辊Г?

Dim lpTL As POINTAPI, lpBR As POINTAPI

lpTL.x = rctFrame.Left

lpTL.Y = rctFrame.Top

lpBR.x = rctFrame.Right

lpBR.Y = rctFrame.Bottom

ScreenToClient frm.hWnd, lpTL

ScreenToClient frm.hWnd, lpBR

rctFrame.Left = lpTL.x

rctFrame.Top = lpTL.Y

rctFrame.Right = lpBR.x

rctFrame.Bottom = lpBR.Y

rctClient.Left = Abs(rctFrame.Left)

rctClient.Top = Abs(rctFrame.Top)

rctClient.Right = rctClient.Right + Abs(rctFrame.Left)

rctClient.Bottom = rctClient.Bottom + Abs(rctFrame.Top)

rctFrame.Right = rctFrame.Right + Abs(rctFrame.Left)

rctFrame.Bottom = rctFrame.Bottom + Abs(rctFrame.Top)

rctFrame.Top = 0

rctFrame.Left = 0

hClient = CreateRectRgn(rctClient.Left, rctClient.Top, rctClient.Right, rctClient.Bottom)

hFrame = CreateRectRgn(rctFrame.Left, rctFrame.Top, rctFrame.Right, rctFrame.Bottom)

CombineRgn hFrame, hClient, hFrame, RGN_XOR

End Sub

Private Sub Form_Resize()
MakeTransparent Me
End Sub

 

posted on 2005-09-02 11:39 木子的blog 阅读(925)   

--------------------next---------------------

阅读(242) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~