Results 1 to 6 of 6

Thread: [RESOLVED] Picturebox opacity

  1. #1

    Thread Starter
    Lively Member cageybee's Avatar
    Join Date
    Nov 2005
    Location
    Stanardsville, VA
    Posts
    81

    Resolved [RESOLVED] Picturebox opacity

    All,
    I've seen an number of posts having to do with setting the opacity of a form.....and I just made that work......what I'd like to do is to fade in and fade out a picturebox. I don't see any built-in way to do it, anybody have a clue? Can i create a form inside of a form where the form inside only has a picturebox in it? Would that work?

    thanks!

    kgb
    Last edited by cageybee; Dec 29th, 2005 at 03:56 PM.

  2. #2
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: Picturebox opacity

    i found something that might help you a little with this

    http://www.vb-helper.com/howto_net_blend_animation.html

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  3. #3

    Thread Starter
    Lively Member cageybee's Avatar
    Join Date
    Nov 2005
    Location
    Stanardsville, VA
    Posts
    81

    Re: Picturebox opacity

    Thanks Derek....I'll study this and see if I can figure out exactly how to use it. I've been playing with this (ipass*63 is the alpha (opacity)) doesn't work yet though! :

    Public Function fade_out()
    Dim ipass As Integer
    Dim mycolor As Color
    Dim myBrush As New SolidBrush(mycolor)
    Dim yd, xd As Integer
    For ipass = 1 to 4
    mycolor = Color.FromArgb(ipass * 63, 23, 56, 78)
    PictureBox1.CreateGraphics.FillRectangle(mybrush, 0, 0, 720, 648)
    System.Threading.Thread.CurrentThread.Sleep(1000)
    'Next
    Next
    myBrush.Dispose()
    PictureBox1.CreateGraphics.Dispose()
    Last edited by cageybee; Dec 30th, 2005 at 02:41 PM.

  4. #4

    Thread Starter
    Lively Member cageybee's Avatar
    Join Date
    Nov 2005
    Location
    Stanardsville, VA
    Posts
    81

    Re: Picturebox opacity

    This is very close to working now:

    Public Function fade_out()
    Dim ipass As Integer
    Dim mycolor As System.Drawing.Color
    Dim yd, xd As Integer
    For ipass = 1 To 16
    mycolor = Color.FromArgb(ipass * 16, 23, 56, 78)
    Dim myBrush As New SolidBrush(mycolor)
    PictureBox1.CreateGraphics.FillRectangle(myBrush, 0, 0, 720, 648)
    System.Threading.Thread.CurrentThread.Sleep(100)
    Next
    PictureBox1.CreateGraphics.Dispose()

    I DON'T like the DIM statement in the loop...but don't know how to make it work otherwise. The rectangle being filled is obviously the entire picturebox.

    kgb

  5. #5
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Re: Picturebox opacity

    VB Code:
    1. Public Function fade_out()
    2.     Dim ipass As Integer
    3.     Dim mycolor As System.Drawing.Color
    4.     Dim yd, xd As Integer
    5.     For ipass = 1 To 16
    6.         mycolor = Color.FromArgb(ipass * 16, 23, 56, 78)
    7.         'Dim myBrush As New SolidBrush(mycolor)
    8.         PictureBox1.CreateGraphics.FillRectangle(New SolidBrush(mycolor), 0, 0, 720, 648)
    9.         System.Threading.Thread.CurrentThread.Sleep(100)
    10.     Next
    11.     PictureBox1.CreateGraphics.Dispose()
    12. End Sub

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  6. #6

    Thread Starter
    Lively Member cageybee's Avatar
    Join Date
    Nov 2005
    Location
    Stanardsville, VA
    Posts
    81

    Re: Picturebox opacity

    YA!!!! Much better! Thanks! changed it a little below to fade to "Control" color

    Public Function fade_out()
    Dim ipass As Integer
    Dim mycolor As System.Drawing.Color
    For ipass = 1 To 28
    mycolor = Color.FromArgb(ipass * 4, 230, 230, 210)
    PictureBox1.CreateGraphics.FillRectangle(New SolidBrush(mycolor), 0, 0, 720, 648)
    System.Threading.Thread.CurrentThread.Sleep(5)
    Next
    PictureBox1.CreateGraphics.Dispose()
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width