Главная страница | назад





Article #16366: Delphi to C++Builder

 Question and Answer Database

FAQ1366C.txt   Delphi to C++Builder
Category   :VCL
Platform    :All
Product    :C++Builder  1.x

Question:

I am moving to C++Builder from Delphi and C++Builder won't let 
me use TCanvas.TextOut.

    

Answer:

In C++ if you have an object created on the stack you access it 
directly using the "dot" operator. For example if class foo 
contained a member function called bar(). I your create an 
instance of foo on the stack you would call test as follows:
   
        foo test;
        test.bar();
    
If you create the foo object in heap memory you have to access
 it through a pointer. With pointers you use the "arrow" 
operator for access.  So if foo was created on the heap you 
would call bar() like this:
   
        foo* test = new foo;
        test->bar();
    
Now for your question.  All components on a form have to be 
accessed via pointers, so you need to use the arrow operator.  
Your code would look some thing like this:

        Canvas->TextOut(...);

        

7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99