|
-
Jan 3rd, 2012, 02:18 AM
#1
Thread Starter
Addicted Member
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
-
Jan 3rd, 2012, 09:01 AM
#2
Re: How to update (refresh) graphics?
Suggest refreshing the control directly: FrmDimer.chkLines(Line).Refresh
-
Jan 3rd, 2012, 04:54 PM
#3
Thread Starter
Addicted Member
Re: How to update (refresh) graphics?
It does not work, same problem.
/jas
-
Jan 3rd, 2012, 05:50 PM
#4
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 (..)-(..)
-
Jan 3rd, 2012, 05:59 PM
#5
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
-
Jan 3rd, 2012, 08:35 PM
#6
Thread Starter
Addicted Member
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
-
Jan 3rd, 2012, 09:40 PM
#7
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
-
Jan 3rd, 2012, 09:47 PM
#8
Thread Starter
Addicted Member
Re: How to update (refresh) graphics?
-
Jan 3rd, 2012, 09:54 PM
#9
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.
-
Jan 3rd, 2012, 10:20 PM
#10
Thread Starter
Addicted Member
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
-
Jan 3rd, 2012, 11:09 PM
#11
Thread Starter
Addicted Member
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
-
Jan 3rd, 2012, 11:59 PM
#12
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|