OVH Cloud OVH Cloud

Transparence sur VB6

9 réponses
Avatar
News79
Salut
Connaissez vous une API ou quoique ce soit qui pourrait rendre une image
transparente ?
Image dans n'importe quel contrôle, Image ou PictureBox ou autre !
Merci

--

9 réponses

Avatar
christophe-pasde
Bonjour,

Précise un peu
Transparente vis à vis de quoi ?
Quel type d'image (Gif ?)

S'agit-il d'utiliser l'Alpha channel ?

Christophe



News79 a écrit :

Salut
Connaissez vous une API ou quoique ce soit qui pourrait rendre une image
transparente ?
Image dans n'importe quel contrôle, Image ou PictureBox ou autre !
Merci

--





Avatar
News79
salut
Je crois que finalement ca ne doit pas être possible !! :-)
Ce n'est pas évident de l'expliquer, disons transparente dans le sens ou
les couleurs de l'image sont atténuées
pour donner l'impression de transparence, comme dans une appli de retouche
d'image, tu augmentes la luminosité et bien
le noir et les couleurs vont s'adoucir... ca donne l'impression d'avoir
une glace plus ou moins opaque sur l'image !
c'est pas clair ? je sais :-) désolé

Merci quand meme.

Laurent

"christophe-pasde<> @wanadoo.fr>" <"christophe-pasde<> a écrit dans le
message de news:4164eb0a$0$17796$
> Bonjour,
>
> Précise un peu
> Transparente vis à vis de quoi ?
> Quel type d'image (Gif ?)
>
> S'agit-il d'utiliser l'Alpha channel ?
>
> Christophe
>
>
>
> News79 a écrit :
>
> > Salut
> > Connaissez vous une API ou quoique ce soit qui pourrait rendre une
image
> > transparente ?
> > Image dans n'importe quel contrôle, Image ou PictureBox ou autre !
> > Merci
> >
> > --
> >
> >
> >
Avatar
christophe-pasde
Dans ce cas il suffit de modifeir la table de couleur de l'image et la
faire tendre vers 255,255,255.

Christophe


News79 a écrit :

salut
Je crois que finalement ca ne doit pas être possible !! :-)
Ce n'est pas évident de l'expliquer, disons transparente dans le sens ou
les couleurs de l'image sont atténuées
pour donner l'impression de transparence, comme dans une appli de retouche
d'image, tu augmentes la luminosité et bien
le noir et les couleurs vont s'adoucir... ca donne l'impression d'avoir
une glace plus ou moins opaque sur l'image !
c'est pas clair ? je sais :-) désolé

Merci quand meme.

Laurent

"christophe-pasde<> @wanadoo.fr>" <"christophe-pasde<> a écrit dans le
message de news:4164eb0a$0$17796$
> Bonjour,
>
> Précise un peu
> Transparente vis à vis de quoi ?
> Quel type d'image (Gif ?)
>
> S'agit-il d'utiliser l'Alpha channel ?
>
> Christophe
>
>
>
> News79 a écrit :
>
> > Salut
> > Connaissez vous une API ou quoique ce soit qui pourrait rendre une
image
> > transparente ?
> > Image dans n'importe quel contrôle, Image ou PictureBox ou autre !
> > Merci
> >
> > --
> >
> >
> >




Avatar
News79
je ne vois pas de quoi tu veux parler
car on ne peut pas jouer sur le RGB d'une image dans un controle !
mais c'est pas grave... :-)
bon week

