要用什么代码可以实现?
Private Declare Function SetLayeredWindowAttributes Lib "User32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Public Sub NTSetfrmRgn()
'-------------------------------------------------
' 确定窗体形状及透明度
' Color 取得0,0处象素的颜色,即要裁减的区域的颜色
' SetLayeredWindowAttributes 设置透明度及窗体形状
'-------------------------------------------------
Dim WindowExs As Long
Set FormPic = LoadPicture(FormFile) '"pic\test.bmp")
FClock.Picture = FormPic
FClock.Height = ScaleY(FormPic.Height, vbHimetric, vbTwips) '把图像大小的Himetric(0.01毫米)单位变为twips单位
FClock.Width = ScaleX(FormPic.Width, vbHimetric, vbTwips)
Color = GetPixel(FClock.hdc, 0, 0) ' 这里是取图片左上角的象素颜色作为去除色,当然如果只做透明就不用!
WindowExs = GetWindowLong(FClock.hwnd, GWL_EXSTYLE)
WindowExs = WindowExs Or WS_EX_LAYERED
SetWindowLong FClock.hwnd, GWL_EXSTYLE, WindowExs
SetLayeredWindowAttributes FClock.hwnd, Color, 255, LWA_ALPHA Or LWA_COLORKEY '255就是透明度,可以调整!!
End Sub