Xojo Conferences
XDCMay2019MiamiUSA

canvas wrestling (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: ListBox ActiveCell
Next thread: Styleruns


RB Database   -   tom.russell transport.alstom.com
  canvas wrestling   -   Bart Pietercil
   Re: canvas wrestling   -   CV
   Re: canvas wrestling   -   Phil Heycock
   Re: canvas wrestling   -   Bart Pietercil
    RE: canvas wrestling   -   RBNUBE
     Re: canvas wrestling   -   Bart Pietercil
     Re: canvas wrestling   -   Bart Pietercil
      RE: canvas wrestling   -   RBNUBE
       Re: canvas wrestling   -   Bart Pietercil
        RE: canvas wrestling   -   RBNUBE
         Re: canvas wrestling   -   Bart Pietercil
          RE: canvas wrestling   -   RBNUBE
         Re: canvas wrestling   -   CV
         Re: canvas wrestling   -   Bart Pietercil
         Re: canvas wrestling   -   CV
   Re: canvas wrestling   -   CV
   Re: canvas wrestling   -   Bart Pietercil

canvas wrestling
Date: 07.01.07 18:33 (Sun, 7 Jan 2007 18:33:00 +0100)
From: Bart Pietercil
Hi List,

passing sunday breaking my head on this simple thing.

Why does this code not draw a string in the new canvas ?

Sub Action()
Dim aCanvas As Canvas

aCanvas = new Canvas1

aCanvas.Top = 120

aCanvas.Graphics.DrawString("allo,allo",0,0,50)
End Sub

I have put a graphic inside the template canvas and I see it is
created after performing the action. ( I see 2 images in the window)

But why the last line doesn't do a thing beats me....

Help REALLY appreciated

TIA

Bart
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 19:05 (Sun, 7 Jan 2007 10:05:46 -0800)
From: CV

On Jan 7, 2007, at 9:33 AM, Bart Pietercil wrote:

> Hi List,
>
> passing sunday breaking my head on this simple thing.
>
> Why does this code not draw a string in the new canvas ?
>
> Sub Action()
> Dim aCanvas As Canvas
>
> aCanvas = new Canvas1
>
> aCanvas.Top = 120
>
> aCanvas.Graphics.DrawString("allo,allo",0,0,50)
> End Sub
>
> I have put a graphic inside the template canvas and I see it is
> created after performing the action. ( I see 2 images in the window)
>
> But why the last line doesn't do a thing beats me....
>
> Help REALLY appreciated
>

Using a y-coordinate of 0 specifies the base(bottom) of the string at
0, thus the string text is off(above), the canvas. Try a larger y-
coordinate, at least aCanvas.Graphics.DrawString("allo, allo", 0,
aCanvas.Graphics.TextHeight, 50). Also, put code in the Paint event
to maintain your image.

Best,

Jack
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 19:11 (Sun, 07 Jan 2007 13:11:55 -0500)
From: Phil Heycock
The 'y' coordinate in text drawing represents the BASELINE for the text...
not the TOP of the text. So, I would guess that your Canvas IS drawing the
text... except that you can't see it, because you are drawing it ABOVE the
'visible' area of the Canvas. Solution: Give the 'y' coordinate some
positive value GREATER THAN Graphics.TextHeight.

HTH

P.



on 1/7/07 12:33 PM, Bart Pietercil at <email address removed> wrote:

> Hi List,
>
> passing sunday breaking my head on this simple thing.
>
> Why does this code not draw a string in the new canvas ?
>
> Sub Action()
> Dim aCanvas As Canvas
>
> aCanvas = new Canvas1
>
> aCanvas.Top = 120
>
> aCanvas.Graphics.DrawString("allo,allo",0,0,50)
> End Sub
>
> I have put a graphic inside the template canvas and I see it is
> created after performing the action. ( I see 2 images in the window)
>
> But why the last line doesn't do a thing beats me....
>
> Help REALLY appreciated
>
> TIA
>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 19:31 (Sun, 7 Jan 2007 19:31:02 +0100)
From: Bart Pietercil

On 7-jan-07, at 19:05, CV wrote:

>
> On Jan 7, 2007, at 9:33 AM, Bart Pietercil wrote:
>
>> Hi List,
>>
>> passing sunday breaking my head on this simple thing.
>>
>> Why does this code not draw a string in the new canvas ?
>>
>> Sub Action()
>> Dim aCanvas As Canvas
>>
>> aCanvas = new Canvas1
>>
>> aCanvas.Top = 120
>>
>> aCanvas.Graphics.DrawString("allo,allo",0,0,50)
>> End Sub
>>
>> I have put a graphic inside the template canvas and I see it is
>> created after performing the action. ( I see 2 images in the window)
>>
>> But why the last line doesn't do a thing beats me....
>>
>> Help REALLY appreciated
>>
> Using a y-coordinate of 0 specifies the base(bottom) of the string
> at 0, thus the string text is off(above), the canvas. Try a larger
> y-coordinate, at least aCanvas.Graphics.DrawString("allo, allo",
> 0, aCanvas.Graphics.TextHeight, 50).

Changing the coordinates didn't help...

> Also, put code in the Paint event to maintain your image.

Could you elaborate on the what and why of putting code in the paint
event ?

Maybe if it is not too much trouble , I could ask to put the
actioncode in a button for

1) "cloning" an offscreen canvas named canvas 1 with nothing in it
2) putting a string inside the canvas
3) putting that cloned canvas at window coordinates 50,50 (example)

