这是一段别人的程序,我把它复制到我的程序中,就出现:
[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;

解决方案 »

  1.   

    implementation{$R *.dfm}
    {$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.
      

  2.   

    这个const的作用和c的static的作用差不多属于静态变量。
    {$j+} 方法可以,
    也可以在project-->option-->compiler-->assignable typed constants 选中。