Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Visual Basic 6 - Trasparenza form
Forum - Visual Basic 6 - Trasparenza form

Avatar
Systemsoft (Normal User)
Newbie


Messaggi: 7
Iscritto: 13/03/2009

Segnala al moderatore
Postato alle 18:17
Venerdì, 13/03/2009
Come si mette la trasparenza tipo vista su la form ?

PM Quote
Avatar
GrG (Member)
Guru^2


Messaggi: 3430
Iscritto: 21/08/2007

Segnala al moderatore
Postato alle 18:30
Venerdì, 13/03/2009
in un modulo:
Codice sorgente - presumibilmente VB.NET

  1. Option Explicit
  2.  
  3. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
  4. Private Declare Function UpdateLayeredWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcDst As Long, pptDst As Any, psize As Any, ByVal hdcSrc As Long, pptSrc As Any, crKey As Long, ByVal pblend As Long, ByVal dwFlags As Long) As Long
  5. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  6. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  7.  
  8. Private Const GWL_EXSTYLE = (-20)
  9. Private Const LWA_COLORKEY = &H1
  10. Private Const LWA_ALPHA = &H2
  11. Private Const ULW_COLORKEY = &H1
  12. Private Const ULW_ALPHA = &H2
  13. Private Const ULW_OPAQUE = &H4
  14. Private Const WS_EX_LAYERED = &H80000
  15.  
  16. Public Function isTransparent(ByVal hWnd As Long) As Boolean
  17. On Error Resume Next
  18. Dim Msg As Long
  19. Msg = GetWindowLong(hWnd, GWL_EXSTYLE)
  20. If (Msg And WS_EX_LAYERED) = WS_EX_LAYERED Then
  21.   isTransparent = True
  22. Else
  23.   isTransparent = False
  24. End If
  25. If Err Then
  26.   isTransparent = False
  27. End If
  28. End Function
  29.  
  30. Public Function MakeTransparent(ByVal hWnd As Long, Perc As Integer) As Long
  31. Dim Msg As Long
  32. On Error Resume Next
  33. If Perc < 0 Or Perc > 255 Then
  34.   MakeTransparent = 1
  35. Else
  36.   Msg = GetWindowLong(hWnd, GWL_EXSTYLE)
  37.   Msg = Msg Or WS_EX_LAYERED
  38.   SetWindowLong hWnd, GWL_EXSTYLE, Msg
  39.   SetLayeredWindowAttributes hWnd, 0, Perc, LWA_ALPHA
  40.   MakeTransparent = 0
  41. End If
  42. If Err Then
  43.   MakeTransparent = 2
  44. End If
  45. End Function
  46.  
  47. Public Function MakeOpaque(ByVal hWnd As Long) As Long
  48. Dim Msg As Long
  49. On Error Resume Next
  50. Msg = GetWindowLong(hWnd, GWL_EXSTYLE)
  51. Msg = Msg And Not WS_EX_LAYERED
  52. SetWindowLong hWnd, GWL_EXSTYLE, Msg
  53. SetLayeredWindowAttributes hWnd, 0, 0, LWA_ALPHA
  54. MakeOpaque = 0
  55. If Err Then
  56.   MakeOpaque = 2
  57. End If
  58. End Function



poi in un button o nella form load metti:
Codice sorgente - presumibilmente Plain Text

  1. MakeTransparent Me.hWnd, VALORE da 0 a 255 '255 = invisibile


PM Quote
Avatar
Systemsoft (Normal User)
Newbie


Messaggi: 7
Iscritto: 13/03/2009

Segnala al moderatore
Postato alle 18:38
Venerdì, 13/03/2009
MakeTransparent Me.hWnd, VALORE da 0 a 255 '255 = invisibile
non va ..

PM Quote
Avatar
theprogrammer (Normal User)
Guru^2


Messaggi: 2509
Iscritto: 28/01/2009

Segnala al moderatore
Postato alle 19:05
Venerdì, 13/03/2009
MA che vuol dire "non va" ???

Spero proprio che tu non abbia scritto

MakeTransparent Me.hWnd, VALORE da 0 a 255 '255 = invisibile

(mi sembra scontato ... c'e' anche scritto!) ma che abbia indicato un valore, ad esempio

MakeTransparent Me.hWnd, 150

PM Quote
Avatar
lorenzo (Normal User)
Guru


Messaggi: 1178
Iscritto: 15/04/2008

Segnala al moderatore
Postato alle 22:10
Venerdì, 13/03/2009
:rofl: :rofl:

Ultima modifica effettuata da lorenzo il 13/03/2009 alle 22:11
PM Quote
Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 19:43
Sabato, 14/03/2009
utile :k:

PM Quote