编译代码,访问数据库时,使用AlphaControls控件的TsDBCombox控件,出现访问地址违规错误:
Project Accounting.exe raised exception class AccessViolation with message 'Access violation at address 773C11D7 in module 'ntdll.dll'
出现错误的代码:
function TacMainWnd.CallPrevWndProc(const Handle: hwnd; const Msg: longint; const WParam: WPARAM; var LParam: LPARAM): LRESULT;
var
M: TMessage;
begin
if Assigned(OldWndProc) then begin
M.Msg := Msg;
M.WParam := WParam;
M.LParam := LParam;
M.Result := 0;
OldWndProc(M);
Result := M.Result;
LParam := M.LParam;
end
else
if Assigned(OldProc) then
try
Result := CallWindowProc(OldProc, Handle, Msg, WParam, LParam) // 出错
except
Result := 0;
end
else
Result := 0;
end;
原本是在源代码中,查找出错处。一直末找到。后经过控件的参数时,发现:
sDBComboBox1.Items值中,有一行空行,删除该空行后,问题解决。通过,这一解决方案,我们在找问题,不能一味地在源代码中找,同时在控件的参数中,也可能出错引起访问的错误。