这是一个很奇特的功能,首先要让Form变透明,接着,放一张背景透明的.gif图进来,如此,这变成一个透明的form,上面有许多Button,且图不会是一个方形,而会让图的背景透通。但有一点要注意,这种透明的Form不可以移动,否则一移就会发现它似乎不是透明的,这个很不好解释,建议您一开始设定Form的BorderStyle = 2 大小可变可移动,而去移动与更动小大,便可以知道。因此,在设计阶段时,一定要设BorderStyle = 0 没有框线,这样子您的Form才不会有问题。 首先我使用以下的程式码令Form变透明 注:有适当的软体(如 MS PhotEditor)可以将图变成背景透通(引用 老怪之言) Me.AutoRedraw = True hBitmap = CreateCompatibleBitmap(Me.hdc, 0, 0) SelectObject Me.hdc, hBitmap Me.Refresh 而透明的图形呢,那需要那一种背景透通性的.GIF档,在Form上放一个Image Control,将 图放到Image Control,那就OK了注释:需一个Image Control , 一个Command1 Option Explicit Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long Private hBitmap As Long Private Sub Command1_Click() Unload Me End Sub Private Sub Form_Load() 注释:事先请设form的BorderStyle = 0 没有框线 Me.AutoRedraw = True Set Image1.Picture = LoadPicture("e:\bubbles.gif") 注释:请自行找一个背景透明的图 hBitmap = CreateCompatibleBitmap(Me.hdc, 0, 0) SelectObject Me.hdc, hBitmap Me.Refresh End Sub Private Sub Form_Unload(Cancel As Integer) DeleteObject hBitmap End Sub |
- 还没有人评论,欢迎说说您的想法!