Board index » cppbuilder » I again with a problem!

I again with a problem!


2005-09-21 10:54:05 AM
cppbuilder99
Hi!
I do the class.
class TCanvasPanel : public TScrollBox
{
public:
__fastcall TCanvasPanel(TComponent* AOwner)
: TScrollBox(AOwner)
{
Parent = (TWinControl*)AOwner;
TCPanel = 0;
TCPanel = new TPanel( this );
PanelCanvas = new TControlCanvas;
PanelCanvas->Control = TCPanel;
AutoScroll = true;
Ctl3D = false;
BevelInner = bvNone;
BevelKind = bkNone;
BevelOuter = bvNone;
BorderStyle = bsNone;
}
__fastcall virtual ~TCanvasPanel()
{
if( PanelCanvas != NULL )
delete PanelCanvas;
if( TCPanel !=NULL )
delete TCPanel;
}
//------------------------------
TPanel* TCPanel;
TControlCanvas* PanelCanvas;
};
I cause.
Area = new TCanvasPanel( MainForm );
Area->Align = alClient;
OldPanelWP = Area->WindowProc;
Area->WindowProc = NewPanelWP;
//--------------------------------
Document = new Gdiplus::Graphics( Area->Handle );
Document->SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
Area->Visible = true;
The message that Guard stands out.
Error 00029. 0x130C10 (Thread 0x0B00):
Method called on illegally casted object: Attempt to access 104 byte(s)
at
0x00F39150. The 'this' pointer points to heap block 0x00F39150 which is
only
100 bytes long.
Call Tree:
0x004036D2(=Project1.exe:0x01:0026D2) c:\program
files\borland\cbuilder6\include\vcl\Controls.hpp#1340
0x004032F1(=Project1.exe:0x01:0022F1)
D:\\DEVELOPER\\MYGRAPH\\MYCLASS\\TCanvasPanel.h#40
...
The memory block (0x00F39150) [size: 100 bytes] was allocated with
SysGetMem
Call Tree:
0x0042830B(=Project1.exe:0x01:02730B)
0x004032F1(=Project1.exe:0x01:0022F1)
D:\\DEVELOPER\\MYGRAPH\\MYCLASS\\TCanvasPanel.h#40
0x0040473C(=Project1.exe:0x01:00373C)
D:\DEVELOPER\MYGRAPH\MYCLASS\TViewPanel.h#110
...
In what a problem?
C++ Builder 6.
Thanks.
--
Отправлено M2, революционно?почтовой программой Opera:
www.opera.com/mail/
 
 

Re:I again with a problem!

"AGA" < XXXX@XXXXX.COM >wrote in message news:op.sxfmcfapcb5s4s@aga...
Quote
Parent = (TWinControl*)AOwner;
You should not be doing that. Asside from the fact that the Owner is not
guaranteed to be a TWinControl to begin with, your constructor has no need
for the Parent to be assigned anyway. Get rid of that. Assign the Parent
after the constructor exits.
Quote
TCPanel = new TPanel( this );
PanelCanvas = new TControlCanvas;
PanelCanvas->Control = TCPanel;
TPanel already has its own Canvas property. You do not need to use a
separate TControlCanvas.
Quote
if( PanelCanvas != NULL )
delete PanelCanvas;
Since you do not need to use the TControlCanvas, you can get rid of that.
Quote
if( TCPanel !=NULL )
delete TCPanel;
That is not necessary. You assigned your component to be the Owner for the
TPanel. As such, the TPanel will be freed automatically when your component
is freed.
Quote
OldPanelWP = Area->WindowProc;
Area->WindowProc = NewPanelWP;
Rather than the MainForm subclassing the WindowProc property, it would be
better if the component overrides its own WndProc() method and then triggers
events for whatever messages you need to handle.
Quote
Document = new Gdiplus::Graphics( Area->Handle );
That will not work. The constructor for the Graphics class expects an HDC,
not an HWND.
Gambit
 

Re:I again with a problem!

I wish to create a basis for drawing. I already asked here this question..
Has seen many examples, but everywhere use Bitmap. But all examples for
GDI.
I wish to draw by means of GDI +. And that scrolling was the automatic
device.
Who can will help with a code?
Thanks
C++ Builder 6.
 

{smallsort}

Re:I again with a problem!

"AGA" < XXXX@XXXXX.COM >wrote in message news:op.sxfvgzsicb5s4s@aga...
Quote
I wish to create a basis for drawing.
You are going about it all wrong.
Quote
Who can will help with a code?
What EXACTLY are you trying to accomplish? Please provide specific details.
Gambit