[RESOLVED] How to drop a gradient color from a picturebox?-VBForums
Results 1 to 6 of 6

Thread: [RESOLVED] How to drop a gradient color from a picturebox?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2016
    Posts
    299

    Resolved [RESOLVED] How to drop a gradient color from a picturebox?

    Hi everyone
    I have some pictureboxes on my form.
    I use a module that allows painting the picturebox with gradient colors.
    Code:
    Public Sub Rectangle4Colors(ByVal hdc As Long, X1, Y1, X2, Y2, Color1, Color2, Color3, Color4)
    
       GradientRect4Corners hdc, CLng(X1), CLng(Y1), CLng(X2), CLng(Y2), CLng(Color1), CLng(Color2), CLng(Color3), CLng(Color4)
    End Sub
    Code:
    pc(I).Color = CommonDialog1.Color
      G.Rectangle4Colors Picture1.hdc, 0, 0, Picture1.Width, Picture1.Height, pc(0).Color, pc(1).Color, pc(2).Color, pc(3).Color
    I want to be able able to change the gradient colors by normal colors at runtime.
    eg
    Picture1.backcolor = vbblue.
    But this does seem to work.


    Thank you

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    15,567

    Re: How to drop a gradient color from a picturebox?

    If all you want is a solid back color, set the .BackColor property as you tried and do not call the gradient routines. Not sure how your Rectangle4Colors routine works, but if you pass the same color for each of the color parameters, that may produce a solid color also.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VB and DPI Tutorial} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2016
    Posts
    299

    Re: How to drop a gradient color from a picturebox?

    thank you LaVolpe for the interest
    and do not call the gradient routines
    I'm calling the gradient routines at form_load event. but later I wabt to substitute the gradient color with a solid color.
    somthing like this doesn't do the task:
    Code:
    Picture1.backcolor = vbblue
    How to cancel the gradient routines?
    thanks

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2016
    Posts
    299

    Re: How to drop a gradient color from a picturebox?

    thank you LaVolpe for the interest
    and do not call the gradient routines
    I'm calling the gradient routines at form_load event. but later I wabt to substitute the gradient color with a solid color.
    somthing like this doesn't do the task:
    Code:
    Picture1.backcolor = vbblue
    How to cancel the gradient routines?
    thanks

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    15,567

    Re: How to drop a gradient color from a picturebox?

    Do your routines have any code that sets the .Picture property, something like Picture1.Picture = Picture1.Image? If so, that's likely the cause. The code draws the gradient and captures it and sets it to the Picture property. If that is the case, then:

    Picture1.BackColor = vbBlue
    Set Picture1.Picture = Nothing

    Edited: If that isn't a fix, can you post your GradientRect4Corners routine?
    Last edited by LaVolpe; Mar 20th, 2017 at 08:49 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {GDI+ Classes/Samples} {Unicode Open/Save Dialog} {Icon Organizer/Extractor}
    {VB and DPI Tutorial} {XP/Vista Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2016
    Posts
    299

    Re: How to drop a gradient color from a picturebox?

    Set Picture1.Picture = Nothing
    That's the trick that did the job
    Thank you very much LaVolpe

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.