Transparent Background

Hi All, is there a simple way to have a background image on a form to be visible behind a Frame ? I have a frame with some labels and command buttons on it. The background of the frame is kind of large and I want to be able to view the form background image that was placed there. So, just want to be able to get rid of the color background in a Frame to see the form background image!

Hope this makes sense ?

Thanks

Canon
CanonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richie_SimonettiIT OperationsCommented:
If you change frame to transparent (with API calls it would be possible) you will not see labels any more.
One possible solution is replace the frame control with a pair of shape controls emulating the shape.
0
aelatikCommented:
This works allright, found it on : http://www.activevb.de/tipps/vb6tipps/tipp0575.html

Option Explicit

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long
Private CtrlDc, lHoch, lBreit, lTemp, lSkin, lStart, lZeile, lSpalte, lBackColor As Long

Private Sub Form_Load()
    Me.Show
    Frame1.BackColor = &HFF&
    DoEvents
    FrameTransparent Frame1
End Sub

Public Function FrameTranz(Ctrl As Frame) As Long
    lSkin = CreateRectRgn(0, 0, 0, 0)
        With Ctrl
            lHoch = .Height / Screen.TwipsPerPixelY
            lBreit = .Width / Screen.TwipsPerPixelX
            CtrlDc = GetDC(.hwnd)
            lBackColor = Ctrl.BackColor
        For lZeile = 0 To lHoch - 1
            lSpalte = 0
            Do While lSpalte < lBreit
                Do While lSpalte < lBreit And GetPixel(CtrlDc, lSpalte, _
                    lZeile) = lBackColor
                    lSpalte = lSpalte + 1
                Loop
                If lSpalte < lBreit Then
                    lStart = lSpalte
                Do While lSpalte < lBreit And GetPixel(CtrlDc, lSpalte, _
                    lZeile) <> lBackColor
                    lSpalte = lSpalte + 1
                Loop
                If lSpalte > lBreit Then lSpalte = lBreit
                    lTemp = CreateRectRgn(lStart, lZeile, lSpalte, lZeile + 1)
                    Call CombineRgn(lSkin, lSkin, lTemp, 2)
                    Call DeleteObject(lTemp)
                End If
            Loop
        Next lZeile
    End With
    FrameTranz = lSkin
End Function

Public Sub FrameTransparent(Ctrl As Frame)
    Dim lSkin As Long
        Ctrl.Visible = True
        lSkin = FrameTranz(Ctrl)
        Call SetWindowRgn(Ctrl.hwnd, lSkin, True)
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richie_SimonettiIT OperationsCommented:
0
Arthur_WoodCommented:
note of caution---this line:

Private CtrlDc, lHoch, lBreit, lTemp, lSkin, lStart, lZeile, lSpalte, lBackColor As Long

ONLY declarse lBackColor As Long, the other variables are ALL declared as VARIANTs.

VB 6 does NOT support multiple declarations in one line, like that.

either:

Private CtrlDc as Long, lHoch as Long, lBreit as Long, lTemp as Long, lSkin as Long, lStart as Long, lZeile as Long, lSpalte as Long, lBackColor As Long

or:

Private CtrlDc as Long
Private lHoch as Long
Private lBreit as Long
Private lTemp as Long
Private lSkin as Long  and so on


AW
0
CanonAuthor Commented:
Thanks to all who replied. The accepted answer worked fine for me!

Canon
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.