program MouseInput;
Uses WinCrt,WinMouse, Graph;
Var
GraphicsDriver, GraphicsMode,
ErrCode : smallint;
x, y: shortstring;
Begin
x:=GetMouseX;
Y:=GetMouseY;
Writeln('Initialising Graphics, please wait...');
GraphicsDriver := Detect;
InitGraph(GraphicsDriver, GraphicsMode,'');
GetmouseX();
GetmouseY();
OuttextXY(0,0,x);
readln();
end.
它给了我错误:23/20 鼠标.pas 错误:不兼容的类型:应获得"WORD"短字符串"但是我不知道如何更改它,以便在GetmouseX需要Word的情况下它可以工作。
将 X,Y 改回单词并将外表行更改为
OuttextXY(0,0,inttostr(x));
确保"sysutils"在你的使用条款中
您的 GetMouseX 和 GetMouseY 函数不返回结果,并且您调用它们的位置不会读取结果,我本以为您会得到堆栈溢出错误,因为它们调用自己(或者这是编译器错误)。
刚刚看到paulsm的评论(我不记得Turbo Pascal函数了),我认为你的代码应该是这样的:
InitGraph(GraphicsDriver, GraphicsMode,'');
x := GetmouseX();
y := GetmouseY();
OuttextXY(0,0,x);
从您的链接:
InitGraph(GraphicsDriver, GraphicsMode,'');
InitMouse;
x := GetmouseX;
y := GetmouseY;