Click here to Skip to main content
15,741,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code

Option Explicit
Const LW_KEY = &H1
Const G_E = (-20)
Const W_E = &H80000
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 ReleaseCapture Lib "user32.dll" () As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const LWA_ALPHA = &H2
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const ULW_COLORKEY = &H1
Private Const ULW_ALPHA = &H2
Private Const ULW_OPAQUE = &H4
Private Const WS_EX_LAYERED = &H80000

Private Sub Form_Load()
Dim Ret As Long
Dim TC As Long
TC = &HC000C0
Ret = GetWindowLong(Me.hwnd, G_E)
Ret = Ret Or W_E
SetWindowLong Me.hwnd, G_E, Ret
Me.BackColor = TC
SetLayeredWindowAttributes Me.hwnd, TC, 0, LWA_COLORKEY
End Sub

What I have tried:

This Code worked in SDI Forms but not working in MDI child form.
How to make make child form transparent back color with layered window?
Please Help me.
Thanks Advance
Updated 25-Jun-19 22:41pm
smdoss 2-Jul-19 2:01am    
Hi Gerry Thanks for your advice. Then I try something altered my code with your advice. Finally I get the result. MDI Child form is do transparent. First i put the code in the parent form and put the code in a child form. It is worked OK. At the same time i want see the contents of controls another child form but the transparent child form didn't show the contents of other child forms. what can i do. please help.
And how can i upload a sample images of my project result?(sorry my poor language)

1 solution

Well, MDI child forms don't support independent transparency. An MDI child form is actually a child control of the MDI parent so, just like all other child controls, their transparency depends on the parent form. You can set the TransparencyKey of the parent and then, if that color is present on the child (You can use another pictureBox to do this on child form), you'll see right through both of them. It's not possible to set the TransparencyKey of the child and see through to the parent though.

How to make MDI child form transparent in vb6[^]
Share this answer
Maciej Los 26-Jun-19 7:35am    
Gerry, a link is broken, because it refers to this page.
Richard Deeming 2-Jul-19 11:38am    
You have a response waiting in the comments to the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900