Am using api to make the vbframe control transparent.
But it flickers when i hover the mouse it.
How ca i stop this.
Any ideas?
Printable View
Am using api to make the vbframe control transparent.
But it flickers when i hover the mouse it.
How ca i stop this.
Any ideas?
You might be able to use the LockWindowUpdate API call along with some well-timed manual redraws to work around it.
Could you post your code? I have code that uses API to redraw anything that's under the frame into the frame DC, as background, this simulates transparency. But i would like to see your code, there is a way to draw to a backbuffer when subclassing, doing this you can avoid flickering.
vb Code:
Option Explicit Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) _ As Long Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject _ As Long) As Long Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 _ As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 _ As Long) As Long Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn _ As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, _ ByVal nCombineMode As Long) As Long Public Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, _ ByVal x As Long, ByVal y As Long) As Long Public Declare Function SetWindowRgn Lib "user32" (ByVal hwnd _ As Long, ByVal hRgn As Long, ByVal bRedraw As Long) As Long Public CtrlDc As Long Public Function GetTransparentFrame(Ctrl As Frame) As Long Dim lHeight As Long Dim lWidth As Long Dim lTemp As Long Dim lSkin As Long Dim lStart As Long Dim lLine As Long Dim lColumn As Long Dim lBackColor As Long lSkin = CreateRectRgn(0, 0, 0, 0) With Ctrl 'Form.ScaleMode = vbTwips lHeight = .Height / Screen.TwipsPerPixelY lWidth = .Width / Screen.TwipsPerPixelX 'Form.ScaleMode = vbPixels 'lHeight = .Height 'lWidth = .Width CtrlDc = GetDC(.hwnd) lBackColor = Ctrl.BackColor For lLine = 0 To lHeight - 1 lColumn = 0 Do While lColumn < lWidth Do While lColumn < lWidth And GetPixel(CtrlDc, lColumn, lLine) = lBackColor lColumn = lColumn + 1 Loop If lColumn < lWidth Then lStart = lColumn Do While lColumn < lWidth And GetPixel(CtrlDc, lColumn, lLine) <> lBackColor lColumn = lColumn + 1 Loop If lColumn > lWidth Then lColumn = lWidth lTemp = CreateRectRgn(lStart, lLine, lColumn, lLine + 1) Call CombineRgn(lSkin, lSkin, lTemp, 2) Call DeleteObject(lTemp) End If Loop Next lLine End With GetTransparentFrame = lSkin End Function Public Sub MakeFrameTransparent(Ctrl As Frame) Dim lSkin As Long Ctrl.Visible = True 'Set the background colour. lSkin = GetTransparentFrame(Ctrl) Call SetWindowRgn(Ctrl.hwnd, lSkin, True) End Sub Public Sub Main() XPStyle Form1.Frame1.BackColor = &HFF& Form1.Show Form1.Refresh MakeFrameTransparent Form1.Frame1 End Sub
I have just posted the code that makes a frame transparent. This solution is not mine
Does it flicker if you disable the XPstyle?
I ran into the same problem with the VB Frame control in a project that was using XPstyle, so I just ended up creating my own owner drawn frames, I posted one of them here.
I used that code but the Frame doesn't flicker when i hover the mouse, it does take a while until its transparent but no flickering after that.
EDIT: Yes, it must be the combination with XPStyle thats causing the flickering.
Ya its' slow, tried it with 4 frames and it takes what seems like forever, and the form has to be in view in the desktop area.
is there any way to make the code faster
ode ?
I'm sure OP means "code". Sadly I can't contribute, just noting the clarification. :)
code, oh ok! should of got that!
Heres one I found on PSC that is much faster.
I tried that one before but it had a side effect, I think the caption turned magenta color on me or something under a certain condition, plus like the code posted above the form has to be shown (in the desktop area) before the transparency effect can be added and take effect.
I have tried that solution before.i think the algorithm that makes it work is what needs to be reimplemented
it dosent work with the frame placed on a tabstrip control that has xp style. any help
For issues like that, put the control (in this case the frame) inside a Picturebox, and put that in the container (the tabstrip).
how can i make the frame transparent then. I was only succesfu to make the frame control transparent. if i put the picturebox on tabstrip it does no become transparent
Well in that case you are probably stuck I'm afraid, I doubt there is anything you can do about it.
does that means that there is no solution. icant take that for an answer. maybe i'll do research onmy own.
but any help will be appreciated
guys any help still?
On the Microsoft Office Packages, it includes a Form 2.0 Frame control, which you can package with your compiled project when you compile it. This frame control is able to use AutoRedraw and also I guess that you can make it transparent, by using Alpha channels, in the Frame control itself.
Also note: That this Frame control is named, frm20.dll, try searching for it on your Office enabled computer system. This version of the control appears in anything Office 95 or better.
Actually you are not allowed to redistribute Microsoft Forms 2.0 Frame, so you can not package it with your compiled project! Your users must have the Fm20.dll on their system. Read Here!
but why would microsoft want to put their developers or customers into so much trouble making the frame control transparent
what if i write microsoft?
this fearture is found in windos system property dialoge
how do i subclass this window and catch all the messages sent from and to it using spy++
maybe i might find a solution there
Read Post #21 just up the page...you can use the Form 2.0 frame, but you can't redistribute it, so what would be the point?Be my guest...all that will do, however, is to provide you with written response about why you can't redistribute them. It won't give you permission to do so.
If all you are looking for is a transparent container, what about using picturebox control?
am confused, please put me throughQuote:
Re: Flikering
Quote:Originally Posted by coolcurrent4u
can you pls help me with some code for this
Its not source code, that you need. Its key strokes and mouse clicking that will deliver what you want to know.
__________________
How to change a light bulb?
Ahh yes, I know that?
Light_Bulb1 = Light_Bulb1 + Ladder
Do a search from with in the VB6's Control Dialog Box. Then select it, and click on the tick on the Control Dialog Box. Finally you can then drag the control to the Form, just like any other control that you have loaded into the Project.
I don't see how that helps, I just tried the Form 2.0 Frame for the first time, here's what I get,
1) It is not a container, it can't hold controls.
2) It doesn't support XP styles.
3) I don't see any Transparent property for it.
4) MS recommends you do not use this control for VC/VB.
Besides not doing what the OP wants his/her users would need to have Office installed or an alternative (see link in post 21).
You have to program in the container into it, as code.
I can't remember the code for the Frame container, because I had worked on one many years ago. When I was a young lad programmer at HP. It was one of my working projects, but not work as such. Also its quite fiddley, and quite a head banger as well.
Well that is what I remember, anyway.
I think that you should use a HTML scrolling document, instead anyway that is somewhat better, and still the same in fact.
pls post some code to help others
I don't know about the code for the HTML controls. But I know that Microsoft uses this to scroll ActiveX controls on their Windows Update website. It has been about ten years, since I had left HP from programming, so I cannot remember any code.
So then here is the ocx file to do that. But the methods, I don't remember.
Enjoy!!
this does not help? i don;t understand
Then try reading a manual, whitepaper or something like that on the subject. I suggest try using the Internet as well.
ok if this is all i ca get thanks anyways i have stopped looking for a way to even make the frame control transparent.
Or actually you could use the shape tools or even the image control to draw up one that you can use as transparent. Also the Microsoft Forms 2.0 one does allow this, but you aren't allowed to disturibute it anyway.
i just wanted to make a dialoge box that look like the xp themed version. i have searched every where. the thing is not just doing it , but making sure it works with orther os or the end user. so i decided to go for a more simple interface. thanks anyways
Then use an XP theme with the project. You can use Windows to do this, but I am not quite sure how to do it, and only for one project.