vb6.0中如何让图片的白色背景透明
我想在vb6.0中的image或者picture中放一张图片,但是图片大部分是白色背景,而其中一部分不是白色,我想让白色部分透明,而只要不是白色的那部分,vb中应该怎样实...
我想在vb6.0中的image 或者picture 中放一张图片,但是图片大部分是白色背景,而其中一部分不是白色,我想让白色部分透明,而只要不是白色的那部分, vb中应该怎样实现?拜托各位了
展开
1个回答
2013-05-14
展开全部
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1 Private Sub Form_Load()
Dim rtn As Long
BorderStyler = 0
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, VBWhite, 0, LWA_COLORKEYEnd Sub '上一行的VBWhite也可以写成其他形式如 RGB(255,255,255) 或 #FFFFFF 都表示颜色,即你要设置为透明的颜色'这代码可能不是太好,你试试看符不符合你口味
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const LWA_COLORKEY = &H1 Private Sub Form_Load()
Dim rtn As Long
BorderStyler = 0
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, VBWhite, 0, LWA_COLORKEYEnd Sub '上一行的VBWhite也可以写成其他形式如 RGB(255,255,255) 或 #FFFFFF 都表示颜色,即你要设置为透明的颜色'这代码可能不是太好,你试试看符不符合你口味
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询