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 Timer1_Timer() Dim a As integer A = A + 1 SetTransparent Me.hWnd, a if a = 254 then timer1.enabled = false end if End Sub Sub SetTransparent(hWnd As Long, Transparent As Byte) SetWindowLong hWnd, (-20), &H80000 SetLayeredWindowAttributes hWnd, 0, Transparent, &H2 End Sub
Tuon kuuluisi muuttaa läpinäkyvä formi vähän kerrallaan näkyvämmäksi, mutta en saa sitä itse toimaan eli voisiko joku auttaa hieman?
Kokeiles nuin:
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 dim a as integer Private Sub Timer1_Timer() a = a + 1 SetTransparent Me.hWnd, a if a = 254 then timer1.enabled = false end if End Sub Sub SetTransparent(hWnd As Long, Transparent As Byte) SetWindowLong hWnd, (-20), &H80000 SetLayeredWindowAttributes hWnd, 0, Transparent, &H2 End Sub
Luulen et a:n arvo on 0 joka kerta ku timeri suoritetaan.
Tai näinki vois toimia:
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 Timer1_Timer() static a as integer a = a + 1 SetTransparent Me.hWnd, a if a = 254 then timer1.enabled = false end if End Sub Sub SetTransparent(hWnd As Long, Transparent As Byte) SetWindowLong hWnd, (-20), &H80000 SetLayeredWindowAttributes hWnd, 0, Transparent, &H2 End Sub
Muistaakseni jos muuttuja oli static ni sen arvo säilyy.
Minulla oli sama ongelma, mutta ratkaisu on simppeli: muuttujan A tyyppi pitää olle byte :)
antaa byref virheen..
ei anna enää virhettä mutta ei kyllä näytäkään formia.
tuomas kirjoitti:
ei anna enää virhettä mutta ei kyllä näytäkään formia.
Jaahas..
Kyllä tuo näyttäisi toimivan (kannattaa muuten asettaa form_loadissa läpinäkyvyys nollaan.. ei välkähdä alussa):
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 Timer1_Timer() Static a As Byte a = a + 1 SetTransparent Me.hWnd, a If a = 254 Then Timer1.Enabled = False End If End Sub Sub SetTransparent(hWnd As Long, Transparent As Byte) SetWindowLong hWnd, (-20), &H80000 SetLayeredWindowAttributes hWnd, 0, Transparent, &H2 End Sub
nyt sain toimimaan..
Kiitti!
Aihe on jo aika vanha, joten et voi enää vastata siihen.