Delphi Bug!!!(0分)

  • 主题发起人 主题发起人 bcb
  • 开始时间 开始时间
B

bcb

Unregistered / Unconfirmed
GUEST, unregistred user!
Delphi Bug:

不管是TComboBox,TListBox:

AControl.Items.InsertObject(0,TObject(-1));
AControl.Items.Objects[0]; //出现异常


Fixed Bug:

function TComboBoxStrings.GetObject(Index: Integer): TObject;
begin
Result := TObject(SendMessage(ComboBox.Handle, CB_GETITEMDATA, Index, 0));
if Longint(Result) = CB_ERR then
Error(SListIndexError, Index);
end;

改为:

TComboBox:

function TComboBoxStrings.GetObject(Index: Integer): TObject;
var
Text: array[0..4095] of Char;
begin
Result := TObject(SendMessage(ComboBox.Handle, CB_GETITEMDATA, Index, 0));
if (Longint(Result) = CB_ERR) and
( SendMessage(ComboBox.Handle, CB_GETLBTEXT, Index, Longint(@Text))=CB_ERR) then
Error(SListIndexError, Index);
end;



TListBox:

function TListBoxStrings.GetObject(Index: Integer): TObject;
begin
Result := TObject(ListBox.GetItemData(Index));
if Longint(Result) = LB_ERR then Error(SListIndexError, Index);
end;

改为:

function TListBoxStrings.GetObject(Index: Integer): TObject;
begin
Get(Index);
Result := TObject(ListBox.GetItemData(Index));
//if Longint(Result) = LB_ERR then Error(SListIndexError, Index);
end;
 
GZ!---- 什么意思???
 
接受答案了.
 

Similar threads

S
回复
0
查看
711
SUNSTONE的Delphi笔记
S
S
回复
0
查看
706
SUNSTONE的Delphi笔记
S
I
回复
0
查看
465
import
I
I
回复
0
查看
452
import
I
I
回复
0
查看
426
import
I
后退
顶部