need help how to trasparent the picturebox?

need help how to trasparent the picturebox?

Page 1 of 1

2 Replies - 3312 Views - Last Post: 31 January 2008 - 06:18 PM Rate Topic: -----

#1 lzaero  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 13-September 07

need help how to trasparent the picturebox?

Post icon  Posted 31 January 2008 - 01:23 AM

hello guys please can you help me with my problem in picturebox that can be able transparent during the form is load?
Is This A Good Question/Topic? 0
  • +

Replies To: need help how to trasparent the picturebox?

#2 LookNAO  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 66
  • Joined: 28-December 07

Re: need help how to trasparent the picturebox?

Posted 31 January 2008 - 12:39 PM

This may help, it may not...

This code can do the whole form:

Option Explicit

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 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 Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000

Function MakeTransparent(OObject As Object, Perc As Integer) As Long

Dim Msg As Long

Msg = GetWindowLong(OObject.hWnd, GWL_EXSTYLE)
Msg = Msg Or WS_EX_LAYERED
SetWindowLong OObject.hWnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes OObject.hWnd, 0, Perc, LWA_ALPHA

End Function

Private Sub Command1_Click()

Dim RReturn As Long
' MakeTransparent - object, percentage of transperency..
RReturn = MakeTransparent(Form1, 128)

End Sub



Now, if you want the picturebox invisible because there is something behind it that you want the user to see:

Picture1.visible = false
Was This Post Helpful? 0
  • +
  • -

#3 lzaero  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 13-September 07

Re: need help how to trasparent the picturebox?

Posted 31 January 2008 - 06:18 PM

View PostLookNAO, on 31 Jan, 2008 - 12:39 PM, said:

This may help, it may not...

This code can do the whole form:

Option Explicit

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 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 Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000

Function MakeTransparent(OObject As Object, Perc As Integer) As Long

Dim Msg As Long

Msg = GetWindowLong(OObject.hWnd, GWL_EXSTYLE)
Msg = Msg Or WS_EX_LAYERED
SetWindowLong OObject.hWnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes OObject.hWnd, 0, Perc, LWA_ALPHA

End Function

Private Sub Command1_Click()

Dim RReturn As Long
' MakeTransparent - object, percentage of transperency..
RReturn = MakeTransparent(Form1, 128)

End Sub



Now, if you want the picturebox invisible because there is something behind it that you want the user to see:

Picture1.visible = false



View PostLookNAO, on 31 Jan, 2008 - 12:39 PM, said:

This may help, it may not...

This code can do the whole form:

Option Explicit

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 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 Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000

Function MakeTransparent(OObject As Object, Perc As Integer) As Long

Dim Msg As Long

Msg = GetWindowLong(OObject.hWnd, GWL_EXSTYLE)
Msg = Msg Or WS_EX_LAYERED
SetWindowLong OObject.hWnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes OObject.hWnd, 0, Perc, LWA_ALPHA

End Function

Private Sub Command1_Click()

Dim RReturn As Long
' MakeTransparent - object, percentage of transperency..
RReturn = MakeTransparent(Form1, 128)

End Sub



Now, if you want the picturebox invisible because there is something behind it that you want the user to see:

Picture1.visible = false



hello thank you for this code...but anyway i want a picturebox can trasparent into the forms.....again thank you sharing me with this...

View PostLookNAO, on 31 Jan, 2008 - 12:39 PM, said:

This may help, it may not...

This code can do the whole form:

Option Explicit

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 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 Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2
Private Const WS_EX_LAYERED = &H80000

Function MakeTransparent(OObject As Object, Perc As Integer) As Long

Dim Msg As Long

Msg = GetWindowLong(OObject.hWnd, GWL_EXSTYLE)
Msg = Msg Or WS_EX_LAYERED
SetWindowLong OObject.hWnd, GWL_EXSTYLE, Msg
SetLayeredWindowAttributes OObject.hWnd, 0, Perc, LWA_ALPHA

End Function

Private Sub Command1_Click()

Dim RReturn As Long
' MakeTransparent - object, percentage of transperency..
RReturn = MakeTransparent(Form1, 128)

End Sub



Now, if you want the picturebox invisible because there is something behind it that you want the user to see:

Picture1.visible = false

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1