onCursorUpdated understanding HCURSOR

47 views
Skip to first unread message

Muhammed İkbal Akpaça

unread,
Nov 5, 2012, 7:34:33 PM11/5/12
to berk...@googlegroups.com
Hi,

How do i get cursor type from HCURSOR?

i do something like this

  HCURSOR h = newCursor.GetCursor();
  if(h == (HCURSOR)0x00010005)
    std::cout << "cursor is arrow\n";
  else if(h == (HCURSOR)0x00010013)
    std::cout << "cursor is we resize\n";
  else if(h == (HCURSOR)0x00010015)
    std::cout << "cursor is ns resize\n";
  else if(h == (HCURSOR)0x00010021)
    std::cout << "cursor is pointer\n";

this works but i think i am missing something here. this feels like a hack.
How do you guys get cursor type?

Thank you.

mikbal

unread,
Nov 6, 2012, 8:35:29 PM11/6/12
to berk...@googlegroups.com
it seems windows reserves a few kilobytes for system resource handles.
mouse cursors are consirdered system resources. this was why handle
address never changed after app or system restart.

still to be on the safe side i found this method better,

// there are OCR_ enumerations for every system cursor. list is in winuser.h
HCURSOR systemArrow = (HCURSOR)LoadImage(NULL,
MAKEINTRESOURCE(OCR_NORMAL), IMAGE_CURSOR, 0, 0, LR_SHARED);

void onCursorUpdated(Window* win, const Berkelium::Cursor& newCursor)
{
if(newCursor.GetCursor() == systemArrow )
std::cout << "cursor is arrow\n";
}

yeah, this id the way i did it
i dont like winapi :) , didnt code in it since 2005.
Reply all
Reply to author
Forward
0 new messages