I must be doing something obvious completely wrong

TIA

Bart
>
> Best,
>
> Jack
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

RE: canvas wrestling
Date: 07.01.07 21:45 (Sun, 7 Jan 2007 15:45:21 -0500)
From: RBNUBE
Try something simple like removing the graphic and the wrap, then:

aCanvas.Graphics.DrawString("allo,allo",10,100)

The 10 and 100 should place the text well within an area that can be seen if
your canvas left and top settings are placing the clone in an area where it
will not be 'hiding' the text.

If you are then able to see it, you are on the right track. Go from here.

If you still cannot see it, let me know and I'll send you a simple example
off list.

HTH

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 21:56 (Sun, 7 Jan 2007 21:56:24 +0100)
From: Bart Pietercil
That's what i tried, should work, but doesn't (OSX RB2006/4)

Since I'm a newbie in RB I suppose the fault is some wire in my brain.

>
> If you still cannot see it, let me know and I'll send you a simple
> example
> off list.
>

Very much appreciated

TIA

Bart

<email address removed>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 22:12 (Sun, 7 Jan 2007 22:12:17 +0100)
From: Bart Pietercil
Nope, RB

nothing is happening, same issue as what I was having. As you said
nothing very special about the code, clicking the button gives
feedback, stepping through the code no exceptions, just... nothing

Do we need to look elsewhere ?

MacBook Pro OSX 10.4.8
Realbasic 2006/4
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

RE: canvas wrestling
Date: 07.01.07 22:16 (Sun, 7 Jan 2007 16:16:35 -0500)
From: RBNUBE
Maybe instead you could send your project to me. I have to leave in about a
half hour...

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 22:25 (Sun, 7 Jan 2007 22:25:16 +0100)
From: Bart Pietercil
Uhm,

the real project is already far to complicated to send (it was the
last screen in the application where I need this functionality)

I was playing with the project you send me.

Out of the box(mail) , I just open it , hit run, click the button no joy
I looked at the code, maybe the left was a bit of so I changed that
to a value of 314
AND i added an image to the backdrop in order to have a visual feedback.

Hit run and I see the image duplicated when clicking the button but
no string appearing, so there must be something wrong with the
drawstring method

