Results 1 to 12 of 12

Thread: How to update (refresh) graphics?

  1. #1

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    How to update (refresh) graphics?

    Happy New Year to everyone,

    I have this problem.
    Code:
    =======
    FrmDimer.chkLines(Line).BackColor = &H8000000F
    FrmDimer.Refresh
    =======

    I am trying to change the BackColor (from Red to Black)
    Despite the fact, this line is processed the color is not changed.
    When I put the breakpoint the color is changed.
    How to deal with that?
    Thanks,
    jas

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

    Re: How to update (refresh) graphics?

    Suggest refreshing the control directly: FrmDimer.chkLines(Line).Refresh
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: How to update (refresh) graphics?

    It does not work, same problem.
    /jas

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to update (refresh) graphics?

    Actually, thinking back on this. You should never have to refresh it. Simply assigning the .BackColor property should make an immediate change. So, some questions

    1) Are you using any On Error statements in the routine that is changing the backcolor
    2) What type of control exactly is chkLines? A VB checkbox control?
    3) Are you positive the value of LINE is within the LBound & UBound of chkLines? You can verify it with a simple IF statement:
    Code:
    If Line < chkLines.LBound Or Line > chkLines.UBound Then MsgBox "Error. Line is not valid"
    4. Are you using Option Explicit at top of that form? If not, do so.

    Suggestion: Do not use Line as variable. It is a VB method: Picture1.Line (..)-(..)
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: How to update (refresh) graphics?

    Jas

    I think LaVolpe's last point is perhaps the most critical one ..

    Line is a reserved word, as he pointed out.
    So, change your variable to something like nLine

    Spoo

  6. #6

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: How to update (refresh) graphics?

    No, the problem is somewhere else.
    I made this experiment.
    Instead of 1 control to change color I tried to change the color of all controls in that array:
    For i = 0 To FrmDimer.chkLines.UBound
    FrmDimer.chkLines(i).BackColor = &H8000000F
    Next

    Guess what. All controls changed the color except the first (visible) control.
    To add more: that control is not even the first contol of array but 7th but it is displayed as the first visible control.

    There is more to it.
    I have also command button (not member of any aaray) in graphical style.
    Thr graphics on that button also is not changed but stepping over the code there is not a problem with that.
    Any more ideas, please?
    /jas

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to update (refresh) graphics?

    Are you using a manifest to make your controls themed? If so, forget about changing backcolors for controls that are not graphical style
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: How to update (refresh) graphics?

    No.
    I do not use it.

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to update (refresh) graphics?

    I give up. I would suggest you attach a test project, that is exhibiting the problems, for us to look at. There isn't enough information to go on. We'd just be floating more guesses and that isn't getting you anywhere.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    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} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: How to update (refresh) graphics?

    In that case I would need to show you all my project.
    Please note, that
    1.
    the problem appears only at the run time without debugging.
    2.
    When I attach that offendfing code to just command button like this:
    ====== code ========
    Public Sub cmdOK_Click()
    FrmDimer.chkLines(7).BackColor = &H8000000F
    End Sub
    or
    Public Sub cmdOK_Click()
    For i = 0 To FrmDimer.chkLines.UBound
    FrmDimer.chkLines(i).BackColor = &H8000000F
    Next
    End Sub
    ===================
    and at the run time I click on OK button the colors are changed weithout problem.
    /jas

  11. #11

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: How to update (refresh) graphics?

    One more clue.
    I am unable to change control's .BackColor but there is not a problem with .ForeColor.
    /jas

  12. #12

    Thread Starter
    Addicted Member jastrzebiec's Avatar
    Join Date
    Nov 2010
    Posts
    173

    Re: How to update (refresh) graphics?

    Another clue.
    After offending line of code I inserted Debug.Print
    and tested the value of BackColor.
    Eureka! The value has changed!
    So the problem is with the refreshing graphics.
    Any more ideas, please?
    /jas

    So the new question is:
    How to force Windows to refresh .BackColor property?

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