How to get access on TMemo Canvas ?

How to get access on TMemo Canvas ?

Post by MCh » Fri, 27 Jun 2003 23:03:13



I want to accsess TMemo Canvas . Any Idea ?
thanks in advance....
 
 
 

How to get access on TMemo Canvas ?

Post by Maynard Philbroo » Sat, 28 Jun 2003 02:55:19


TCanvas *M = new TCanvas();
M->Handle = GetDc(Memo1->Handle);
 // now use M as  your canvas..
// when done on local code make sure you release it.
 ReleaseDC(Memo1->Handle, M->Handle);
delete M;

> I want to accsess TMemo Canvas . Any Idea ?
> thanks in advance....


 
 
 

How to get access on TMemo Canvas ?

Post by MCh » Sat, 28 Jun 2003 06:15:57


Covered  : GetDC



Quote:> I want to accsess TMemo Canvas . Any Idea ?
> thanks in advance....

 
 
 

How to get access on TMemo Canvas ?

Post by Hans Galem » Sat, 28 Jun 2003 18:16:35



> Covered  : GetDC

Could you pleas provide some more info how you did it ?

Hans.

 
 
 

How to get access on TMemo Canvas ?

Post by Giulia » Sat, 28 Jun 2003 19:26:25


On Fri, 27 Jun 2003 11:16:35 +0200, Hans Galema



>> Covered  : GetDC

>Could you pleas provide some more info how you did it ?

Hi Hans,

   try with the following snippet.

#include <memory>

std::auto_ptr<TControlCanvas> C( new TControlCanvas );
C->Control = Memo1;
C->MoveTo( 0, 0 );
C->LineTo( 100, 100 );

Ciao!

Giuliano

 
 
 

How to get access on TMemo Canvas ?

Post by Hans Galem » Sat, 28 Jun 2003 19:58:32



>    try with the following snippet.

> #include <memory>

> std::auto_ptr<TControlCanvas> C( new TControlCanvas );
> C->Control = Memo1;
> C->MoveTo( 0, 0 );
> C->LineTo( 100, 100 );

Thanks. It's about the same as in thread 'Drawing a circle' !

Hans.

 
 
 

How to get access on TMemo Canvas ?

Post by Steve_Alett » Sat, 28 Jun 2003 21:02:51



> On Fri, 27 Jun 2003 11:16:35 +0200, Hans Galema

> #include <memory>

> std::auto_ptr<TControlCanvas> C( new TControlCanvas );

I've understood the matter, but I have some related
questions...

Why do you need to use std::auto_ptr?
Would it be the same with TControlCanvas *C = new
TControlCanvas()?
What differences are there?
What's the best way?

TIA,

Steve.

 
 
 

How to get access on TMemo Canvas ?

Post by zhang l » Sat, 28 Jun 2003 21:26:11


Quote:>    try with the following snippet.

> #include <memory>

> std::auto_ptr<TControlCanvas> C( new TControlCanvas );
> C->Control = Memo1;
> C->MoveTo( 0, 0 );
> C->LineTo( 100, 100 );

;-) I'm interest more. please.

TControlCanvas *C = new TControlCanvas;
C->Control = Memo1;
C->MoveTo( 0, 0 );
C->LineTo( 100, 100 );
delete C;

Li

 
 
 

How to get access on TMemo Canvas ?

Post by Hans Galem » Sat, 28 Jun 2003 21:27:30



> Why do you need to use std::auto_ptr?
> Would it be the same with TControlCanvas *C = new
> TControlCanvas()?
> What differences are there?

The difference is the memorymanager. With auto_ptr you don't have to
bother about freeing the memory when it goes out of scope. With new
you have to use delete (exept if the object handles that self).

Quote:> What's the best way?

Do your choice.

Hans.

 
 
 

How to get access on TMemo Canvas ?

Post by Steve_Alett » Sat, 28 Jun 2003 21:46:07





> Do your choice.

Done. What's yours? :-)

Steve.

 
 
 

How to get access on TMemo Canvas ?

Post by Hans Galem » Sat, 28 Jun 2003 22:07:02



>>Do your choice.

> Done. What's yours? :-)

Just switched from malloc and free to new and delete.

Nothing as conservative as a programmer, so auto_ptr is
for the future.

Hans.