Does it run on your end (an does it draw the 'Joe....")?

Bart



On 7-jan-07, at 22:16, RBNUBE wrote:

> Maybe instead you could send your project to me. I have to leave
> in about a
> half hour...
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

RE: canvas wrestling
Date: 07.01.07 22:48 (Sun, 7 Jan 2007 16:48:54 -0500)
From: RBNUBE
(Sending complicated projects isn't an issue, I don't think. If you want to
attach it, you should be able to without problem. If you're worried about
other people seeing your code, that's understandable.)

Sure. It works fine on my end...on Windows.

I just tested it on my Mac where it does not appear to work. The clone is
created, but the string is not drawn.

Interestingly enough, placing a MsgBox statement in the code forces the
string to appear on the cloned canvas.

People are recommending that you place code in the Paint event of the
Canvas. This might lead to success, but it will more than likely cause
redraw issues (very annoying and obvious flicker) on Windows. So, if you
want to write for Windows, you may need to add a buffering system.


-----Original Message-----
From: <email address removed>
[mailto:<email address removed>] On Behalf Of Bart
Pietercil
Sent: Sunday, January 07, 2007 4:25 PM
To: Getting Started
Subject: Re: canvas wrestling

Uhm,

the real project is already far to complicated to send (it was the
last screen in the application where I need this functionality)

I was playing with the project you send me.

Out of the box(mail) , I just open it , hit run, click the button no joy I
looked at the code, maybe the left was a bit of so I changed that
to a value of 314
AND i added an image to the backdrop in order to have a visual feedback.

Hit run and I see the image duplicated when clicking the button but
no string appearing, so there must be something wrong with the
drawstring method

Does it run on your end (an does it draw the 'Joe....")?

Bart



On 7-jan-07, at 22:16, RBNUBE wrote:

> Maybe instead you could send your project to me. I have to leave
> in about a
> half hour...
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 23:13 (Sun, 7 Jan 2007 23:13:01 +0100)
From: Bart Pietercil
Hi List,

First special thanks to RBNUBE and CV for helping me out

These are my findings with the drawstring problem

This code on OSX does not work on my macbook pro with RB2006/4

Sub Action()

Dim aCanvas as Canvas

aCanvas = new Canvas1
'
aCanvas.Top = 7
aCanvas.Left = 314
aCanvas.Graphics.TextFont="Arial"
aCanvas.Graphics.TextSize
aCanvas.Graphics.ForeColor=RGB(255,0,0)
aCanvas.Graphics.DrawString("Joe Bob Gizzerdamp YEAH!!!",
10,10,aCanvas.Width-10)

End Sub

More precisely everything works but the last line
The code as stated above works on windows ( cfr RBNube)

Jack(CV) helped me by posting that the 3 last lines should be placed
within a select case construct in the paint event of the canvas
That works

However RBNube warns that this will lead to flickering on Windows
systems

So here I am needing something cross-platform AND maintainable (by
this I mean that I can see how I could place differing code for OSX
and Windows, but that can hardly be the way to go for a crossplatform
tool and what seems to me being a fairly common task)

RBNube told me that when placing a messagebox before drawing into the
canvas cured the problem on mac which lead me to this code that works

Sub Action()

Dim aCanvas as Canvas

aCanvas = new Canvas1
'
aCanvas.Top = 7
aCanvas.Left = 314
aCanvas.Graphics.TextFont="Arial"
aCanvas.Graphics.TextSize
aCanvas.Graphics.ForeColor=RGB(255,0,0)

self.Refresh(True)

aCanvas.Graphics.DrawString("Joe Bob Gizzerdamp YEAH!!!",
10,10,aCanvas.Width-10)

End Sub

Can somebody shed some light on the way to go ? And as to WHY the
first example does not work?

TIA

Bart Pietercil



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

RE: canvas wrestling
Date: 08.01.07 01:26 (Sun, 7 Jan 2007 19:26:43 -0500)
From: RBNUBE
Something I overlooked (even though it was mentioned before in this thread)
is that if your code is not placed in the Paint event, it will disappear
under certain circumstances. For instance, if you move the window off
screen, then Back on screen.



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 08.01.07 01:25 (Sun, 7 Jan 2007 16:25:32 -0800)
From: CV

On Jan 7, 2007, at 2:13 PM, Bart Pietercil wrote:
> And as to WHY the first example does not work?
>

I don't know why, but apparently Rb refreshed the cloned canvas after
the string drawing from the button was performed. The canvas was
cleared and remained clear since there was no code in Paint to draw
the string again.

Best,

Jack
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 08.01.07 11:38 (Mon, 8 Jan 2007 11:38:00 +0100)
From: Bart Pietercil
And why would it behave differently on Windows?

Bart

On 8-jan-07, at 01:25, CV wrote:

>
> On Jan 7, 2007, at 2:13 PM, Bart Pietercil wrote:
>> And as to WHY the first example does not work?
>>
> I don't know why, but apparently Rb refreshed the cloned canvas
> after the string drawing from the button was performed. The canvas
> was cleared and remained clear since there was no code in Paint to
> draw the string again.
>
> Best,
>
> Jack
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 08.01.07 14:15 (Mon, 8 Jan 2007 05:15:38 -0800)
From: CV
With drawing code in the Paint event, where it should be, it works
the same on WindowsXP and OSX for me. Windows and OSX use different
graphics engines and their order of events can be slightly different
as well. Put your code in the Paint event and let Rb take care of
those differences for you, plus maintain your images during resizes
and so forth.

Best,

Jack


On Jan 8, 2007, at 2:38 AM, Bart Pietercil wrote:

> And why would it behave differently on Windows?
>
> Bart
>
> On 8-jan-07, at 01:25, CV wrote:
>
>>
>> On Jan 7, 2007, at 2:13 PM, Bart Pietercil wrote:
>>
>>> And as to WHY the first example does not work?
>>>
>>>
>> I don't know why, but apparently Rb refreshed the cloned canvas
>> after the string drawing from the button was performed. The canvas
>> was cleared and remained clear since there was no code in Paint to
>> draw the string again.
>>
>> Best,
>>
>> Jack
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives of this list here:
>> <http://support.realsoftware.com/listarchives/lists.html>
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 22:24 (Sun, 7 Jan 2007 13:24:07 -0800)
From: CV

On Jan 7, 2007, at 10:31 AM, Bart Pietercil wrote:

>
> On 7-jan-07, at 19:05, CV wrote:
>
>>
>> On Jan 7, 2007, at 9:33 AM, Bart Pietercil wrote:
>>
>>> Hi List,
>>>
>>> passing sunday breaking my head on this simple thing.
>>>
>>> Why does this code not draw a string in the new canvas ?
>>>
>>> Sub Action()
>>> Dim aCanvas As Canvas
>>>
>>> aCanvas = new Canvas1
>>>
>>> aCanvas.Top = 120
>>>
>>> aCanvas.Graphics.DrawString("allo,allo",0,0,50)
>>> End Sub
>>>
>>> I have put a graphic inside the template canvas and I see it is
>>> created after performing the action. ( I see 2 images in the window)
>>>
>>> But why the last line doesn't do a thing beats me....
>>>
>>> Help REALLY appreciated
>>>
>>>
>> Using a y-coordinate of 0 specifies the base(bottom) of the string
>> at 0, thus the string text is off(above), the canvas. Try a larger
>> y-coordinate, at least aCanvas.Graphics.DrawString("allo, allo",
>> 0, aCanvas.Graphics.TextHeight, 50).
>>
> Changing the coordinates didn't help...
>
>> Also, put code in the Paint event to maintain your image.
>>
> Could you elaborate on the what and why of putting code in the
> paint event ?
>
> Maybe if it is not too much trouble , I could ask to put the
> actioncode in a button for
>
> 1) "cloning" an offscreen canvas named canvas 1 with nothing in it
> 2) putting a string inside the canvas
> 3) putting that cloned canvas at window coordinates 50,50 (example)
>
> I must be doing something obvious completely wrong
>
> TIA
>
> Bart
>

