Home All Groups Group Topic Archive Search About
Author
10 Oct 2005 1:23 PM
Bart Steur
Hi

I've a form with on it a picturebox. How can I make the picturebox
transparent, so I can see the form (and it's controls) it's on thru it.

Thx

B.

Author
10 Oct 2005 1:52 PM
alpine
On Mon, 10 Oct 2005 15:23:35 +0200, "Bart Steur" <soln***@xs4all.nl>
wrote:

>Hi
>
>I've a form with on it a picturebox. How can I make the picturebox
>transparent, so I can see the form (and it's controls) it's on thru it.
>
>Thx
>
>B.


Depending on exactly what you wish to accomplish, there are other
methods that might be better/easier so, what exactly is it that you
want to do?

HTH,
Bryan
_______________________________
Bryan Stafford
New Vision Software
newvision_don'tspam@mvps.org
Author
10 Oct 2005 2:23 PM
Bart Steur
The picturebox is a container for 1 or more text boxes. Underneath the
picture box is a image with some text that needs to be typed into the
textbox(es).


Show quoteHide quote
"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
news:l5skk1dvribr4pnu4sppled6mc7bdil5d8@4ax.com...
> On Mon, 10 Oct 2005 15:23:35 +0200, "Bart Steur" <soln***@xs4all.nl>
> wrote:
>
>>Hi
>>
>>I've a form with on it a picturebox. How can I make the picturebox
>>transparent, so I can see the form (and it's controls) it's on thru it.
>>
>>Thx
>>
>>B.
>
>
> Depending on exactly what you wish to accomplish, there are other
> methods that might be better/easier so, what exactly is it that you
> want to do?
>
> HTH,
> Bryan
> _______________________________
> Bryan Stafford
> New Vision Software
> newvision_don'tspam@mvps.org
Author
10 Oct 2005 4:10 PM
Mike Williams
"Bart Steur" <soln***@xs4all.nl> wrote in message
news:uOBw3YazFHA.1256@TK2MSFTNGP09.phx.gbl...

> The picturebox is a container for 1 or more text boxes. Underneath
> the picture box is a image with some text that needs to be typed into
> the textbox(es).

You've got me confused there, Bart. If you don't want to see the Picture Box
then why is it there? Why not simply place the Text Boxes themselves over
the background image? Can you please be a bit more specific as to exactly
what it is you want to do.

Mike
Author
10 Oct 2005 5:54 PM
Bart Steur
I want the possiblity to move the textboxes around, since there can be more
than one, the picturebox (as container) can grow quite large. Therefore I
want it to be transparent, so the background is still (partially) readable.


Show quoteHide quote
"Mike Williams" <M***@WhiskyAndCoke.com> schreef in bericht
news:die3om$pq9$1@newsg3.svr.pol.co.uk...
> "Bart Steur" <soln***@xs4all.nl> wrote in message
> news:uOBw3YazFHA.1256@TK2MSFTNGP09.phx.gbl...
>
>> The picturebox is a container for 1 or more text boxes. Underneath
>> the picture box is a image with some text that needs to be typed into
>> the textbox(es).
>
> You've got me confused there, Bart. If you don't want to see the Picture
> Box then why is it there? Why not simply place the Text Boxes themselves
> over the background image? Can you please be a bit more specific as to
> exactly what it is you want to do.
>
> Mike
>
>
>
>
Author
11 Oct 2005 8:02 AM
Jan Hyde
"Bart Steur" <bstn***@xs4all.nl>'s wild thoughts were
released on Mon, 10 Oct 2005 19:54:39 +0200 bearing the
following fruit:

>I want the possiblity to move the textboxes around, since there can be more
>than one, the picturebox (as container) can grow quite large. Therefore I
>want it to be transparent, so the background is still (partially) readable.

Why isn't the 'background' hosted in the picturebox.

J

Show quoteHide quote
>
>"Mike Williams" <M***@WhiskyAndCoke.com> schreef in bericht
>news:die3om$pq9$1@newsg3.svr.pol.co.uk...
>> "Bart Steur" <soln***@xs4all.nl> wrote in message
>> news:uOBw3YazFHA.1256@TK2MSFTNGP09.phx.gbl...
>>
>>> The picturebox is a container for 1 or more text boxes. Underneath
>>> the picture box is a image with some text that needs to be typed into
>>> the textbox(es).
>>
>> You've got me confused there, Bart. If you don't want to see the Picture
>> Box then why is it there? Why not simply place the Text Boxes themselves
>> over the background image? Can you please be a bit more specific as to
>> exactly what it is you want to do.
>>
>> Mike
>>
>>
>>
>>
>


Jan Hyde (VB MVP)

--
Arrest: What you take when you are tired.  (Leopold Fechtner)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
11 Oct 2005 8:12 AM
Bart Steur
What do you mean with Background hosted?

Show quoteHide quote
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
news:ocsmk19feq1blq9k50pffmi3pc5opf64gm@4ax.com...
> "Bart Steur" <bstn***@xs4all.nl>'s wild thoughts were
> released on Mon, 10 Oct 2005 19:54:39 +0200 bearing the
> following fruit:
>
>>I want the possiblity to move the textboxes around, since there can be
>>more
>>than one, the picturebox (as container) can grow quite large. Therefore I
>>want it to be transparent, so the background is still (partially)
>>readable.
>
> Why isn't the 'background' hosted in the picturebox.
>
> J
>
>>
>>"Mike Williams" <M***@WhiskyAndCoke.com> schreef in bericht
>>news:die3om$pq9$1@newsg3.svr.pol.co.uk...
>>> "Bart Steur" <soln***@xs4all.nl> wrote in message
>>> news:uOBw3YazFHA.1256@TK2MSFTNGP09.phx.gbl...
>>>
>>>> The picturebox is a container for 1 or more text boxes. Underneath
>>>> the picture box is a image with some text that needs to be typed into
>>>> the textbox(es).
>>>
>>> You've got me confused there, Bart. If you don't want to see the Picture
>>> Box then why is it there? Why not simply place the Text Boxes themselves
>>> over the background image? Can you please be a bit more specific as to
>>> exactly what it is you want to do.
>>>
>>> Mike
>>>
>>>
>>>
>>>
>>
>
>
> Jan Hyde (VB MVP)
>
> --
> Arrest: What you take when you are tired.  (Leopold Fechtner)
>
> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>
Author
11 Oct 2005 9:40 AM
Jan Hyde
"Bart Steur" <soln***@xs4all.nl>'s wild thoughts were
released on Tue, 11 Oct 2005 10:12:29 +0200 bearing the
following fruit:

>What do you mean with Background hosted?

I asume you have set the background of the form to a
picture? Ie the form is hosting the picture.

Why not set the picture property of the *picture* box
instead

J

Show quoteHide quote
>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>news:ocsmk19feq1blq9k50pffmi3pc5opf64gm@4ax.com...
>> "Bart Steur" <bstn***@xs4all.nl>'s wild thoughts were
>> released on Mon, 10 Oct 2005 19:54:39 +0200 bearing the
>> following fruit:
>>
>>>I want the possiblity to move the textboxes around, since there can be
>>>more
>>>than one, the picturebox (as container) can grow quite large. Therefore I
>>>want it to be transparent, so the background is still (partially)
>>>readable.
>>
>> Why isn't the 'background' hosted in the picturebox.
>>
>> J
>>
>>>
>>>"Mike Williams" <M***@WhiskyAndCoke.com> schreef in bericht
>>>news:die3om$pq9$1@newsg3.svr.pol.co.uk...
>>>> "Bart Steur" <soln***@xs4all.nl> wrote in message
>>>> news:uOBw3YazFHA.1256@TK2MSFTNGP09.phx.gbl...
>>>>
>>>>> The picturebox is a container for 1 or more text boxes. Underneath
>>>>> the picture box is a image with some text that needs to be typed into
>>>>> the textbox(es).
>>>>
>>>> You've got me confused there, Bart. If you don't want to see the Picture
>>>> Box then why is it there? Why not simply place the Text Boxes themselves
>>>> over the background image? Can you please be a bit more specific as to
>>>> exactly what it is you want to do.
>>>>
>>>> Mike
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>> Jan Hyde (VB MVP)
>>
>> --
>> Arrest: What you take when you are tired.  (Leopold Fechtner)
>>
>> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>>
>


Jan Hyde (VB MVP)

--
Lysdexia: a peech imspediment we live to learn with. (Ed Hexter)

[Abolish the TV Licence - http://www.tvlicensing.biz/]
Author
11 Oct 2005 9:57 AM
Bart Steur
The image underneath (lower in z-order) is a Kodak Image Control. It
contains a Multi Image TIFF. I place highlights (annotations) on the tiff
image. The highlights mark some textparts that need to be typed into the
textbox(es) in the TRANSPARENT picturebox control. All I want to know, can
you make a picturebox transparent. I've tried the way you can you to make a
Form transparent (using SetLayeredWindowAttributes), but that doesn't work
for a Picturebox.

Anyone?


Show quoteHide quote
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
news:t12nk1pmr9ae62u7dmnf96fmb7bcbb5td0@4ax.com...
> "Bart Steur" <soln***@xs4all.nl>'s wild thoughts were
> released on Tue, 11 Oct 2005 10:12:29 +0200 bearing the
> following fruit:
>
>>What do you mean with Background hosted?
>
> I asume you have set the background of the form to a
> picture? Ie the form is hosting the picture.
>
> Why not set the picture property of the *picture* box
> instead
>
> J
>
>>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>>news:ocsmk19feq1blq9k50pffmi3pc5opf64gm@4ax.com...
>>> "Bart Steur" <bstn***@xs4all.nl>'s wild thoughts were
>>> released on Mon, 10 Oct 2005 19:54:39 +0200 bearing the
>>> following fruit:
>>>
>>>>I want the possiblity to move the textboxes around, since there can be
>>>>more
>>>>than one, the picturebox (as container) can grow quite large. Therefore
>>>>I
>>>>want it to be transparent, so the background is still (partially)
>>>>readable.
>>>
>>> Why isn't the 'background' hosted in the picturebox.
>>>
>>> J
>>>
>>>>
>>>>"Mike Williams" <M***@WhiskyAndCoke.com> schreef in bericht
>>>>news:die3om$pq9$1@newsg3.svr.pol.co.uk...
>>>>> "Bart Steur" <soln***@xs4all.nl> wrote in message
>>>>> news:uOBw3YazFHA.1256@TK2MSFTNGP09.phx.gbl...
>>>>>
>>>>>> The picturebox is a container for 1 or more text boxes. Underneath
>>>>>> the picture box is a image with some text that needs to be typed into
>>>>>> the textbox(es).
>>>>>
>>>>> You've got me confused there, Bart. If you don't want to see the
>>>>> Picture
>>>>> Box then why is it there? Why not simply place the Text Boxes
>>>>> themselves
>>>>> over the background image? Can you please be a bit more specific as to
>>>>> exactly what it is you want to do.
>>>>>
>>>>> Mike
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> Jan Hyde (VB MVP)
>>>
>>> --
>>> Arrest: What you take when you are tired.  (Leopold Fechtner)
>>>
>>> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>>>
>>
>
>
> Jan Hyde (VB MVP)
>
> --
> Lysdexia: a peech imspediment we live to learn with. (Ed Hexter)
>
> [Abolish the TV Licence - http://www.tvlicensing.biz/]
>
Author
11 Oct 2005 11:00 AM
Mike Williams
"Bart Steur" <soln***@xs4all.nl> wrote in message
news:OP9H1okzFHA.3588@tk2msftngp13.phx.gbl...

> The image underneath (lower in z-order) is a Kodak Image Control.
> It contains a Multi Image TIFF. I place highlights (annotations) on the
> tiff image. The highlights mark some textparts that need to be typed
> into the textbox(es) in the TRANSPARENT picturebox control. All
> I want to know, can you make a picturebox transparent. I've tried
> the way you can you to make a Form transparent (using SetLayered
> WindowAttributes), but that doesn't work for a Picturebox.

I've written code years ago to make picture boxes transparent, but it
doesn't seem to work on XP. There is probably another way of doing it, but I
haven't got time to look into it at the moment. By the way, why did you not
take up Jan's suggestion of using the Picture Box (rather than the Form) as
the Kodak Image Control's container?Another way out would be to write code
that checks at run time what controls are in the Picture Box and then moves
then into the Form instead at the appropriate positions and then gets rid of
the Picture Box altogether (or at least gets rid of its visual presence by
setting its Visible property to False). That would certainly achieve the
effect you seem to want (where the picture box is really only acting as a
"design time" container). Try the following. The example is for a borderless
picture box (which you could set to whatever backcolour you wanted so that
you could easily see it in the IDE). It would, of course, also be possible
to modify the code so as to automatically work correctly on picture boxes
with borders as well. Anyway, try the following code (which assumes the name
of your picture box is Picture1):

Mike

Private Sub Form_Load()
Dim oldmode As Long, ctl As Control
oldmode = Me.ScaleMode
Me.ScaleMode = Picture1.ScaleMode
On Error Resume Next
For Each ctl In Controls
  If ctl.Container.Name = "Picture1" Then
  Set ctl.Container = Me
  ctl.Move ctl.Left + Picture1.Left, ctl.Top + Picture1.Top
  End If
Next ctl
Picture1.Visible = False
Me.ScaleMode = oldmode
End Sub
Author
11 Oct 2005 11:36 AM
J French
On Tue, 11 Oct 2005 11:57:33 +0200, "Bart Steur" <soln***@xs4all.nl>
wrote:

>The image underneath (lower in z-order) is a Kodak Image Control. It
>contains a Multi Image TIFF. I place highlights (annotations) on the tiff
>image. The highlights mark some textparts that need to be typed into the
>textbox(es) in the TRANSPARENT picturebox control. All I want to know, can
>you make a picturebox transparent. I've tried the way you can you to make a
>Form transparent (using SetLayeredWindowAttributes), but that doesn't work
>for a Picturebox.

Have you considered ditching the PictureBox and using a UserControl
instead ?

A compiled in UserControl certainly can be transparent
- it also makes a good container

Basically it is a Picturebox on steroids
Author
11 Oct 2005 12:19 PM
Bart Steur
Now we're talking

That's certainly a great idea.

Thx

Bart

Show quoteHide quote
"J French" <erew***@nowhere.uk> wrote in message
news:434ba2fd.273530813@news.btopenworld.com...
> On Tue, 11 Oct 2005 11:57:33 +0200, "Bart Steur" <soln***@xs4all.nl>
> wrote:
>
>>The image underneath (lower in z-order) is a Kodak Image Control. It
>>contains a Multi Image TIFF. I place highlights (annotations) on the tiff
>>image. The highlights mark some textparts that need to be typed into the
>>textbox(es) in the TRANSPARENT picturebox control. All I want to know, can
>>you make a picturebox transparent. I've tried the way you can you to make
>>a
>>Form transparent (using SetLayeredWindowAttributes), but that doesn't work
>>for a Picturebox.
>
> Have you considered ditching the PictureBox and using a UserControl
> instead ?
>
> A compiled in UserControl certainly can be transparent
> - it also makes a good container
>
> Basically it is a Picturebox on steroids
Author
11 Oct 2005 12:26 PM
Bart Steur
No, that's not what I meant. Sorry. It should be semi-transparent, something
like a fade or drop shadow. With SetLayeredWindowAttributes you can set the
transparency from 0 (fully transparent) to 255 (Fully visible) Thats what I
need for my picturebox. Sorry for setting you guys on the wrong track

B.


Show quoteHide quote
"J French" <erew***@nowhere.uk> wrote in message
news:434ba2fd.273530813@news.btopenworld.com...
> On Tue, 11 Oct 2005 11:57:33 +0200, "Bart Steur" <soln***@xs4all.nl>
> wrote:
>
>>The image underneath (lower in z-order) is a Kodak Image Control. It
>>contains a Multi Image TIFF. I place highlights (annotations) on the tiff
>>image. The highlights mark some textparts that need to be typed into the
>>textbox(es) in the TRANSPARENT picturebox control. All I want to know, can
>>you make a picturebox transparent. I've tried the way you can you to make
>>a
>>Form transparent (using SetLayeredWindowAttributes), but that doesn't work
>>for a Picturebox.
>
> Have you considered ditching the PictureBox and using a UserControl
> instead ?
>
> A compiled in UserControl certainly can be transparent
> - it also makes a good container
>
> Basically it is a Picturebox on steroids
Author
11 Oct 2005 1:27 PM
Mike Williams
"Bart Steur" <soln***@xs4all.nl> wrote in message
news:uIhVU8lzFHA.2924@TK2MSFTNGP15.phx.gbl...

> No, that's not what I meant. Sorry. It should be semi-transparent,
> something like a fade or drop shadow. With SetLayeredWindow
> Attributes you can set the transparency from 0 (fully transparent)
> to 255 (Fully visible) Thats what I need for my picturebox. Sorry
> for setting you guys on the wrong track

That's okay. Now we know what you're after we may be able to help a little
more. Actually I haven't used semi transparent windows before, but I've just
checked it out and it appears that you are correct. It works fine for VB
Forms but doesn't appear to work at all for VB Picture Boxes (at least as
far as I can see at the moment). But now we know what you're after perhaps
we can suggest another way to achieve the same effect. How about a semi
transparent borderless VB Form on top of your main VB form (Loaded with the
"Me" attribute to keep it on top of the main Form). We can certainly make
that second Form semi transparent, and with a bit of "jiggery pokery" we can
also make it nicely follow the main Form as the main Form is dragged
(behaving in much the same way as a Picture Box would). Try the following
code. Start a new VB project which uses two Forms (Form1 is the main form
and Form2 the second). In the IDE set the BorderStyle of Form 2 to none and
"sprinkle it" with a few Text Boxes and Command Buttons and such like. Also
add a standard code module. Then paste in the following two code blocks
(Module 1code and Form1 code). By the way, change the hard coded
"c:\tulips.jpg" filename in the LoadPicture function to a picture that
exists on your own machine. I know it's probably not exactly what you want
(just a simple test bed at the moment), but is it perhaps "on the way
there"?

Mike

' ************** START MODULE CODE ******************
Option Explicit
Public lOldWndProc As Long
Public lOldWndProc2 As Long
Private Const WM_MOVE = &H3
Private Const WM_SIZE = &H5
Public Const GWL_WNDPROC = (-4)
Public Declare Function SetWindowLongA Lib "user32.dll" _
  (ByVal hWnd As Long, ByVal nIndex As Long, _
  ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProcA Lib "user32.dll" _
  (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, _
  ByVal Msg As Long, ByVal wParam As Long, _
  ByVal lParam As Long) As Long
Public Const LWA_COLORKEY = &H1
Public Const LWA_ALPHA = &H2
Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_LAYERED = &H80000
Public Declare Function GetWindowLong Lib "user32" _
  Alias "GetWindowLongA" (ByVal hWnd As Long, _
  ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" _
  Alias "SetWindowLongA" (ByVal hWnd As Long, _
  ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function SetLayeredWindowAttributes _
  Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, _
  ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Public Function WndProc(ByVal hWnd As Long, ByVal Msg As _
  Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  If Msg = WM_MOVE Then
    Form2.Top = Form1.Top + 2000
    Form2.Left = Form1.Left + 2000
  ElseIf Msg = WM_SIZE Then
    Form2.Top = Form1.Top + 2000
    Form2.Left = Form1.Left + 2000
  End If
  WndProc = CallWindowProcA(lOldWndProc, hWnd, Msg, _
    wParam, lParam)
End Function
' ************** END MODULE CODE ******************
'
'
'
' ************** START FORM1 CODE ******************
Option Explicit

Private Sub Form_Load()
Dim ret As Long
  Me.Picture = LoadPicture("c:\tulips.jpg")
  Me.Move 0, 0, 10000, 8000
  DoEvents
  Form2.Move Form1.Left + 2000, Form1.Top + 2000, 6000, 4000
  Form2.Show , Me
  ret = GetWindowLong(Form2.hWnd, GWL_EXSTYLE)
  ret = ret Or WS_EX_LAYERED
  SetWindowLong Form2.hWnd, GWL_EXSTYLE, ret
  SetLayeredWindowAttributes Form2.hWnd, 0, 128, LWA_ALPHA
  lOldWndProc = SetWindowLongA(Me.hWnd, GWL_WNDPROC, _
    AddressOf WndProc)
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, _
  UnloadMode As Integer)
SetWindowLongA hWnd, GWL_WNDPROC, lOldWndProc
End Sub

Private Sub Form_Unload(Cancel As Integer)
Unload Form2
End Sub
' ************** END FORM1 CODE ******************
Author
10 Oct 2005 9:56 PM
DanS
"Bart Steur" <soln***@xs4all.nl> wrote in news:uOBw3YazFHA.1256
@TK2MSFTNGP09.phx.gbl:

> The picturebox is a container for 1 or more text boxes. Underneath the
> picture box is a image with some text that needs to be typed into the
> textbox(es).
>

i typically use a frame for a container, with no border, and set the frame
background color to the color of the window it is on top of.

does 'Underneath the picture box' mean in the z-order, or in a 2-d world is
it the image below the picturebox ?
Author
11 Oct 2005 7:35 AM
Bart Steur
The image underneath (lower in z-order) is a Kodak Image Control. It
contains a Multi Image TIFF. I place highlights (annotations) on the tiff
image. The highlights mark some textparts that need to be typed into the
textbox(es) in the TRANSPARENT picturebox control. All I want to know, can
you make a picturebox transparent. I've tried the way you can you to make a
Form transparent (using SetLayeredWindowAttributes), but that doesn't work
for a Picturebox.

Anyone?


Show quoteHide quote
"DanS" <t.h.i.s.n.t.h.a.t@a.d.e.l.p.h.i.a..n.e.t> wrote in message
news:Xns96EBB74EBDA10idispcom@216.196.97.142...
> "Bart Steur" <soln***@xs4all.nl> wrote in news:uOBw3YazFHA.1256
> @TK2MSFTNGP09.phx.gbl:
>
>> The picturebox is a container for 1 or more text boxes. Underneath the
>> picture box is a image with some text that needs to be typed into the
>> textbox(es).
>>
>
> i typically use a frame for a container, with no border, and set the frame
> background color to the color of the window it is on top of.
>
> does 'Underneath the picture box' mean in the z-order, or in a 2-d world
> is
> it the image below the picturebox ?
>