constructor TComboButton.Create(AOwner: TComponent);
var
mButtonsWidth:integer;
begin
inherited;
with TDBListCombo (Parent.Parent) do
mButtonsWidth := Width;
showmessage(inttostr(mButtonsWidth)); //****************
// Left := mButtonsWidth ;
end;
以上代码运行的时候出现如下错误:
Exception EAccessViolation in module Project1.exe at 00086F80.
Access violation at address 0048F80 in module Project1.exe.Read of address 00000024.
错误行在带星号的那行,如果注释该行则没有错误,请问这是什么原因呢?
不要在构造函数里取,可以在OnCreate,OnPaint,OnActivate之类事件中实现.一般来说,如果该控件有OnCreate事件的话,就在它里面加代码就好.