关于vb做透明窗体的问题。实在看不懂它为什么这样!哪位哥哥帮我看下这几句是啥意思

PrivateDeclareFunctionGetWindowRectLib"user32"(ByValhWndAs_Long,lpRECTAsRECT)AsLongPr... 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

Public Sub MakeTransparent(frm As Form)
Dim rctClient As RECT, rctFrame As RECT
Dim hClient As Long, hFrame As Long

'获得窗口矩形区域
GetWindowRect frm.hWnd, rctFrame 'rctFrame窗体矩形的四个点
GetClientRect frm.hWnd, rctClient '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, 2

SetWindowRgn frm.hWnd, hFrame, True
End Sub

Private Sub Form_Resize()
MakeTransparent Me
End Sub
我是个初学者。这是我第一次接触API函数。希望能看不懂。不然打击自信心。
展开
 我来答
百度网友2ca1c0f24
2010-10-12 · TA获得超过2036个赞
知道大有可为答主
回答量:4364
采纳率:0%
帮助的人:3434万
展开全部
关于vb做透明窗体的问题。
代码太繁杂,其实不用这样,有简单的,而且容易理解:

下面是声明API函数:
Option Explicit
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, _
ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
ByVal hObject As Long) As Long

Private Sub Form_Load()
Dim BAST '定义一个变量
Me.AutoRedraw = True '将窗体的 AutoRedraw 属性设置为 True (设置一个永久性位图的输出)
BAST = CreateCompatibleBitmap(Me.hdc, 0, 0) '使用CreateCompatibleBitmap 函数
SelectObject Me.hdc, BAST '使用 SelectObject 函数,设置窗体透明
'OK!窗体已经透明了!!
End Sub
详细请查看我的空间:http://hi.baidu.com/xnzhrx/blog/item/55b175b4b2f4217c8bd4b291.html
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式