Problem compiling for Windows

Hi all.

I’m writing a new program. Mainly is displaying curves and graphs. If I compile it with my old Real Studio 2011 (r 4.3). it’s working under Mac & also under Windows without problems.

If I compile the same code with the last XoJo 2017 r.3, the Mac build works much faster then the compiled from Real Studio, but the Windows build is working so slow that the program crashes when loading the first curves. It opens ok, the problem arrives when starting loading data on it.

I’ve try compiling in XoJo as 64-bit and also as 32-bit with identical results. The program crashed when starting working with it.

Any idea about why the same code can be compiled without problems in RS for windows and it’s failing under Xojo?. I don’t believe I’m making something wrong in the code, because under MacOS is working as heaven.

Best regards.

The drawing system in Windows changed after 2016r3 (if I recall). Try with 2016r3. If it works you know that the change from GDI+ to DIRECTDRAW is where the issue relies. It will not “fix” your issue, but it should point you at which code sections you need to look at.

Hi.

I believe you’re right. it’s because I’m using Graphics instead of Pain…, but I don’t know how can I call from a Method to parameters like this:

Canvas.Graphics.ClearRect 0,0,255,255
Canvas.Graphics.ForeColor=RGB(250,250,250)
Canvas.Graphics.drawrect 0,25.6,255,25.6
Canvas.Graphics.DrawLine 0,255,255,0

Best regards.

Your method does this:

Canvas.Graphics.ForeColor=RGB(250,250,250)

Add a parameter g as graphics to the method.
Lets assume the method is called MyMethod

Then change

Canvas.Graphics.ClearRect 0,0,255,255 Canvas.Graphics.ForeColor=RGB(250,250,250) Canvas.Graphics.drawrect 0,25.6,255,25.6 Canvas.Graphics.DrawLine 0,255,255,0

to be

g.ClearRect 0,0,255,255 g.ForeColor=RGB(250,250,250) g.drawrect 0,25.6,255,25.6 g.DrawLine 0,255,255,0

And add

call MyMethod  (g)

into the paint event of the canvas.

Note that unlike PDF work, graphics.drawrect only uses integers… 25.6 is treated as 25 in this call.

Yes… this is clear… but I’ve different Canvas in my app, how can I choose to witch Canvas I’m talking about?, because right now I’ve:

Canvas_1.Graphics.ClearRect 0,0,255,255
Canvas_2.Graphics.ClearRect 0,0,255,255
Canvas_3.Graphics.ClearRect 0,0,255,255
Canvas_4.Graphics.ClearRect 0,0,255,255

and if I make the replacement as you describe I’d have:

dim g as graphics.

g.ClearRect 0,0,255,255

??? but how can I connect (refer) that g is in Canvas_1 or in Canvas_2?..

Thanks a lot for your help. :)))

in each canvas paint event, g is ‘this canvas’

if you want canvas1 to show a circle and canvas2 to show a square

the paint event of canvas 1 will say

g.drawoval 10,10,30,30

and canvas2 paint event will say

g.drawrect 20,20,30,30

Yes, but in the canvas1 I’ve a paint event, and it’s making things, and in the code, depending in the data I’m loading, Im drawing other things in canvas 1, same for canvas 2, 3 4… so depending on the data I’m loading, I’m painting different things on each canvas from the code.

how can I’ve different paint events in the same canvas1?. Does it mean I’ve to create different global variables, giving different values to each one of the variables and writing all my code inside the paint event filled with if then sentences depending on each one of the new variables?, because this is rewriting 95% of my actual code… there is no other solution?

BR

You may want to have each canvas with its own picture property, draw to that picture, and then on the canvas paint event draw the picture to the canvas. See https://forum.xojo.com/39771-offscreen-picture-to-canvas and https://forum.xojo.com/41472-animation-speed for some examples.