Discussion:
OnDrawCell Event handler
(too old to reply)
Richard
2008-06-26 22:17:50 UTC
Permalink
Using 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
DEC
2008-06-27 22:49:28 UTC
Permalink
Post by Richard
Using 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.
Richard
2008-06-28 09:51:57 UTC
Permalink
Post by DEC
Post by Richard
Using 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
DEC
2008-06-29 20:23:40 UTC
Permalink
Post by Richard
Post by DEC
Post by Richard
Using 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
Richard
2008-06-30 09:23:31 UTC
Permalink
Dean,

Thank for your suggestions. It made me look more closely at some of my old code and I
noticed that the TRect argument was passed as a const. Adding const TRect to the handler
decraration fixed the problem.

Regards
Richard

Loading...