0
votes

I was trying to convert Touch input to mouse input. But now I have a strange problem, the ShowCursor function works randomly.

here is part of my code

case ETouchMove:
    if (mInMove)
    {
        int X = Point->Move.X;
        int Y = Point->Move.Y;
        mCursor.X = ((mCursorBak.X + mSpeed*X) < GetSystemMetrics(SM_CXSCREEN) 
                  && (mCursorBak.X + mSpeed*X) >0)
                    ? mCursorBak.X + mSpeed*X : 0;
        mCursor.Y = ((mCursorBak.Y + mSpeed*Y) < GetSystemMetrics(SM_CXSCREEN) 
                   && (mCursorBak.Y + mSpeed*Y) >0) 
                     ? mCursorBak.Y + mSpeed*Y : 0;

        SetCursorPos(mCursor.X, mCursor.Y);
        SetPhysicalCursorPos(mCursor.X, mCursor.Y);
        ShowCursor(true);
    }
    break; 

It sometime works, but most time the cursor just won't show up during moving. I saw that on MSDN page someone said that this function only works on window created by the same thread. However after trying seems no difference.

It seems I keep receiving CURSOR_SUPPRESSED which is new in win8. Is there anyway to unsuppressed since it sometime still works? I also searched through stackoverflow but seems no answers yet, could anyone give some tips?Thanks in advance.

working on a tablet without mouse win8.1 visual studio 2013

1

1 Answers

2
votes

Solved, someone else might found helpful.

  1. stop using set pos functions
  2. use sendinput movement

        //SetCursorPos(mCursor.X, mCursor.Y);
        //SetPhysicalCursorPos(mCursor.X, mCursor.Y);
        //ShowCursor(true);
    
        INPUT Command = { 0 };
        Command.type = INPUT_MOUSE;
        Command.mi.time = 0;
        Command.mi.dx = (mCursor.X * 65536) / GetSystemMetrics(SM_CXSCREEN);
        Command.mi.dy = (mCursor.Y * 65536) / GetSystemMetrics(SM_CYSCREEN);
        Command.mi.mouseData = 0;
        Command.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
        SendInput(1, &Command, sizeof(INPUT));