Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Transparent Background

Posted on 2003-11-05
5
Medium Priority
?
521 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:Canon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9687477
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
 
LVL 14

Accepted Solution

by:
aelatik earned 800 total points
ID: 9687498
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9687513
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9687664
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
 

Author Comment

by:Canon
ID: 9687800
Thanks to all who replied. The accepted answer worked fine for me!

Canon
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question