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>

Reply via email to