使用图形 window 时的 FreePascal 鼠标输入?

FreePascal mouse input when using graph window?

GetMouseX 在使用图形时不起作用 window。

uses wincert,graph,winmouse;
var x,y:integer;
Begin
x:=GetMouseX;
End.

这让我 Error:Identifier 未找到 "GetMouseX"。 使用单元 'mouse' 尝试此操作在控制台 window 中有效,但在图形 window.

中无效

有人可以帮忙吗?

是的,winmouse 不是 version/subset 的鼠标,而 wincrt 是 windows "graph" 使用的 crt 的子集..

鼠标操作图形只是一个单位。查看设备以查看可用的功能(lpressed、rpressed、getlastbuttonpress 等)

经过长时间的搜索,我设法找到了 winmouse 的功能列表。该页面是......波兰语或其他语言,但示例代码非常有效。

uses graph, wincrt, winmouse;
var gd,gm: integer;
    ch:char;
    i:integer;
    mposx, mposy, state: longint;
begin
 gd := d4bit;
 gm := m640x480;
 initgraph(gd,gm,'');
 initmouse;
 randomize;
 for i:=1 to 10 do
   circle(random(640),random(480),150);
 repeat
   if keypressed then ch:= readkey;
   if lpressed then
     begin
     repeat until not lpressed;
     getmousestate(mposx,mposy,state);
     if getpixel(mposx,mposy)<15 then
       begin
       setfillstyle(solidfill,random(14)+1);
       floodfill(mposx,mposy,15);
       end;
     end;
 until ch = #27;
 closegraph;
end.

感谢您的帮助。