how to make control transparent like textbox, commandbutton or other.

Recommended Answers

All 4 Replies

Try this code to first create a transparent window:

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 GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_ALPHA = &H2

Private Sub Command1_Click()
Dim f2 As New Form2
f2.show
Call SetWindowLong(f2.hWnd, GWL_EXSTYLE, GetWindowLong(f2.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
Call SetLayeredWindowAttributes(f2.hWnd, 0, 255 / 2, LWA_ALPHA) ' 50% translucent
End Sub

You can modify this code to use for textbox control or command button.

thanks. for the coding. but i dont want it form transparent :'( . i just want control textbox or commandbutton transparent :) .

thank for the reply.

thanks. for the coding. but i dont want it form transparent :'( . i just want control textbox or commandbutton transparent :) .

thank for the reply.

By transparent do you mean it should match the color of the form?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.