--
"christophe-pasde<> @wanadoo.fr>" <"christophe-pasde<> a écrit dans le
message de news:416539db$0$28821$
> Dans ce cas il suffit de modifeir la table de couleur de l'image et la
> faire tendre vers 255,255,255.
>
> Christophe
>
>
> News79 a écrit :
>
> > salut
> > Je crois que finalement ca ne doit pas être possible !! :-)
> > Ce n'est pas évident de l'expliquer, disons transparente dans le
sens ou
> > les couleurs de l'image sont atténuées
> > pour donner l'impression de transparence, comme dans une appli de
retouche
> > d'image, tu augmentes la luminosité et bien
> > le noir et les couleurs vont s'adoucir... ca donne l'impression
d'avoir
> > une glace plus ou moins opaque sur l'image !
> > c'est pas clair ? je sais :-) désolé
> >
> > Merci quand meme.
> >
> > Laurent
> >
> > "christophe-pasde<> @wanadoo.fr>" <"christophe-pasde<> a écrit dans
le
> > message de news:4164eb0a$0$17796$
> > > Bonjour,
> > >
> > > Précise un peu
> > > Transparente vis à vis de quoi ?
> > > Quel type d'image (Gif ?)
> > >
> > > S'agit-il d'utiliser l'Alpha channel ?
> > >
> > > Christophe
> > >
> > >
> > >
> > > News79 a écrit :
> > >
> > > > Salut
> > > > Connaissez vous une API ou quoique ce soit qui pourrait rendre
une
> > image
> > > > transparente ?
> > > > Image dans n'importe quel contrôle, Image ou PictureBox ou
autre !
> > > > Merci
> > > >
> > > > --
> > > >
> > > >
> > > >
> >
> >
Avatar
jmn
Question pleine d'intérêt artistique... et après quelques recherches vous
pouvez regarder du coté des fonctions SetLayeredWindowAttribute,
TransparentBlt, AlphaBlend, etc. du GDI Window (mais uniquement sous 98,
2000 et XP).

Vous pouvez effectivement rendre transparent (de 0 (inivisible) à 255
(opaque) n'importe quel objet Window qui dispose d'un Hdc en suivant les
exemples de MSDN.
Avatar
jmn
J'ai encore mieux !
========================================
HOWTO: Create a Layered Window in Visual Basic

----------------------------------------------------------------------------
----
The information in this article applies to:

Microsoft Visual Basic Professional and Enterprise Editions for Windows,
versions 4.0, 5.0, 6.0

----------------------------------------------------------------------------
----


SUMMARY
Microsoft Windows 2000 has the ability to create translucent windows. These
windows are called layered windows. This article describes how to create a
layered window by using Visual Basic.



MORE INFORMATION

Step-by-Step Example
Create a new Standard EXE project in Visual Basic. Form1 is created by
default.


Add the following code to the General Declarations section of Form1:



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 SetLayeredWindowAttributes Lib "user32" _
(ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long

Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
Private Const WS_EX_TRANSPARENT = &H20&
Private Const LWA_ALPHA = &H2&

Option Explicit

Private Sub Form_Load()
Dim lOldStyle As Long
Dim bTrans As Byte ' The level of transparency (0 - 255)

bTrans = 128
lOldStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
SetWindowLong Me.hWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
SetLayeredWindowAttributes Me.hWnd, 0, bTrans, LWA_ALPHA
End Sub
Run the example program by pressing the F5 key. The form should look like a
normal Visual Basic window. However, windows that are lower in the Z order
should be partially visible through the window.

It is also possible to make mouse events go through to the lower windows by
changing the preceding code line
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
to:
SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED Or
WS_EX_TRANSPARENT
However, the form does not remain topmost if another form is activated. See
the "Reference" section for information on how to create a form that remains
on top.



REFERENCES
For additional information how to create a topmost window, click the article
number below to view the article in the Microsoft Knowledge Base:

Q184297 HOWTO: Create a Form That Always Stays on Top

Additional query words:

Keywords : kbAPI kbWinOS2000 kbSDKWin32 kbVBp kbVBp400 kbVBp500 kbVBp600
kbForms kbGrpVB kbDSupport
Version : WINDOWS:4.0,5.0,6.0
Platform : WINDOWS
Issue type : kbhowto
Technology : kbvcSearch


Last Reviewed: July 12, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.




----------------------------------------------------------------------------
----
Send feedback to MSDN.Look here for MSDN Online resources.
Avatar
christophe-pasde
Bonjour,

Si tu gères uniquement avec VB oui, mais si tu passes par les API ...

Christophe

News79 a écrit :

je ne vois pas de quoi tu veux parler
car on ne peut pas jouer sur le RGB d'une image dans un controle !
mais c'est pas grave... :-)
bon week

--
"christophe-pasde<> @wanadoo.fr>" <"christophe-pasde<> a écrit dans le
message de news:416539db$0$28821$
> Dans ce cas il suffit de modifeir la table de couleur de l'image et la
> faire tendre vers 255,255,255.
>
> Christophe
>
>
> News79 a écrit :
>
> > salut
> > Je crois que finalement ca ne doit pas être possible !! :-)
> > Ce n'est pas évident de l'expliquer, disons transparente dans le
sens ou
> > les couleurs de l'image sont atténuées
> > pour donner l'impression de transparence, comme dans une appli de
retouche
> > d'image, tu augmentes la luminosité et bien
> > le noir et les couleurs vont s'adoucir... ca donne l'impression
d'avoir
> > une glace plus ou moins opaque sur l'image !
> > c'est pas clair ? je sais :-) désolé
> >
> > Merci quand meme.
> >
> > Laurent
> >
> > "christophe-pasde<> @wanadoo.fr>" <"christophe-pasde<> a écrit dans
le
> > message de news:4164eb0a$0$17796$
> > > Bonjour,
> > >
> > > Précise un peu
> > > Transparente vis à vis de quoi ?
> > > Quel type d'image (Gif ?)
> > >
> > > S'agit-il d'utiliser l'Alpha channel ?
> > >
> > > Christophe
> > >
> > >
> > >
> > > News79 a écrit :
> > >
> > > > Salut
> > > > Connaissez vous une API ou quoique ce soit qui pourrait rendre
une
> > image
> > > > transparente ?
> > > > Image dans n'importe quel contrôle, Image ou PictureBox ou
autre !
> > > > Merci
> > > >
> > > > --
> > > >
> > > >
> > > >
> >
> >




Avatar
News79
MERCI BCP
je vais essayer ! :-)
--
Laurent


