| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 462 人关注过本帖
标题:[求助]关于透明怎么做?
只看楼主 加入收藏
fx520pl
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-11-26
收藏
 问题点数:0 回复次数:3 
[求助]关于透明怎么做?
在文本筐里 除了输入的内容以外(因为有背景图片 要求只要文字部分显示) 能做成透明的吗
搜索更多相关主题的帖子: 图片 
2006-12-03 11:02
bestfeng
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:179
专家分:0
注 册:2006-10-31
收藏
得分:0 

>>步骤1----建立新工程。
>>步骤2----编写如下代码:

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)
GetFrameClientRgn frm
SetWindowRgn frm.hWnd, hFrame, 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

>>步骤3----编译运行,是不是看到效果了

2006-12-03 11:08
fx520pl
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-11-26
收藏
得分:0 
还是不明白 怎么用那些代码?
发个图给老大看看
我要文本筐的背景色变成透明 没有最好了!
希望老大 能说明白点
我刚学 还懂的不多! 见谅!
图片附件: 游客没有浏览图片的权限,请 登录注册

[此贴子已经被作者于2006-12-3 11:31:33编辑过]

2006-12-03 11:31
fx520pl
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-11-26
收藏
得分:0 

已经解决

2006-12-03 14:44
快速回复:[求助]关于透明怎么做?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030466 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved