28/09/09 19:58
piter123
ho trovato questo codice, ma rende la form figlia solo trasparente al 100%, è possibile intervenire su questo codice per poter settare la percentuale di trasparenza ?
mille grazie
Private Const REG_OR = 2
Private Const REG_MIN = 4
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
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 Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, Y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Dim GlassForm As Long
'-----------------------------------------------------------------------------
Private Sub Form_Click()
TraspGlass 1
' TraspGlass 0 x tornare allo stato precedente non-glass
' TraspGlass 1 ' ...Glass PARZIALE (Resta la caption del form)
' TraspGlass 2 ' ...Glass TOTALE (restano solo i controlli senza form)
End Sub
'-----------------------------------------------------------------------------
Private Sub Form_Initialize()
Me.Height = 3600
Me.Width = 4800
Me.ScaleMode = vbPixels ' Non modificare!!!
Me.Caption = "Un click con il tasto del mouse su questo form..."
End Sub
'-----------------------------------------------------------------------------
Private Sub TraspGlass(GlassFX As Integer)
Dim w As Single, h As Single, Contorno As Single, topEye As Single
Dim i As Long, k As Long, n As Long, q As Long
Dim PosTop As Double, PosLeft As Double
' Conversione su assi X/Y | width/height | scalewidth/scaleheight
w = ScaleX(Width, vbTwips, vbPixels)
h = ScaleY(Height, vbTwips, vbPixels)
' Verifica lo stato...
If GlassFX = 0 Then
GlassForm = CreateRectRgn(0, 0, w, h)
SetWindowRgn hwnd, GlassForm, True
Exit Sub
End If
GlassForm = CreateRectRgn(0, 0, 0, 0)
Contorno = (w - ScaleWidth) / 2
topEye = h - Contorno - ScaleHeight
If GlassFX = 1 Then
k = CreateRectRgn(0, 0, w, h)
n = CreateRectRgn(Contorno, topEye, w - Contorno, h - Contorno)
CombineRgn GlassForm, k, n, REG_MIN
End If
' Traspone la nuova regione sul form...
For i = 0 To Me.Controls.Count - 1
If Me.Controls(i).Visible = True Then
PosLeft = ScaleX(Me.Controls(i).Left, Me.ScaleMode, vbPixels) + Contorno
PosTop = ScaleX(Me.Controls(i).Top, Me.ScaleMode, vbPixels) + topEye
q = CreateRectRgn(PosLeft, PosTop, _
PosLeft + ScaleX(Me.Controls(i).Width, Me.ScaleMode, vbPixels), PosTop + ScaleY(Me.Controls(i).Height, Me.ScaleMode, vbPixels))
CombineRgn GlassForm, q, GlassForm, REG_OR
End If
Next
' Esegue...
SetWindowRgn hwnd, GlassForm, True
End Sub
'-----------------------------------------------------------------------------
Private Sub Form_Load()
' Centra il form
CentraForm Form1
' On Top
MakeTopMost Me.hwnd
End Sub
'-----------------------------------------------------------------------------
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
' Scarca l'oggetto GlassForm dalla memoria.
SetWindowRgn hwnd, 0, False
DeleteObject GlassForm
' Scarica il form dalla memoria
Unload Form1
Set Form1 = Nothing
End Sub
'-----------------------------------------------------------------------------
Public Sub CentraForm(MyForm As Form)
' Centra il form
MyForm.Top = (Screen.Height - MyForm.Height) / 2
MyForm.Left = (Screen.Width - MyForm.Width) / 2
End Sub
'-----------------------------------------------------------------------------
Sub MakeNormal(Handle As Long)
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
'-----------------------------------------------------------------------------
Sub MakeTopMost(Handle As Long)
SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
mille grazie
Private Const REG_OR = 2
Private Const REG_MIN = 4
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
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 Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, Y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Dim GlassForm As Long
'-----------------------------------------------------------------------------
Private Sub Form_Click()
TraspGlass 1
' TraspGlass 0 x tornare allo stato precedente non-glass
' TraspGlass 1 ' ...Glass PARZIALE (Resta la caption del form)
' TraspGlass 2 ' ...Glass TOTALE (restano solo i controlli senza form)
End Sub
'-----------------------------------------------------------------------------
Private Sub Form_Initialize()
Me.Height = 3600
Me.Width = 4800
Me.ScaleMode = vbPixels ' Non modificare!!!
Me.Caption = "Un click con il tasto del mouse su questo form..."
End Sub
'-----------------------------------------------------------------------------
Private Sub TraspGlass(GlassFX As Integer)
Dim w As Single, h As Single, Contorno As Single, topEye As Single
Dim i As Long, k As Long, n As Long, q As Long
Dim PosTop As Double, PosLeft As Double
' Conversione su assi X/Y | width/height | scalewidth/scaleheight
w = ScaleX(Width, vbTwips, vbPixels)
h = ScaleY(Height, vbTwips, vbPixels)
' Verifica lo stato...
If GlassFX = 0 Then
GlassForm = CreateRectRgn(0, 0, w, h)
SetWindowRgn hwnd, GlassForm, True
Exit Sub
End If
GlassForm = CreateRectRgn(0, 0, 0, 0)
Contorno = (w - ScaleWidth) / 2
topEye = h - Contorno - ScaleHeight
If GlassFX = 1 Then
k = CreateRectRgn(0, 0, w, h)
n = CreateRectRgn(Contorno, topEye, w - Contorno, h - Contorno)
CombineRgn GlassForm, k, n, REG_MIN
End If
' Traspone la nuova regione sul form...
For i = 0 To Me.Controls.Count - 1
If Me.Controls(i).Visible = True Then
PosLeft = ScaleX(Me.Controls(i).Left, Me.ScaleMode, vbPixels) + Contorno
PosTop = ScaleX(Me.Controls(i).Top, Me.ScaleMode, vbPixels) + topEye
q = CreateRectRgn(PosLeft, PosTop, _
PosLeft + ScaleX(Me.Controls(i).Width, Me.ScaleMode, vbPixels), PosTop + ScaleY(Me.Controls(i).Height, Me.ScaleMode, vbPixels))
CombineRgn GlassForm, q, GlassForm, REG_OR
End If
Next
' Esegue...
SetWindowRgn hwnd, GlassForm, True
End Sub
'-----------------------------------------------------------------------------
Private Sub Form_Load()
' Centra il form
CentraForm Form1
' On Top
MakeTopMost Me.hwnd
End Sub
'-----------------------------------------------------------------------------
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
' Scarca l'oggetto GlassForm dalla memoria.
SetWindowRgn hwnd, 0, False
DeleteObject GlassForm
' Scarica il form dalla memoria
Unload Form1
Set Form1 = Nothing
End Sub
'-----------------------------------------------------------------------------
Public Sub CentraForm(MyForm As Form)
' Centra il form
MyForm.Top = (Screen.Height - MyForm.Height) / 2
MyForm.Left = (Screen.Width - MyForm.Width) / 2
End Sub
'-----------------------------------------------------------------------------
Sub MakeNormal(Handle As Long)
SetWindowPos Handle, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
'-----------------------------------------------------------------------------
Sub MakeTopMost(Handle As Long)
SetWindowPos Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
End Sub
aaa
29/09/09 5:08
theprogrammer
Postato originariamente da piter123:
ho trovato questo codice, ma rende la form figlia solo trasparente al 100%, è possibile intervenire su questo codice per poter settare la percentuale di trasparenza ?
ho trovato questo codice, ma rende la form figlia solo trasparente al 100%, è possibile intervenire su questo codice per poter settare la percentuale di trasparenza ?
No ...
aaa
29/09/09 6:10
piter123
mille grazie comunque, anche per l'interessamento, a questo punto penso risolverò utilizzando una form esterma alla famiglia mdi e la sovrapporrò ogni volta che serve.
Ora devo capire come intercettare il trascinamento della barra della form per ridare le eventuali nuove coordinate alla eventuale form con opacity.
ciao e grazie
Ora devo capire come intercettare il trascinamento della barra della form per ridare le eventuali nuove coordinate alla eventuale form con opacity.
ciao e grazie
aaa
29/09/09 7:11
theprogrammer
Postato originariamente da piter123:
mille grazie comunque, anche per l'interessamento, a questo punto penso risolverò utilizzando una form esterma alla famiglia mdi e la sovrapporrò ogni volta che serve.
Ora devo capire come intercettare il trascinamento della barra della form per ridare le eventuali nuove coordinate alla eventuale form con opacity.
ciao e grazie
mille grazie comunque, anche per l'interessamento, a questo punto penso risolverò utilizzando una form esterma alla famiglia mdi e la sovrapporrò ogni volta che serve.
Ora devo capire come intercettare il trascinamento della barra della form per ridare le eventuali nuove coordinate alla eventuale form con opacity.
ciao e grazie
Per completezza, ho provato anche con un form esterno e la SetParent, ma il form non viene ridisegnato correttamente ...
aaa
05/10/09 7:09
piter123
scusate, esiste eventualmente un ocx per rendere opacity una form, magari con quello risolvo il problema all'interno di una MDI. Oppure è possibile (ho letto qualcosa in giro ma senza ottenere risultati) creare una form figlia e renderla opacity applicandoci sopra una foto semitrasparente ?
Mille grazie
Mille grazie
aaa