|
-
Jun 5th, 2002, 03:51 AM
#1
Thread Starter
Frenzied Member
Make frame transparent?
Does anyone know how to make a frame transparent? I am just using the frame to separate groups of similar data on a form but I want it transparent so the form background can be seen.
-
Jun 5th, 2002, 04:00 AM
#2
Not NoteMe
That's not as easy as it sounds, i'd try using the line control first.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Jun 5th, 2002, 04:09 AM
#3
Thread Starter
Frenzied Member
i'd try using the line control first.
You mean use a series of lines instead? OK, but how do I give the lines the etched effect?
-
Jun 5th, 2002, 04:16 AM
#4
try getting sheridan controls.... u can make a it
by a property....
-
Jun 5th, 2002, 04:20 AM
#5
Frenzied Member
See this answer....you can do without the DLL if you use GetWindowLong and SetWindowLong API calls...
HTH,
Duncan
-
Jun 5th, 2002, 05:33 AM
#6
Thread Starter
Frenzied Member
MerrionComputin
This only sets the backstyle of the contents of the frame i.e. the text boxs I have in the frame. I need to set the frame itself to transparent so only the border shows.
-
Jun 5th, 2002, 05:39 AM
#7
Frenzied Member
VB Code:
.SetWindowStyle WS_EX_TRANSPARENT, True
Makes the frame itself transparent...it may need to be redrawn though - try minimising and restoring the form and see if it goes transparent then...
-
Jun 5th, 2002, 05:46 AM
#8
Frenzied Member
Code (without need for EventVB.dll)
VB Code:
Option Explicit
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 SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const WS_EX_TRANSPARENT = &H20&
Private Const GWL_EXSTYLE = (-20)
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE
Public Sub MakeFrameTransparent(ByVal fraThis As Frame)
Dim lExStyle As Long
lExStyle = GetWindowLong(fraThis.hwnd, GWL_EXSTYLE)
lExStyle = lExStyle Or WS_EX_TRANSPARENT
Call SetWindowLong(fraThis.hwnd, GWL_EXSTYLE, lExStyle)
Call SetWindowPos(fraThis.hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_FRAMECHANGED)
End Sub
Note that you can make other windows transparent as well - the effect with a rich text box is particularily pleasing....
HTH,
Duncan
-
Jun 5th, 2002, 09:11 AM
#9
Hyperactive Member
Re: Code (without need for EventVB.dll)
I can't get this to work. Is this the correct way to call it?
Private Sub Form_Load()
MakeFrameTransparent Frame1
End Sub
-
Jun 5th, 2002, 09:22 AM
#10
Thread Starter
Frenzied Member
Me neither
-
Jun 5th, 2002, 09:25 AM
#11
Frenzied Member
That's correct..try putting apicture on your form so you can see that the frame is transparent...wiorks for me (VB5 on NT4)
-
Jun 5th, 2002, 09:37 AM
#12
Hyperactive Member
I do have a picture covering the form and Frame1 in the middle. Using VB6 Enterprise, Win98SE
-
Jun 5th, 2002, 09:45 AM
#13
Thread Starter
Frenzied Member
Am using VB6 and Win2000pro and just the textboxes are transparent in the frame. The labels - even when set to transparent, in the frame still aren't transparent.
Thanks anyway
-
Jun 5th, 2002, 10:03 AM
#14
Frenzied Member
VB Code:
Option Explicit
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 SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const WS_EX_TRANSPARENT = &H20&
Private Const GWL_EXSTYLE = (-20)
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Declare Function SetBkMode Lib "gdi32" Alias "SetBkMode" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Long) As Long
Private Const TRANSPARENT = 1
Private Declare Function InvalidateRectLong Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long,ByVal lpRect As Long, ByVal bErase As Long) As Long
Public Sub MakeFrameTransparent(ByVal fraThis As Frame)
Dim lExStyle As Long
lExStyle = GetWindowLong(fraThis.hwnd, GWL_EXSTYLE)
lExStyle = lExStyle Or WS_EX_TRANSPARENT
'\\ Set window style to be transparent
Call SetWindowLong(fraThis.hwnd, GWL_EXSTYLE, lExStyle)
'\\ make the fram backstyle transparent
Call SetBKMode(GetDc(fraThis.hwnd),TRANSPARENT)
'\\ Make frame window redraw itself
Call SetWindowPos(fraThis.hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_FRAMECHANGED)
Call InvalidateRect(fraThis.hwnd, vbNull, True)
fraThis.Refresh
End Sub
Try this?
Also - is your form's AutoRedraw set to false?
HTH,
Duncan
-
Jun 5th, 2002, 10:29 AM
#15
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|