Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
'Code to make the Form Transparent:
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Sub Form_Load()
Me.AutoRedraw = True
hBitmap = CreateCompatibleBitmap(Me.hdc, 0, 0)
SelectObject Me.hdc, hBitmap
Me.Refresh
End Sub
'The Code to Make the BackGround of TextBox(txtInfo) Transparent,use the CommandButton(cmdMakeTransparent):
Option Explicit
Dim DoIt As Boolean
Private Const DT_EDITCONTROL = &H2000&
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function BitBlt Lib "gdi32" (ByVal hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Sub TextTrans(MyTB As TextBox)
Dim TempDC As Long
Dim Temp As String
Dim MyLoc As RECT
Temp = MyTB.Text
MyLoc.Left = MyTB.Left
MyLoc.Top = MyTB.Top
MyLoc.Right = MyLoc.Left + MyTB.Width
MyLoc.Bottom = MyLoc.Top + MyTB.Height
MyTB.Parent.Cls
MyTB.Parent.ForeColor = MyTB.ForeColor
Set MyTB.Parent.Font = MyTB.Font
DrawText MyTB.Parent.hdc, Temp, Len(Temp), MyLoc, DT_EDITCONTROL
TempDC = GetDC(MyTB.hWnd)
BitBlt TempDC, 0, 0, MyTB.Width, MyTB.Height, MyTB.Parent.hdc, MyTB.Left, MyTB.Top, vbSrcCopy
End Sub
Private Sub cmdMakeTransparent_Click()
TextTrans txtInfo
DoIt = True
End Sub
Private Sub txtInfo_Change()
If Not DoIt Then Exit Sub
TextTrans txtInfo
End Sub
Private Sub txtInfo_KeyPress(KeyAscii As Integer)
If Not DoIt Then Exit Sub
TextTrans txtInfo
End Sub
Private Sub txtInfo_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not DoIt Then Exit Sub
TextTrans txtInfo
End Sub