Animated Cursors
Stracka -- stracka@inet.dpt.com
Monday, July 22, 1996
Environment: Win95, VC++4.0, MFC4.0
when my app is busy, i'd like to change the cursor to something fun,
like a little animated cursor that i made up myself. when i load the
cursor from an external file, things work just fine. an
pseudo-example of this method follows:
// we've become busy
HCURSOR hCursor = LoadCursorFromFile("WIGGLY.ANI");
hCursor = SetCursor(hCursor);
:
: do busy-stuff
:
// we aren't busy anymore
SetCursor(hCursor);
the only problem with this method is (obviously) that i'd have to ship
the WIGGLY.ANI file along with my app. yuck. since dev studio
doesn't allow you to import animated cursors into your resource
script, i decided to try to use something i'd never used before: a
user-defined resource type. i imported "WIGGLY.ANI" and called it a
"Wiggly" resource, and gave it a resource id of IDR_WIGGLY. i then
tried the following:
// we've become busy
HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_WIGGLY),
"Wiggly");
HCURSOR handle = (HCURSOR)LoadResource(NULL, hRsrc);
HCURSOR hCursor = SetCursor(handle);
:
: do busy-stuff
:
// we aren't busy anymore
SetCursor(hCursor);
this didn't work out the way i'd hoped. i realized that in the first
example, the LoadCursorFromFile() call was giving me a
handle-looking-thing, whereas in the second example, the
LoadResource() call was giving me what appears to be a nice copy of
the WIGGLY.ANI file. SetCursor() seems to prefer the former over the
latter... :)
my question, then, is how would one go about stuffing an animated
cursor into an executable and then grab it on-the-fly to change the
current on-screen cursor?
-Mark Stracka
Distributed Processing Technology
ps. if any of you out there haven't gotten yourselves a copy of
Mike Blaszczak's MFC book, GO GET ONE! it is the most
informative, entertaining MFC book on the market, bar none.
great job, Mike, and thanks!
Brad Wilson/Crucial Software -- crucial@pobox.com
Friday, July 26, 1996
> HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_WIGGLY),
> "Wiggly");
> HCURSOR handle = (HCURSOR)LoadResource(NULL, hRsrc);
> HCURSOR hCursor = SetCursor(handle);
The result of LoadResource() is not a handle to a cursor. What you have a
handle to the memory of the data in the cursor file. I strongly suspect
that the easiest solution is to take the handle, dump the contents into a
temporary file and call LoadCursorFromFile() on the temporary file. None
of the APIs like CreateCursor() seem to indicate if they'll work with
animated cursors.
> ps. if any of you out there haven't gotten yourselves a copy of
> Mike Blaszczak's MFC book, GO GET ONE!
Plug plug plug. :-) Would you believe I bought it months ago and STILL
have not touched it yet? I hate moving. :-)
--
Brad Wilson, Objectivist philosopher, software engineer, web designer
crucial@pobox.com http://pobox.com/~crucial Objectvst@Undernet
"I'm never going to say I'm sorry for the essence of my soul"
| Вернуться в корень Архива
|