• Advertisement
Sign in to follow this  

find cursor image being used

This topic is 1240 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.

(win32)

 

thanks.

Edited by David Ga11agher

Share this post


Link to post
Share on other sites
Advertisement

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

gCursor_Arrow = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
gCursor_Hand = LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND));
gCursor_IBeam = LoadCursor(NULL, MAKEINTRESOURCE(IDC_IBEAM));
 

function to get the hcursor...

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


    // Find out which window owns the cursor
    GetCursorPos(&pt);
    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...

if(pWebTexture2D[i].bWebView_Has_Focus)
{
//---------------------------------------------
//cursor info...
HCURSOR hc = GetCurrentCursorHandle();
//change cursor texture...
if(pWebTexture2D[i].gCursor != hc)
{
if(hc == gCursor_Arrow)
{
iSpriteTextureSet(pWebTexture2D[i].Camera_Sprite_MC,pWebTexture2D[i].Camera_Mouse_Tex2D[0]);
}
else if(hc == gCursor_Hand)
{
iSpriteTextureSet(pWebTexture2D[i].Camera_Sprite_MC,pWebTexture2D[i].Camera_Mouse_Tex2D[1]);
}
else if(hc == gCursor_IBeam)
{
iSpriteTextureSet(pWebTexture2D[i].Camera_Sprite_MC,pWebTexture2D[i].Camera_Mouse_Tex2D[2]);
}
pWebTexture2D[i].gCursor = hc;
}
//...

Share this post


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

  • Advertisement