Re: Transparent Container?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"AppleBag" <applebag@xxxxxxxxx> wrote in message news:1155302289.584382.69220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I have been toying with the code and sort of battle testing
to see if I could throw it some loops . . . . .

Yikes! It's just some testbed code at the moment. Don't be throwing things at it, at least not yet ;-)

and came across some issues when placing a transparent frame
inside another non-transparent frame. The labels are acting wacky.

Well they will be. The code works by setting up a clipping region that effectively make the entire Frame area transparent so that all you see is whatever happens to be underneath it (normally the Form). It then runs through the Form's Control Collection checking each control to see if its Container is the Frame, in which case it causes the small area occupied by that specific control to effectively be non-transparent, so that you can see the control. (For simplicity of description, and for want of a better phrase, I called the act of doing that "punching a non-transparent hole"). That works for all controls except transparent Labels, because the way VB draws those things causes the Label's transparency to cease to have an effect and you see the Label as though it was set to Opaque. So, in order to get around that problem, the code causes the Label to become invisible by the simple act of failing to "punch the non-transparent hole" at its position. That causes whatever is beaneth the Label (the Form in the example) to show itself. Then the code draws the Label's caption property onto the Form using the Print method (although later it would be best to use the DrawText API instead, for reasons I've already explained). So, as it currently stands, in order for the routine to work properly you need to pass it a Form (so that the routine will know which Control Collection to look at) and a Frame so that it knows what "container" to look for when running through the Control Collection. If you place your "transparent Frame" inside another Frame (as you have suggested) then in the transparent areas you will see the other Frame, not the Form. Also, and this is what you probably mean when you say "The labels are acting wacky", you will not see the Label caption. This is because it isn't really a Label caption at all, but is simply some text that has been drawn to the underlying Form using the Print statement, and it will of course be hidden by "the other Frame" into which you dropped your "transparent Frame".

To summarise, for this code to work as it stands you need to have the "transparent Frame" in a Form (something to which you can draw text) and not in another Frame. Actually, that's not strictly true because it would be possible to make a very slight adjustment to the code so that it draws (Prints) the text to the "transparent Frame's" container (it currently draws to the Form which you pass it). In that way you could have the "transparent Frame" in a container other than the Form. However, as the code currently stands, it needs to be a container into which you can Print stuff using the VB Print method, such as a Form or a Picture Box.

Having said all that, almost nothing is impossible of course and after the code has been modified so as to use the TextOut (or better still DrawText) API method it should be possible use another Frame as a container for the "transparent Frame" and to draw to the hDC of the underlying Frame instead of to the underlying Form, although you would also need to add a bit more code to make the drawing of the text persistent. I'm not sure how all that would work in practice, but I think it is quite probably "doable". For the moment though I would simply place your "transparent Frame" directly onto the Form, unless there is some pressing reason for you to need to do otherwise.

Mike Williams (MVP - Visual Basic)



.



Relevant Pages

  • Re: Whats the opposite event for "MouseMove"? (Emergency)
    ... the frame that changes the label text back. ... That will work if you have plenty of space around every control and the user ... As mentioned before this can be done by watching the MouseMove of every ...
    (microsoft.public.vb.general.discussion)
  • Re: Multiline Tooltip
    ... How about just putting a label over the control and that control in a frame. ... ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) ...
    (microsoft.public.excel.programming)
  • Re: Assigning control tip text
    ... How about just putting a label over the control and that control in a frame. ... ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) ...
    (microsoft.public.excel.programming)
  • Re: Label does not appear in Frame Control
    ... >> or create them inside of the frame. ... You can also single click the Label ... > directly into the Frame (or any other container control) and it will be ...
    (microsoft.public.vb.general.discussion)
  • Re: Label does not appear in Frame Control
    ... I'll be happy to label your way as the correct way since, other than placing them onto the form, then cutting and pasting them into ... the selected container control, that is the only way I know to DIRECTLY place a control into a container control. ... > put a control on a Frame, ...
    (microsoft.public.vb.general.discussion)