Accessing protected members of component from Form

[b][red]This message was edited by Alien_SM at 2006-8-3 23:11:44[/red][/b][hr]
[b][red]This message was edited by Alien_SM at 2006-8-3 22:0:16[/red][/b][hr]
Hi All

This will be my first post in C++ Builder Msb Board

Ok so here is the question. I have been looking at the tutorials on the DB grid on delphi.about.com. They pull a trick there to accomplish allot of the nifty tricks:

Accessing protected members of a DBGrid
[code]
uses
Windows, Messages, ..., Grids, DBGrids, ... ;

type THackDBGrid = class(TDBGrid);

type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
....
[/code]

Then late in same unit he uses the following lines
[code]
THackDBGrid(DBGrid1).RowHeights[0] := 20;
[/code]
Ok off course that type of casting is not a good idea in C++ Builder. Event tried declaring a clean class and doing the same just to test.

I also tried the following:
[code]
typedef class THackGrid : TDBGrid
{
friend class TForm1;
};
[/code]

Then in a event of one of the components like a button on the form:
[code]
THackGrid* Testing1;

Testing1 = dynamic_cast(DBGrid1);
Testing1->RowHeights[1] = 10;;
[/code]

This causes a exception which is right if I think about it. But is something similar possible.

Regards

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion