Cannot get rectangle fill color to change on canvas RS 2012

Hello All,

I have an app that I started some time ago, and it has come back to the forefront of priorities. The app, in part, is based on the RS Flow Chart sample. There are many objects (rectangles) drawn and positioned at start up. They are moved about the screen using a timer to scroll them. This all works perfectly.

Now, I have to change one or more of the rectangles fill color. Using the sample, I tried adding a button with this code:

  If FlowChartCanvas.Nodes(2).myColor =RGB(250, 0, 250) Then 
    FlowChartCanvas.Nodes(2).myColor =  RGB(0,255,255)  //&cFF000000
    FlowChartCanvas.Nodes(2).myColor =RGB(250, 0, 250) 
  End If

That works perfectly.

This is the code from the sample that draws the rectangles:

  Dim theX, theY, w As Integer
  Dim n As Node
  n = Nodes(num)
  off.Graphics.ForeColor = n.myColor
  Select Case n.shape
  Case 0 // circle/oval
    off.Graphics.FillOval(n.x, n.y, n.Width, n.Height)
  Case 1 // rectangle
    off.Graphics.FillRect(n.x, n.y, n.width, n.height)
  End Select
  If SelNode = num Then
    off.Graphics.ForeColor = RGB(250, 0, 0)
    off.Graphics.ForeColor = nodeColor
  End If
  Select Case n.shape
  Case 0 //circle/oval
    off.Graphics.DrawOval(n.x, n.y, n.width, n.height)
  Case 1 //rectangle
    off.Graphics.DrawRect(n.x, n.y, n.width, n.height)
  End Select
  off.Graphics.ForeColor = nodeColor
  off.Graphics.TextFont = myFont
  theX = n.x + n.width/2 - off.Graphics.StringWidth(
  theY = n.y + n.height/2 + off.Graphics.TextHeight/2
  off.Graphics.DrawString(, theX, theY)
  If editMode And SelNode = num Then
    w = 6
    off.Graphics.ForeColor = RGB(0, 0, 0)
    off.Graphics.FillRect(n.x-w/2, n.y-w/2, w, w)
    off.Graphics.FillRect(n.x-w/2, n.y+n.height-w/2, w, w)
    off.Graphics.FillRect(n.x+n.width-w/2, n.y-w/2, w, w)
    off.Graphics.FillRect(n.x+n.width-w/2, n.y+n.height-w/2, w, w)
  End If

Next, I switched over to the real app, and tried doing the same thing. No go. I even disabled the timer for the scrolling thinking the scroll forcing the paint event was getting in the way. No change.

I checked the code, and for the most part, it appears to match. I even removed all code other than to draw the fill and it still will not change!
This is the my modified code that draws the rectangles:

  dim thex,they,w as integer
  dim n as clsUnit   //node
  Select Case n.shape //FILL Of object
  Case 0 //circle/oval n.x,n.y,n.width,n.height
  Case 1 //rectangle n.x,n.y,n.width,n.height
  End Select
  // if UpdatingColor = True Then Return
  //*******************  Border Around Unit    ***********************//
  if selnode=num then  //FORECOLOR,0,0)
    NodeSelectedIndicated = True
  end if
  //Draw the border for each unit object
  If App.GraphiXSiteDefaults.DrawBorder <> "N" Then
    num = num
  End iF
  Select Case n.shape //OUTLINE of Object
  Case 0 //circle/oval n.x,n.y,n.width,n.height
  Case 1 //rectangle n.x,n.y,n.width,n.height
  End Select
  //*******************  Border Around Unit    ***********************//
  //*******************  Unit Text    ***********************//  //Text Color
  if num <> 35 then 
    if editmode and selnode=num then
      w=6,0,0) n.x-w/2,n.y-w/2,w,w n.x-w/2,n.y+n.height-w/2,w,w n.x+n.width-w/2,n.y-w/2,w,w n.x+n.width-w/2,n.y+n.height-w/2,w,w
    end if
  End If
  //*******************  Unit Text    ***********************//

The project is a decent size, but not yet huge. However it would be too large I think, to post here. While I know this makes it a LOT tougher to provide help, if anyone has any ideas, I would really appreciate the input! Spent all day today, with no progress at all…

Thanks all,

I don’t see anything, but I’d be happy to take a look at your project.

Thank you Tim.
I emailed a ZIP to you,

I found that my code works perfectly in RS 2012 R1.2 But it will not work in any subsequent RS versions or any Xojo version.
Any big change following 2012 R1.2 that anyone knows about?


If FlowChartCanvas.Nodes(2).myColor =RGB(250, 0, 250) Then

I wonder if this is failing due to alpha channel?
Try changing this line to

If FlowChartCanvas.Nodes(2) = 0 Then

I see you have already got some alpha channel style code lying around

//&cFF000000 … 4 bytes not 3

Hi Jeff,
The problem is actually larger than just the change of color, I have found. All repainting is not accomplished as evident by a drag. In RS2012 R1.2, a node can be dragged, color changed, border added etc. But in all other versions, of RS or Xojo, these functions do not appear!

Also, the color is originally set by using a 6 byte color value. However, I did try your suggestion, no change.
Any other ideas???


Does the same problem occur in the original flow chart example for you?

Does your function have ‘exception’ at the bottom?
(might an exception be occurring and you don’t see it happen?)
Have you stepped through the code to check what happens, line by line? (you only need one node to check that)

Hi Jeff,
Each sub and function has error handling, so I would know. But more importantly, I did step through all of the code, and everytime no error and it fails in later versions. Same code, (reading same project) works from R1.2…

The samples do work in later versions. However the samples are taken from the versions supplied with. The only thing I can think of, is that the actual canvas object is from V1.2 - I have never had to do this, but maybe using a new object from a later version, copy/past the associate code to the new, and deleting the old would work?! Have not tried that yet.


Hello all,

I finally found the cause late last night, but have not had time today to update the forum post.
The problem was cause by this line of code in the open even of the canvas.

I remarked it, and that cured the problem. Remarkable however that this did not cause a problem with RS2012 R1.2!