Announcement

Collapse
No announcement yet.

Use custom cursor pointer for app only

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use custom cursor pointer for app only

    Hi,
    I've checked the forums and found some threads related to this but none of the solutions worked.

    Basically I want to use a custom cursor pointer inside the application's window only. If the cursor moves outside, it should return to the default cursor pointer.

    Thanks.

  • #2
    Originally posted by Ronin View Post
    Hi,
    I've checked the forums and found some threads related to this but none of the solutions worked.

    Basically I want to use a custom cursor pointer inside the application's window only. If the cursor moves outside, it should return to the default cursor pointer.

    Thanks.
    If you look around you will find examples that do work in the app only, I have not used them for years as there only toys but it is possible.
    Plugins or Sources MokoX
    BunnyHop 2021 Here

    Comment


    • #3
      Originally posted by kingzooly View Post
      If you look around you will find examples that do work in the app only, I have not used them for years as there only toys but it is possible.
      Can you link me? All those that I've tried haven't worked properly. For example it would switch to custom pointer but then it would switch back to the default as soon as I moved the cursor.

      Comment


      • #4
        Cursors are windows specific so if you set a cursor on a window then move out of that window the default cursor for the new window will be used and the window you just left when you enter it again will show its default cursor, this is how Microsoft designed windows so if your looking to say have a busy cursor shown on all windows off your application all the time (till you turn it off) then you handle the WM_SETCURSOR message and return true if you are in a busy state and wish your busy cursor to remain or false to do the default cursor.

        None of the tutorials or posts on this forum do work for persistent cursors but it can be done easily with MemoryEx.

        Comment


        • #5
          Originally posted by Shrek View Post
          Cursors are windows specific so if you set a cursor on a window then move out of that window the default cursor for the new window will be used and the window you just left when you enter it again will show its default cursor, this is how Microsoft designed windows so if your looking to say have a busy cursor shown on all windows off your application all the time (till you turn it off) then you handle the WM_SETCURSOR message and return true if you are in a busy state and wish your busy cursor to remain or false to do the default cursor.

          None of the tutorials or posts on this forum do work for persistent cursors but it can be done easily with MemoryEx.
          Any chance you can create a small .apz example / snippet code so I can look at it? I'm terrible with MemoryEx.

          Comment


          • #6
            I can't right now as the PC to hand has no AMS on it but there are lots of examples here showing MemoryEx subclassing the main window so just copy that then deal with the message, ie (air code):

            Code:
            Imbusy = true; -- set once you've set the cursor
            
             local s = Subclass.Create(MYMainWindowHandle,function(hWnd,uMsg,wParam,lParam)
              if uMsh == WM_SETCURSOR then
               if Imbusy then
                return true
               end
              end
              return Subclass.OldWinProc(hWnd, uMsg, wParam, lParam)
             end)
            obviously you'll need to use the set cursor and load cursor functions;

            https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx

            https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx

            Comment


            • #7
              Code:
              sCursorFile = "AutoPlay\\Docs\\Normal Select.cur";
              nCursorID = 32512;
              
              local hCursor = DLL.CallFunction(_SystemFolder.."\\user32.dll", "LoadCursorFromFileA", "\""..sCursorFile.."\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
              DLL.CallFunction(_SystemFolder.."\\User32.dll", "SetCursor", hCursor..","..nCursorID, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
              This piece of code is changing the cursor and it works fine for like a second but then the application crashes with a 'has stopped working'.

              I've added your code after my code as well and it's not stopping the application from crashing.

              Comment


              • #8
                Use the MemoryEx load library feature:

                Code:
                User32 = Library.Load("user32.dll");
                and remember the argument for LoadCursorFromFile is a pointer to a string not a string.


                Also in the SETCURSOR message I can't remember if you have to reset the cursor before returning true or not as it's been a while.

                Search the forum for MemoryEx examples for dealing with strings, I haven't got that on this PC either to help.

                Comment


                • #9
                  Not having any luck. Thanks anyhow, Shark.

                  If I change the SetCursor to SetSystemCursor, it works fine but that's for a system-wide cursor change and I don't need that.

                  Comment

                  Working...
                  X