Consulting

Results 1 to 12 of 12

Thread: Don't have Frame1 & ListBox1 BackColor = fmBackStyleTransparent Property?

  1. #1
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location

    Don't have Frame1 & ListBox1 BackStyle = fmBackStyleTransparent Property?

    Hi everyone,

    I have a Frame1 and ListBox1 on UserForm1.

    Also have a Picture on UserForm1.

    My problem is; I can change the BackStyle prorerties to fmBackStyleTransparent of the all controls on UserForm1. And it's ok. But i can not change the same thing for Frame1 and ListBox1.

    I tried the codes shown below:

    [vba] ListBox1.BackColor = fmBackStyleTransparent
    Frame1.BackColor = fmBackStyleTransparent[/vba]
    But Frame1 and ListBox1 will get black color while the codes run.

    So, what i have to do for resolve it? An API or something else?
    I need your ideas and suggestions.

    (By the way, i attaeched my file.)

    Thank you very much.
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

  2. #2
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location
    Opps!!

    The header must be :
    Don't have Frame1 & ListBox1 BackStyle = fmBackStyleTransparent Property?

    I wrote wrong. So sorry guys..
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

  3. #3
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    No worries, Erdinc. I've modified the post title for you.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  4. #4
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Hmm... see what you mean. 0 (numerical equivalent) just sets it to black, not transparent.

    I took a quick stroll through google, but can't see any way there either. Is the frame going to sit on a solid background? Can you sample the colour from your background image and set the back color to that?

    EDIT: Only link that came up as close has no answer (yet). At least it's recent though... http://www.a1vbcode.com/a1vbcode/vbf...15442-3-1.aspx
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  5. #5
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location
    Quote Originally Posted by Ken Puls
    No worries, Erdinc. I've modified the post title for you.
    Thanks Ken.


    Quote Originally Posted by Ken Puls
    Hmm... see what you mean. 0 (numerical equivalent) just sets it to black, not transparent.

    I took a quick stroll through google, but can't see any way there either. Is the frame going to sit on a solid background? Can you sample the colour from your background image and set the back color to that?
    Hi Ken, unfortunately my background image's color is not single. The image is like a cover of a litte program and have some different types and colurs. Therefore it is not suitable for this issue.

    Should i research for an API?
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

  6. #6
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location
    Hi again,

    I found out a link for Transparent but i can't understand because is't written by French language.

    http://www.vbfrance.com/codes/SUITE-...LES_24305.aspx

    Also i found an add-in at Ivan F Moala's website.
    http://www.xcelfiles.com/SeachSite.html

    (But i could not post here because too lagre for add here: 282 KB Around...)

    This add-in is very beautiful and have an API for transparent UserForm.

    Can anybody help me to adaptation this API for my Frame1 and ListBox1?

    Thanks in advance.
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

  7. #7
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    How about adding another image control to the frame and positioning it such that it aligns with the one on the userform.

    Assuming Image1 is on the userform and Image2 is within Frame1.
    [vba]
    Image2.Move Image1.Left - Frame1.Left, Image1.Top - Frame1.Top
    [/vba]

    You will need to play with the calculation a little to include caption and border.
    Cheers
    Andy

  8. #8
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    My bad I should have checked your example workbook before posting.

    The listbox will remain solid. But to be honest if it was transparent you would have a great difficulting reading it's contents.

    This will do is you add a image to frame 1.
    [vba]
    Image1.Move 0 - Frame1.Left - 3, 0 - Frame1.Top - 15[/vba]

    On a personal note I think the background formatting is to noisey. If you must have the image have it as a small banner at the top or bottom but away from the input controls.
    Cheers
    Andy

  9. #9
    Erdin?,

    I am assuming that you will have controls hosted within your frame? If not, setting it transparent is the same as simply making it invisible. The listbox and frame are not windowless but they are children. As far as I know, you cannot set the opacity of a child window. The only option I can concieve of for your frame would be to clip the background region within the userfrom that is overlayed by the frame, create a new bitmap from this region, and then set that bitmap to the picture property of your frame. To see what this would produce, open the attached and click on the "Toggle Frame1 picture" button to toggle the frame from the clipped background to a solid color background. Note that the gridmarks are within the frame's background picture because I clipped the area in design mode.

    I have so suggestions for your listbox though I cannot imagine the need for making a listbox transparent to begin with.

  10. #10
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Erdin? E. Ka
    I found out a link for Transparent but i can't understand because is't written by French language.

    http://www.vbfrance.com/codes/SUITE-...LES_24305.aspx
    Erdin?,

    How did you find out that this worked?


  11. #11
    You can set the opacity of a userform, but no a control. I'm pretty sure about this. Place this on a userform with ScrollBar1.

    [VBA]
    Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal Hwnd As Long, ByVal crKey As Integer, ByVal bAlpha As Integer, ByVal dwFlags As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal lngWinIdx As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal Hwnd As Long, ByVal lngWinIdx As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Private Const GWL_EXSTYLE = &HFFEC
    Private Const WS_EX_LAYERED = &H80000
    Private Const LWA_ALPHA = &H2

    Private Sub SetOpacity(Opacity As Byte)
    Dim NewLong As Long, Hwnd As Long
    Hwnd = FindWindow(vbNullString, Me.Caption)
    NewLong = GetWindowLong(Hwnd, GWL_EXSTYLE)
    SetWindowLong Hwnd, GWL_EXSTYLE, NewLong Or WS_EX_LAYERED
    SetLayeredWindowAttributes Hwnd, 0, CInt(Opacity), LWA_ALPHA
    End Sub

    Private Sub ScrollBar1_Change()
    SetOpacity 255 - ScrollBar1.Value
    End Sub
    [/VBA]

  12. #12
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location
    Hi all,

    Thank you very much for your personal note and kindly help Andy Pope, i'll keep it.

    Tom, Frame1 is ok with your "Toggle Frame1 picture" button method. Thank you very much. So, it's looks like better if i don't use ListBox1 like my wish. A small banner is sound like well.

    Bob, actually i didn't controlled that codes because descriptions of that codes in French language and i can't understand French language. So, i couldn't sure that codes. Maybe that is wrong or may have some error, i am not sure that.

    Tom, your SetOpacity API is wonderful. Many thanks.

    Thank you all again...
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •