Jump to content
  • Advertisement
Sign in to follow this  

find cursor image being used

This topic is 1510 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just wondering if anyone knows how to find out what cursor image is being used. I'm trying to set a texture to a sprite based on the mouse state.




Edited by David Ga11agher

Share this post

Link to post
Share on other sites

Thanks ankhd, but because I'm not manually setting the mouse I can't retrieve it but didn't know about that thanks.

what I wanted was for my engine (using 3DWebUI) I wanted to change my sprite (used for navigating the web) based on the windows mouse cursor while it's hidden.

GetCursorInfo() wasn't enough as it wouldn't work while hidden but someone was generous enough to share a function that worked.


anyway for anyone else...


load some global cursors...


function to get the hcursor...

HCURSOR GetCurrentCursorHandle()
    POINT pt;
    HWND hWnd;
    DWORD dwThreadID, dwCurrentThreadID;
    HCURSOR hCursor = NULL;

    // Find out which window owns the cursor
    hWnd = WindowFromPoint(pt);

    // Get the thread ID for the cursor owner.
    dwThreadID = GetWindowThreadProcessId(hWnd, NULL);

    // Get the thread ID for the current thread
    dwCurrentThreadID = GetCurrentThreadId();

    // If the cursor owner is not us then we must attach to
    // the other thread in so that we can use GetCursor() to
    // return the correct hCursor
    if (dwCurrentThreadID != dwThreadID) {

        // Attach to the thread that owns the cursor
        if (AttachThreadInput(dwCurrentThreadID, dwThreadID, TRUE)) {

            // Get the handle to the cursor
            hCursor = GetCursor();

            // Detach from the thread that owns the cursor
            AttachThreadInput(dwCurrentThreadID, dwThreadID, FALSE);
    } else
        hCursor = GetCursor();

    return hCursor;

in use...

//cursor info...
HCURSOR hc = GetCurrentCursorHandle();
//change cursor texture...
if(pWebTexture2D[i].gCursor != hc)
if(hc == gCursor_Arrow)
else if(hc == gCursor_Hand)
else if(hc == gCursor_IBeam)
pWebTexture2D[i].gCursor = hc;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!