Transparent frame possible?? [resolved (on a alternative way) :)]-VBForums
Results 1 to 29 of 29

Thread: Transparent frame possible?? [resolved (on a alternative way) :)]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    66

    Resolved Transparent frame possible?? [resolved (on a alternative way) :)]

    Hi all,

    Is it possible to make the background colour of a frame transparent?
    Thanks in advance

    Walter
    Last edited by waltervis; Feb 12th, 2005 at 06:29 PM.

  2. #2
    Addicted Member makster246's Avatar
    Join Date
    Dec 2004
    Location
    nottingham
    Posts
    187

    Re: Transparent frame possible??

    There is actually a few ways to do this, the main 1 being use of the APi, but if you are lookign for a sneeky alternative, u can create a custom control.

    and in the custom control, use the line tool, to create a frame like border, and a caption box to create the look of the frame text..although this meathod (unless properly worked on), will not have the total funcationatie of a normal frame, but it would work fine unless you need to use a frame for anythign complecated.

    Rob

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    66

    Re: Transparent frame possible??

    Quote Originally Posted by makster246
    There is actually a few ways to do this, the main 1 being use of the APi, but if you are lookign for a sneeky alternative, u can create a custom control.

    and in the custom control, use the line tool, to create a frame like border, and a caption box to create the look of the frame text..although this meathod (unless properly worked on), will not have the total funcationatie of a normal frame, but it would work fine unless you need to use a frame for anythign complecated.

    Rob

    nothing complicated... but i already bound my textboxes to them lol.
    So eeeermmmm cwap. There is not a colour (or better a NON colour) in the colour list present?

    Thats is pretty unlucky then for me.
    Hey mate Thanks for your info

  4. #4
    Addicted Member makster246's Avatar
    Join Date
    Dec 2004
    Location
    nottingham
    Posts
    187

    Re: Transparent frame possible??

    I wish there was....
    as i say the only other way to do it would be to use the API, there are a few tutorials on here which could help you out if you run a search on "transparent API"

    Rob

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    66

    Re: Transparent frame possible??

    Guys,

    Thanks for help. Im gonna photoshop my way through this one. lol
    Thank you very much!

    Walter

  6. #6
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,164

    Re: Transparent frame possible??

    Just a guess, but what about setting the frames background color to the
    same as the control/form behind it? Or is there more to it then that?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    66

    Re: Transparent frame possible??

    Quote Originally Posted by RobDog888
    Just a guess, but what about setting the frames background color to the
    same as the control/form behind it? Or is there more to it then that?
    Ye youre right.. but this madhead (me) wasnt looking good.
    Slap me big time.
    thanks mate

    lol big time! hahah

  8. #8
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,164

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Ok, here it comes *SLAP*

    I was thinking that this was the solution, but maybe you were trying to get the frame to show through the
    form to the desktop of something. Maybe you had other controls that you wanted to show through too.
    So, I was too making allot of it event though I had no way to know.

    Ps, this is typical Programmer thinking - anaylzing everything and anything
    until it becomes complicated!

    Glad to have helped you on this one
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    You can use BitBlt and some other APIs to mimic transparent frame.
    Here is a sample but you'll need to work with caption a little more to make it pefect.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const BDR_SUNKENOUTER = &H2
    4. Private Const BDR_RAISEDINNER = &H4
    5. Private Const DT_EDITCONTROL = &H2000&
    6. Private Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
    7. Private Const BF_BOTTOM = &H8
    8. Private Const BF_LEFT = &H1
    9. Private Const BF_RIGHT = &H4
    10. Private Const BF_TOP = &H2
    11. Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
    12. Private Const DT_LEFT = &H0
    13. Private Const DT_TOP = &H0
    14.  
    15. Private Type RECT
    16.         Left As Long
    17.         Top As Long
    18.         Right As Long
    19.         Bottom As Long
    20. End Type
    21.  
    22. Private Declare Function BitBlt Lib "gdi32" (ByVal hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    23. Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    24. Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    25. Private Declare Function DrawCaption Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long, pcRect As RECT, ByVal un As Long) As Long
    26. Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
    27. Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    28.  
    29. Private Sub Command1_Click()
    30. '============================
    31. Static blnTrans As Boolean
    32. Dim MyRect As RECT
    33. Dim X1&, Y1&, X2&, Y2&
    34. Dim strText As String
    35. Dim TempDC As Long
    36.  
    37.     blnTrans = Not blnTrans 'toggle transparency
    38.    
    39.     With Frame1
    40.         If blnTrans Then
    41.             Me.Cls
    42.             Me.ScaleMode = vbPixels
    43.             X1 = .Left - 2
    44.             Y1 = .Top - 2
    45.             X2 = X1 + .Width + 4
    46.             Y2 = Y1 + .Height + 4
    47.             SetRect MyRect, X1, Y1, X2, Y2
    48.            
    49.             SetRect MyRect, X1, Y1, X2, Y2
    50.             DrawEdge Me.hdc, MyRect, EDGE_ETCHED, BF_RECT
    51.            
    52.             strText = .Caption
    53.             SetRect MyRect, X1 + 10, Y1 - 5, X2, Y2
    54.             DrawText Me.hdc, strText, Len(strText), MyRect, DT_LEFT Or DT_TOP
    55.            
    56.             TempDC = GetDC(.hWnd)
    57.             BitBlt TempDC, 0, 0, .Width, .Height, .Parent.hdc, .Left, .Top, vbSrcCopy
    58.         Else
    59.             Me.Cls
    60.             .Refresh
    61.         End If
    62.     End With
    63.  
    64. End Sub
    65.  
    66. Private Sub Form_Load()
    67.     Me.AutoRedraw = True
    68. End Sub
    69.  
    70. Private Sub Frame1_Click()
    71.     MsgBox "You've just clicked transparent frame control."
    72. End Sub

  10. #10
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,164

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Very nice duplication of a frame RB! One issue is that when you mouseover the frame after the
    button click it goes back to the original frame control.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  11. #11

  12. #12
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,164

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Is there another setting that I need to apply? I just pasted the code from your post and added the controls.

    I am running XP SP-1 IE 6.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  13. #13

  14. #14
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,164

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Not exactly. I realize the command button toggles it but when its on and I move the mouse over the
    transparent frame it changes back.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  15. #15

  16. #16
    New Member
    Join Date
    Apr 2006
    Posts
    1

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    in my work, the following procedures made the control reset to its original frame control:
    1. clik the cmd button and make the control transparent.
    2. then, make active to other windows that overlap that vb form.
    3. then, go back to vb form, the control is in the original state(not transparent).

    I think it need to redraw...
    Last edited by Hack; Apr 5th, 2006 at 10:02 AM.

  17. #17
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Welcome to the forums.

    I have removed your email address from your post. Never put your email address in an open post on an open forum. Mail spam bots can pick that up and before you know it, your mailbox is full of junk mail.

    What is your question?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  18. #18
    Lively Member
    Join Date
    Mar 2006
    Posts
    70

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    hi Walter
    did u happen to get u r transparent frame.. coz.. i am also facing the same situation
    please do let me know
    my thread is in http://www.vbforums.com/showthread.php?t=399890

  19. #19
    Junior Member
    Join Date
    Apr 2006
    Posts
    28

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Hello Deepa/Rhino Bull,

    I tried both loading the transparent OCX and implementing the code that RB supplied, but the neither frame control method is showing as transparent. Do I need to change some system and/or VB setting to affect transparency?

  20. #20
    Lively Member
    Join Date
    Mar 2006
    Posts
    70

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    hi Keith...
    I persume that u have visited my thread at http://www.vbforums.com/showthread.php?t=399890..( from where u got the ocx)
    this works just great for me..no coding.. nothing else... just change the backstyle property to transparent...

    However the transparencey of the frame is seeen only at runtime
    at design mode the transparent-frame ""looks-like"" normal frame


    RhinoBull
    You can use BitBlt and some other APIs to mimic transparent frame.
    ...vbcode.. etc
    here i think RB's code needs to be worked independently..perhaps he did not have the ocx when the message was posted

    may be both ocx.. and RB's code are not complementry to each other
    try using them independtly

    good luck
    Deepa

  21. #21
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Guys,
    one more time and only to clarify thigs: VB6's Frame control DOES NOT support transparency - as I said you may only mimic it by using technic similar to what i've posted. That's the end of story.

  22. #22
    New Member
    Join Date
    Aug 2006
    Posts
    3

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    YES IT IS POSSIBLE!!!!! ..and not a fake-transparent, but a REAL transparent frame! any one who wants it can e-mail me : sokin_keso@hotmail.com

    I'm working on a few inproovements and I'll distribute release 1.0 in the next days. My Transparent N-Frame will be a freeware .ocx

  23. #23
    Junior Member
    Join Date
    Nov 2006
    Posts
    22

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Hello EveryBady thes Progect Is Very simple
    1. yuo can chose Stander Skin for Make Transparent
    2. yuo Can chose Transparent Imge
    3. yuo can chose Color Transparent


    http://www.vbforums.com/attachment.p...id=52235&stc=1
    Attached Files Attached Files

  24. #24
    Member
    Join Date
    Apr 2008
    Posts
    46

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Quote Originally Posted by RhinoBull
    You can use BitBlt and some other APIs to mimic transparent frame.
    Here is a sample but you'll need to work with caption a little more to make it pefect.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const BDR_SUNKENOUTER = &H2
    4. Private Const BDR_RAISEDINNER = &H4
    5. Private Const DT_EDITCONTROL = &H2000&
    6. Private Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
    7. Private Const BF_BOTTOM = &H8
    8. Private Const BF_LEFT = &H1
    9. Private Const BF_RIGHT = &H4
    10. Private Const BF_TOP = &H2
    11. Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
    12. Private Const DT_LEFT = &H0
    13. Private Const DT_TOP = &H0
    14.  
    15. Private Type RECT
    16.         Left As Long
    17.         Top As Long
    18.         Right As Long
    19.         Bottom As Long
    20. End Type
    21.  
    22. Private Declare Function BitBlt Lib "gdi32" (ByVal hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    23. Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    24. Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    25. Private Declare Function DrawCaption Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long, pcRect As RECT, ByVal un As Long) As Long
    26. Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
    27. Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    28.  
    29. Private Sub Command1_Click()
    30. '============================
    31. Static blnTrans As Boolean
    32. Dim MyRect As RECT
    33. Dim X1&, Y1&, X2&, Y2&
    34. Dim strText As String
    35. Dim TempDC As Long
    36.  
    37.     blnTrans = Not blnTrans 'toggle transparency
    38.    
    39.     With Frame1
    40.         If blnTrans Then
    41.             Me.Cls
    42.             Me.ScaleMode = vbPixels
    43.             X1 = .Left - 2
    44.             Y1 = .Top - 2
    45.             X2 = X1 + .Width + 4
    46.             Y2 = Y1 + .Height + 4
    47.             SetRect MyRect, X1, Y1, X2, Y2
    48.            
    49.             SetRect MyRect, X1, Y1, X2, Y2
    50.             DrawEdge Me.hdc, MyRect, EDGE_ETCHED, BF_RECT
    51.            
    52.             strText = .Caption
    53.             SetRect MyRect, X1 + 10, Y1 - 5, X2, Y2
    54.             DrawText Me.hdc, strText, Len(strText), MyRect, DT_LEFT Or DT_TOP
    55.            
    56.             TempDC = GetDC(.hWnd)
    57.             BitBlt TempDC, 0, 0, .Width, .Height, .Parent.hdc, .Left, .Top, vbSrcCopy
    58.         Else
    59.             Me.Cls
    60.             .Refresh
    61.         End If
    62.     End With
    63.  
    64. End Sub
    65.  
    66. Private Sub Form_Load()
    67.     Me.AutoRedraw = True
    68. End Sub
    69.  
    70. Private Sub Frame1_Click()
    71.     MsgBox "You've just clicked transparent frame control."
    72. End Sub
    Thanks a lot, dude. This works just fine for me.

  25. #25

  26. #26
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    Re: Transparent frame possible??

    Quote Originally Posted by RobDog888 View Post
    Just a guess, but what about setting the frames background color to the
    same as the control/form behind it? Or is there more to it then that?
    transparency mean being able to see behind the frame whatever lies there

  27. #27
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    3,694

    Re: Transparent frame possible??

    Quote Originally Posted by coolcurrent4u View Post
    transparency mean being able to see behind the frame whatever lies there
    Just posted a newer version of my framez control here. But its not real transparent, its fake, limited usage.

  28. #28
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    Question Re: Transparent frame possible??

    Quote Originally Posted by Edgemeal View Post
    Just posted a newer version of my framez control here. But its not real transparent, its fake, limited usage.
    The attachment below shows the effect am trying to create. can any body help?
    You can see that the frame show the color of the tabstrip (gradient) and still behaves as a container
    Attached Images Attached Images  

  29. #29
    Fanatic Member coolcurrent4u's Avatar
    Join Date
    Apr 2008
    Location
    *****
    Posts
    970

    Re: Transparent frame possible?? [resolved (on a alternative way) :)]

    Quote Originally Posted by RhinoBull View Post
    You can use BitBlt and some other APIs to mimic transparent frame.
    Here is a sample but you'll need to work with caption a little more to make it pefect.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const BDR_SUNKENOUTER = &H2
    4. Private Const BDR_RAISEDINNER = &H4
    5. Private Const DT_EDITCONTROL = &H2000&
    6. Private Const EDGE_ETCHED = (BDR_SUNKENOUTER Or BDR_RAISEDINNER)
    7. Private Const BF_BOTTOM = &H8
    8. Private Const BF_LEFT = &H1
    9. Private Const BF_RIGHT = &H4
    10. Private Const BF_TOP = &H2
    11. Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)
    12. Private Const DT_LEFT = &H0
    13. Private Const DT_TOP = &H0
    14.  
    15. Private Type RECT
    16.         Left As Long
    17.         Top As Long
    18.         Right As Long
    19.         Bottom As Long
    20. End Type
    21.  
    22. Private Declare Function BitBlt Lib "gdi32" (ByVal hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    23. Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    24. Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    25. Private Declare Function DrawCaption Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long, pcRect As RECT, ByVal un As Long) As Long
    26. Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long
    27. Private Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    28.  
    29. Private Sub Command1_Click()
    30. '============================
    31. Static blnTrans As Boolean
    32. Dim MyRect As RECT
    33. Dim X1&, Y1&, X2&, Y2&
    34. Dim strText As String
    35. Dim TempDC As Long
    36.  
    37.     blnTrans = Not blnTrans 'toggle transparency
    38.    
    39.     With Frame1
    40.         If blnTrans Then
    41.             Me.Cls
    42.             Me.ScaleMode = vbPixels
    43.             X1 = .Left - 2
    44.             Y1 = .Top - 2
    45.             X2 = X1 + .Width + 4
    46.             Y2 = Y1 + .Height + 4
    47.             SetRect MyRect, X1, Y1, X2, Y2
    48.            
    49.             SetRect MyRect, X1, Y1, X2, Y2
    50.             DrawEdge Me.hdc, MyRect, EDGE_ETCHED, BF_RECT
    51.            
    52.             strText = .Caption
    53.             SetRect MyRect, X1 + 10, Y1 - 5, X2, Y2
    54.             DrawText Me.hdc, strText, Len(strText), MyRect, DT_LEFT Or DT_TOP
    55.            
    56.             TempDC = GetDC(.hWnd)
    57.             BitBlt TempDC, 0, 0, .Width, .Height, .Parent.hdc, .Left, .Top, vbSrcCopy
    58.         Else
    59.             Me.Cls
    60.             .Refresh
    61.         End If
    62.     End With
    63.  
    64. End Sub
    65.  
    66. Private Sub Form_Load()
    67.     Me.AutoRedraw = True
    68. End Sub
    69.  
    70. Private Sub Frame1_Click()
    71.     MsgBox "You've just clicked transparent frame control."
    72. End Sub
    I tried this code, and it does not work. am using vb6with sp5 install on win xp
    see the effcts i get in the picture below. and by the way do i have to click a button to get the effect. it does not work when doing it automatically.
    Attached Images Attached Images  

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.