T
terry_zhou82
Unregistered / Unconfirmed
GUEST, unregistred user!
我的在程序的主窗体添加一个MEMO控件,使他可以相应客户的输入,如果是键盘,就启动MEMO,如果是鼠标,则启动canvans,但是又一个问题,就是每当我点击鼠标后,他总是要先画一条长的线,然后才会按照我的要求画线,即,鼠标点到哪里,线就画到那里。请问,这个是什么原因呢?我的代码如下var mouselbstate:boolean; implementation {$R *.dfm} procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); begin refresh; memo1.Visible :=true; memo1.SetFocus ; end; procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if button=mbleft then begin mouselbstate:=true; memo1.Visible :=false; canvas.MoveTo(x,y); canvas.LineTo(x,y); end; end; procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin memo1.Visible :=false; if mouselbstate then canvas.LineTo(x,y); end; procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin memo1.Visible :=false; if button=mbleft then mouselbstate:=false; end; procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin memo1.Visible :=false; refresh; end; procedure TForm1.Memo1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin memo1.Visible :=false; refresh; end; end.