I'm sure that you've given your offscreen Canvas1 an index, say 0,
so that it can be cloned. In the button put:

Dim aCanvas as Canvas
aCanvas = new Canvas1
aCanvas.Top = 120

Then in the Paint event of Canvas1 put:

g.DrawString "Hello", 10, 10 // or whatever

Note that in your Paint event there is an index parameter, so if you
make additional clones with different strings you can put a Select
Case based on index.


Best,

Jack

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: canvas wrestling
Date: 07.01.07 22:52 (Sun, 7 Jan 2007 22:52:29 +0100)
From: Bart Pietercil
>>

Thanks Jack,

this works and I can see how to use this, but that leaves the
question why this does not work:

> Dim aCanvas as Canvas
> aCanvas = new Canvas1
> aCanvas.Top = 120
> aCanvas.graphics.DrawString "Hello", 10, 10 // or whatever


As you can see I just added the line you put in the paint event to
the button. So why can I not talk to my new object from the button
code ?

TIA

Bart

>
> I'm sure that you've given your offscreen Canvas1 an index, say 0,
> so that it can be cloned. In the button put:
>
> Dim aCanvas as Canvas
> aCanvas = new Canvas1
> aCanvas.Top = 120
>
> Then in the Paint event of Canvas1 put:
>
> g.DrawString "Hello", 10, 10 // or whatever
>
> Note that in your Paint event there is an index parameter, so if
> you make additional clones with different strings you can put a
> Select Case based on index.
>
> Best,
>
> Jack
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>