Dear GRX
I have experienced trouble using GrMouseWarp under Win32(MinGW). Using it seems to position the cursor in the wrong place. Also, GrMouseErase does not seem to remove the cursor. I enclose a sample program. This draws a white cross at the centre. I then try and position the mouse cursor over it using GrMouseWarp. This seems to give the wrong position. Hiding it with GrMouseErase does not seem to work.
I would be grateful of any advice.
/* Program draws a white cross in the centre of the screen */ /* It then attempts to position the mouse at his point. */ /* Using GrMouseWarp(oX,oY) it attempts to match this point */ /* GrMouseEraseCursor() attempts to hide the mouse cursor */ /* Under Win32(MinGW) (W2000 & XP) it fails in these last two tasks */ /* Program is halted by a key press */
#include <stdio.h> #include <grx20.h>
int main() { GrMouseEvent event; /*Mouse event */ int x,y,buttons; /* Mouse position & buttons */ int xMax,yMax,oX,oY; /* Size of screen & centre */ GrGraphicsMode gM; GrVideoAdapter gV;
GrSetMode(GR_default_graphics);
GrMouseInit(); /* In this order */ xMax = GrSizeX(); yMax = GrSizeY(); oX = xMax/2; oY = yMax/2; GrMouseWarp(oX,oY); GrMouseEraseCursor();
printf("xMax = %d yMax = %d\n",xMax,yMax); printf("oX = %d oY = %d\n",oX,oY);
gM = GrCurrentMode(); printf("Graphics mode = %d\n",gM);
gV = GrAdapterType(); printf("Video adapter = %d\n",gV);
while(1) { GrMouseGetEvent(GR_M_MOTION,&event); GrLine(oX-4,oY,oX+4,oY,GrWhite()); GrLine(oX,oY-4,oX,oY+4,GrWhite()); if(GrKeyPressed()) break; } GrMouseUnInit();
return 0; }
Peter Williams wrote:
I have experienced trouble using GrMouseWarp under Win32(MinGW). Using it seems to position the cursor in the wrong place.
I have experienced the same. My impression is that it uses absolute coordinates and does not take the position of the GRX window into account.
My idea for a solution (-:in Pascal syntax):
W32GetCursorPos ( P ); x := P.x + x - MouseWhere.x; y := P.y + y - MouseWhere.y; GrMouseWarp ( x, y );
... with (MouseWhere.x, MouseWhere.y) being the current and (x, y) being the desired new position of the mouse cursor, as recorded by the program.
Peter