原文 : http://www.myexception.cn/c-builder/695189.html
动态创办的ComboBox控件,添加OnDrawItem事件是报错
www.MyException.Cn 网友分享于:2013-09-12 浏览:75次
动态创建的ComboBox控件,添加OnDrawItem事件是报错
[BCC32 Error] test.cpp(43): E2034 Cannot convert 'void (_fastcall * (_closure )(TWinControl *,int,TRect &,TOwnerDrawState))(TWinControl *,int,TRect &,TOwnerDrawState)' to 'TDrawItemEvent'
Full parser context
test.cpp(32): parsing: void _fastcall TForm1::Button1Click(TObject *)
请教一下,我动态的创建了一个ComboBox控件,添加了OnDrawItem事件,结果报错,找不到原因,Help
------解决方案--------------------
TRect 加一个const 就好了
[BCC32 Error] test.cpp(43): E2034 Cannot convert 'void (_fastcall * (_closure )(TWinControl *,int,TRect &,TOwnerDrawState))(TWinControl *,int,TRect &,TOwnerDrawState)' to 'TDrawItemEvent'
Full parser context
test.cpp(32): parsing: void _fastcall TForm1::Button1Click(TObject *)
请教一下,我动态的创建了一个ComboBox控件,添加了OnDrawItem事件,结果报错,找不到原因,Help
------解决方案--------------------
TRect 加一个const 就好了
class TForm1 : public TForm { __published: // IDE-managed Components TComboBox *ComboBox1; void __fastcall ComboBox1DrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State); void __fastcall myComboBox1DrawItem(TWinControl *Control, int Index, const TRect &Rect, TOwnerDrawState State); void __fastcall FormCreate(TObject *Sender); private: // User declarations TComboBox *ComboBox2; public: // User declarations __fastcall TForm1(TComponent* Owner); };