Post by RichardPost by DECPost by RichardUsing Rad Studio 2007 I have created a TStringGrid component in my program. When I try to
assign an OnDrawCell handler tor the Grid, the compiler issued the following error :-
[BCC32 Error] Unit1.cpp(27): E2034 Cannot convert 'void (_fastcall *)(TObject
*,int,int,TRect &,TGridDrawState)' to 'TDrawCellEvent'
I have done this before in CBuilder 6 with no trouble.
What am I doing wrong?
Can anyone help?
TIA
Richard
From the error message it's possible that your function is not a
member of your form, you might check that. Otherwise you should post
the function that the compiler is complaining about, perhaps there's a
subtle typo in your declaration.
HTH.
Thanks for your help.
The function in question is -
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol, int ARow,
TRect &Rect, TGridDrawState State)
{
TStringGrid *g = (TStringGrid *)Sender;
}
It is a copy of the function generated by the IDE when making the assignment in the IDE.
The assignment -
OnDrawCell = StringGrid1DrawCell;
fails.
Regards
Richard- Hide quoted text -
- Show quoted text -
The phrase "It is a copy of..." makes me wonder -- copied from where?
From another form? If so make sure you changed the class qualifier
for the copied function (TForm1:: in your definition above) to the
proper name of the current form. Also, how is the StringGrid1DrawCell
function declared in the header? Which section is it in -- public:,
private:, published:, etc.?
I'm still feeling like the compiler thinks it's not a member, which
would be based on the header declaration.
I too usually do custom drawing in String grids, including the latest
compiler version, so we know it works.
-Dean