unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TSendMessage = function (hwnd : Longword; MSG : Longword;
wParam : Longint; lParam : longint ) : longint; stdcall;
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Instance : Longword;
MySendMessage : TSendMessage;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
const
StartPos : Integer = 0;
EndPos : Integer = -1;
begin
Edit1.SetFocus;
StartPos := Not StartPos;
EndPos := Not EndPos;
MySendMessage(Edit1.Handle, EM_SETSEL, StartPos, EndPos);end;procedure TForm1.FormCreate(Sender: TObject);
begin
Instance := LoadLibrary('user32.dll');
if( Instance <> 0 ) then
MySendMessage := GetProcAddress( Instance, 'SendMessageA');end;procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeLibrary(Instance);
end;end.报错:
[Error] Unit1.pas(40): Left side cannot be assigned to
[Error] Unit1.pas(41): Left side cannot be assigned to
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
即:TForm1.Button1Click方法中的StartPos := Not StartPos; EndPos := Not EndPos;
两句
为什么啊?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TSendMessage = function (hwnd : Longword; MSG : Longword;
wParam : Longint; lParam : longint ) : longint; stdcall;
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Instance : Longword;
MySendMessage : TSendMessage;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
const
StartPos : Integer = 0;
EndPos : Integer = -1;
begin
Edit1.SetFocus;
StartPos := Not StartPos;
EndPos := Not EndPos;
MySendMessage(Edit1.Handle, EM_SETSEL, StartPos, EndPos);end;procedure TForm1.FormCreate(Sender: TObject);
begin
Instance := LoadLibrary('user32.dll');
if( Instance <> 0 ) then
MySendMessage := GetProcAddress( Instance, 'SendMessageA');end;procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeLibrary(Instance);
end;end.报错:
[Error] Unit1.pas(40): Left side cannot be assigned to
[Error] Unit1.pas(41): Left side cannot be assigned to
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
即:TForm1.Button1Click方法中的StartPos := Not StartPos; EndPos := Not EndPos;
两句
为什么啊?
解决方案 »
- 求助delphi [Error] :')'expected but identifier 'where' found
- idtcpserver如何给指定的CLIENT发送数据。CLIENT如何接收
- 在做东东的时候的三个问题,网络连接,单实例,报表
- 远程管理的问题请教。
- 怎么知道一张图片的有效宽度及长度
- 怎样在DrawGrid的Cells里面画个checkbox!!!
- 网速的快慢问题
- 500分送上,求一个Grid的设计方法,有源代码更好!
- 怎样将query的结果返回给窗体?
- 有什么好的学习方法用来学习对硬件进行编程
- 请教大家一个问题.如何在dbgrid的最后一行做一个数据统计.
- 数据转换一定要设置一个变量吗?
procedure TForm1.Button1Click(Sender: TObject);
{$J+}
const
StartPos : Integer = 0;
EndPos : Integer = -1;
{$J-}
Syntax {$J+} or {$J-}
{$WRITEABLECONST ON} or {$WRITEABLECONST OFF}
Default {$J-}
{$WRITEABLECONST OFF}
Scope Local
The $J directive controls whether typed constants can be modified or not. In the {$J+} state, typed constants can be modified, and are in essence initialized variables. In the {
$J-} state, typed constants are truly constant, and any attempt to modify a typed constant causes the compiler to report an error.
Writeable consts refers to the use of a typed const as a variable modifiable at runtime. For example:const foo: Integer = 12;
begin
foo := 14;end.With $WRITEABLECONST OFF, this code produces a compile error on the assignment to the foo variable in the begin..end block. To fix it, change the const declaration to a var declaration.In previous versions of Delphi and Borland Pascal, typed constants were always writeable, corresponding to the {$J+} state. Old source code that uses writeable typed constants must be compiled in the {$J+} state, but for new applications it is recommended that you use initialized variables and compile your code in the {$J-} state.