jmfmarques
Messages postés
7666
Date d'inscription
samedi 5 novembre 2005
Statut
Membre
Dernière intervention
22 août 2014
27
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 Const RGN_AND = 1
Private Const RGN_OR = 2
Private Const RGN_XOR = 3
Private Const RGN_DIFF = 4
Private Const RGN_COPY = 5
Private Sub Command2_Click()
End
End Sub
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