marc9101
Messages postés8Date d'inscriptionmardi 3 octobre 2006StatutMembreDernière intervention10 octobre 2006
-
4 oct. 2006 à 15:02
jmfmarques
Messages postés7668Date d'inscriptionsamedi 5 novembre 2005StatutMembreDernière intervention22 août 2014
-
2 nov. 2006 à 08:55
voila j'ai une question :
j'ai une form mdichild. Comment faire pour la rendre transparente?? cad, comment faire pour que seul le fond de la form soit invisible ?? mais que tous les bouttons et autres images .... soient visibles ??
PCPT
Messages postés13280Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201848 4 oct. 2006 à 17:05
salut,
suffit de choisir une couleur et de la rendre invisible
Option Explicit
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
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 crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags _
As Long) As Long
'
Private Sub Form_Load()
Me.BackColor = RGB (255, 0, 255)
Dim Ret As Long
Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes Me.hWnd, Me.BackColor, 128, LWA_COLORKEY
End Sub
marc9101
Messages postés8Date d'inscriptionmardi 3 octobre 2006StatutMembreDernière intervention10 octobre 2006 9 oct. 2006 à 20:55
petite rectification, ca marche pour une form classique, mais moi j'ai une mdi child !!! et ca ne marche pas !quelqu'un ne saurait il pas comment faire pour une mdichild svp ???
PCPT
Messages postés13280Date d'inscriptionlundi 13 décembre 2004StatutMembreDernière intervention 3 février 201848 9 oct. 2006 à 21:08
salut,
ah oui en effet (c'est fou ce que je hais les mdi ^^)
bref, après modif j'ai réussi mais...
qu'est-ce que tu veux?.... voir le bureau? ou voir le fond de la fenêtre mère.....
bureau c'est ok (testé en mdi)
<hr size="2" width="100%" />Prenez un instant pour répondre à ce sondage svp
jmfmarques
Messages postés7668Date d'inscriptionsamedi 5 novembre 2005StatutMembreDernière intervention22 août 201427 2 nov. 2006 à 08:55
Mets ceci dans le code de la Form (pas dans celui de la Mdi)
Option Explicit
Private Declare Function CreateRectRgn Lib _
"gdi32" (ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib _
"gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, _
ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Declare Function SetWindowRgn Lib _
"user32" (ByVal hWnd As Long, ByVal hRgn As Long, _
ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib _
"gdi32" (ByVal hObject As Long) As Long
Private Sub Form_Activate()
Dim rgnForm As Long, rgnCombined As Long
Dim rgnControl As Long, x As Long
Dim formWidth As Single, formHeight As Single
Dim borderWidth As Single, titleHeight As Single
Dim ctlLeft As Single, ctlTop As Single
Dim ctlWidth As Single, ctlHeight As Single
Dim ctl As Control
borderWidth = (Me.Width - Me.ScaleWidth) / 2
titleHeight = Me.Height - Me.ScaleHeight - borderWidth
borderWidth = ScaleX(borderWidth, vbTwips, vbPixels)
titleHeight = ScaleY(titleHeight, vbTwips, vbPixels)
formWidth = ScaleX(Me.Width, vbTwips, vbPixels)
formHeight = ScaleY(Me.Height, vbTwips, vbPixels)
rgnForm = CreateRectRgn(0, 0, formWidth, formHeight)
rgnCombined = CreateRectRgn(0, 0, 0, 0)
x = CombineRgn(rgnCombined, rgnForm, rgnForm, RGN_DIFF)
For Each ctl In Controls
On Error Resume Next
If TypeOf ctl.Container Is Form Then
ctlLeft = ScaleX(ctl.Left, vbTwips, vbPixels) + borderWidth
ctlTop = ScaleX(ctl.Top, vbTwips, vbPixels) + titleHeight
ctlWidth = ScaleX(ctl.Width, vbTwips, vbPixels) + ctlLeft
ctlHeight = ScaleX(ctl.Height, vbTwips, vbPixels) + ctlTop
rgnControl = CreateRectRgn(ctlLeft, ctlTop, ctlWidth, ctlHeight)
x = CombineRgn(rgnCombined, rgnCombined, rgnControl, RGN_OR)
End If
Next ctl
SetWindowRgn hWnd, rgnCombined, True
x = DeleteObject(rgnCombined)
x = DeleteObject(rgnControl)
x = DeleteObject(rgnForm)
End Sub
Et dis-moi si c'est ce que tu voulais !
Bien sur (pour y voir plus clair) : mets quelques contrôles (qui devront rester opaques) sur ta Form
Bonne journée