这是一段别人的程序,我把它复制到我的程序中,就出现:
[Error] PresideForm.pas(163): Left side cannot be assigned to
而在原来程序中没问题,我看不出有什么不同?
?“带类型常量”怎么用呢,帮一下忙!!
procedure TMainForm.Button1Click(Sender: TObject);
const
oldh : DWORD = 0;
begin
if not boolean(oldh) then
begin
oldh := GetWindowLong(Memo1.handle,GWL_WNDPROC);
SetWindowLong(Memo1.handle,GWL_WNDPROC,integer(@s));
end
else
begin
SetWindowLong(Memo1.handle,GWL_WNDPROC,oldh);
oldh := 0;
end;
end;
[Error] PresideForm.pas(163): Left side cannot be assigned to
而在原来程序中没问题,我看不出有什么不同?
?“带类型常量”怎么用呢,帮一下忙!!
procedure TMainForm.Button1Click(Sender: TObject);
const
oldh : DWORD = 0;
begin
if not boolean(oldh) then
begin
oldh := GetWindowLong(Memo1.handle,GWL_WNDPROC);
SetWindowLong(Memo1.handle,GWL_WNDPROC,integer(@s));
end
else
begin
SetWindowLong(Memo1.handle,GWL_WNDPROC,oldh);
oldh := 0;
end;
end;
{$J+} //add this 注:
In the default {$J-} compiler state, typed constants can not have new values assigned to them; they are, in effect, read-only variables. However, if the {$J+} compiler directive is in effect, typed constants can have new values assigned to them; they behave essentially like initialized variables.
{$j+} 方法可以,
也可以在project-->option-->compiler-->assignable typed constants 选中。