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;
不管是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;