Board index » cppbuilder » Re: TShape, repaint & resize

Re: TShape, repaint & resize


2003-09-15 09:57:15 AM
cppbuilder27
"Jaepil Kim" < XXXX@XXXXX.COM >wrote in message
Quote
I tried to set an event in TSelectShape's constructor like this

this->OnResie = ShapeResize;
A component should *never* assign event handlers to its own events. That
prevents the user of the component from assigning its own handlers outside
of the component. Instead, you should be overriding the inherited Resize()
method instead.
Quote
I created a test application with that component. I found out
that if the TSelectShape is put on to a Form in design mode it
doesn't draw member objects. Even worse, in design mode it
doesn't recieve OnResize event....
Are you trying to do your custom drawing from inside the OnResize() event?
You should not be if you are. You should be overriding the inherited
Paint() method and doing all of your custom painting from there instead.
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
 
 

Re:Re: TShape, repaint & resize

Hi Gambit
Quote
A component should *never* assign event handlers to its own events. That
prevents the user of the component from assigning its own handlers outside
of the component. Instead, you should be overriding the inherited Resize()
method instead.
When i do this
class PCAKAGE TSelectShape : public TShape
{
...
public:
virtual void __fastcall Paint(void);
virtual void __fastcall Resize(void);
...
};
I creates and error message:
[C++ Error] SelectShape.h(35): E2113 Virtual function '_fastcall
TSelectShape::Resize()' conflicts with base class 'TControl'
Why can i override Paint function but not Resize function?
Thanks
 

Re:Re: TShape, repaint & resize

"Jaepil Kim" < XXXX@XXXXX.COM >wrote in message
Quote
I creates and error message:

[C++ Error] SelectShape.h(35): E2113 Virtual function '_fastcall
TSelectShape::Resize()' conflicts with base class 'TControl'

Why can i override Paint function but not Resize function?
Because you did not declare Resize() correctly. Resize() is not 'virtual',
it is 'DYNAMIC' instead, ie:
DYNAMIC void __fastcall Resize(void);
There is a subtle but important difference between 'virtual' and 'DYNAMIC',
they are not exactly the same thing.
Whenever you override methods, make sure that you are always referring to
either the help file or the header file to see how they are actually
declared.
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
 

{smallsort}

Re:Re: TShape, repaint & resize

Now i got it.
Thanks alot. :)
Remy Lebeau (TeamB) wrote:
Quote
"Jaepil Kim" < XXXX@XXXXX.COM >wrote in message
news:3f6522f5$ XXXX@XXXXX.COM ...


>I creates and error message:
>
>[C++ Error] SelectShape.h(35): E2113 Virtual function '_fastcall
>TSelectShape::Resize()' conflicts with base class 'TControl'
>
>Why can i override Paint function but not Resize function?


Because you did not declare Resize() correctly. Resize() is not 'virtual',
it is 'DYNAMIC' instead, ie:

DYNAMIC void __fastcall Resize(void);

There is a subtle but important difference between 'virtual' and 'DYNAMIC',
they are not exactly the same thing.

Whenever you override methods, make sure that you are always referring to
either the help file or the header file to see how they are actually
declared.


Gambit



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03