Announcement

Collapse
No announcement yet.

Use custom cursor pointer for app only

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

  • Ronin
    replied
    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.

    Leave a comment:


  • Shrek
    replied
    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.

    Leave a comment:


  • Ronin
    replied
    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.

    Leave a comment:


  • Shrek
    replied
    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;



    Loads the specified cursor resource from the executable (.EXE) file associated with an application instance. (ANSI)

    Leave a comment:


  • Ronin
    replied
    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.

    Leave a comment:


  • Shrek
    replied
    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.

    Leave a comment:


  • Ronin
    replied
    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.

    Leave a comment:


  • kingzooly
    replied
    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.

    Leave a comment:


  • Ronin
    started a topic Use custom cursor pointer for app only

    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.
Working...
X