"jmn" a écrit dans le message de
news:
> J'ai encore mieux !
> ======================================== >
> HOWTO: Create a Layered Window in Visual Basic
>


--------------------------------------------------------------------------


--
> ----
> The information in this article applies to:
>
> Microsoft Visual Basic Professional and Enterprise Editions for Windows,
> versions 4.0, 5.0, 6.0
>


--------------------------------------------------------------------------


--
> ----
>
>
> SUMMARY
> Microsoft Windows 2000 has the ability to create translucent windows.
These
> windows are called layered windows. This article describes how to create
a
> layered window by using Visual Basic.
>
>
>
> MORE INFORMATION
>
> Step-by-Step Example
> Create a new Standard EXE project in Visual Basic. Form1 is created by
> default.
>
>
> Add the following code to the General Declarations section of Form1:
>
>
>
> 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 SetLayeredWindowAttributes Lib "user32" _
> (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, _
> ByVal dwFlags As Long) As Long
>
> Private Const GWL_EXSTYLE = (-20)
> Private Const WS_EX_LAYERED = &H80000
> Private Const WS_EX_TRANSPARENT = &H20&
> Private Const LWA_ALPHA = &H2&
>
> Option Explicit
>
> Private Sub Form_Load()
> Dim lOldStyle As Long
> Dim bTrans As Byte ' The level of transparency (0 - 255)
>
> bTrans = 128
> lOldStyle = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
> SetWindowLong Me.hWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
> SetLayeredWindowAttributes Me.hWnd, 0, bTrans, LWA_ALPHA
> End Sub
> Run the example program by pressing the F5 key. The form should look
like a
> normal Visual Basic window. However, windows that are lower in the Z
order
> should be partially visible through the window.
>
> It is also possible to make mouse events go through to the lower windows
by
> changing the preceding code line
> SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED
> to:
> SetWindowLong Me.hwnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED Or
> WS_EX_TRANSPARENT
> However, the form does not remain topmost if another form is activated.
See
> the "Reference" section for information on how to create a form that
remains
> on top.
>
>
>
> REFERENCES
> For additional information how to create a topmost window, click the
article
> number below to view the article in the Microsoft Knowledge Base:
>
> Q184297 HOWTO: Create a Form That Always Stays on Top
>
> Additional query words:
>
> Keywords : kbAPI kbWinOS2000 kbSDKWin32 kbVBp kbVBp400 kbVBp500 kbVBp600
> kbForms kbGrpVB kbDSupport
> Version : WINDOWS:4.0,5.0,6.0
> Platform : WINDOWS
> Issue type : kbhowto
> Technology : kbvcSearch
>
>
> Last Reviewed: July 12, 2000
> © 2000 Microsoft Corporation. All rights reserved. Terms of Use.
>
>
>
>


--------------------------------------------------------------------------


--
> ----
> Send feedback to MSDN.Look here for MSDN Online resources.
>
>
Avatar
jmn
Cher Laurent, vous éprouverez un bonheur total en récupérant le code complet
d'une utlisation de la plupart des fonctionnalités des Layered Windows
disponible à :
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeIdB918&ln
gWId=1

JMN