Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Animated Cursor

marshallc
Beginner
876 Views
What is the best way to animatea cursor in FORTRAN? I'm trying to find references to animating a cursor, but I haven't found anything in either of the books that I have at hand. Does anyone have any recommended sources or suggestions for animating a cursor?
0 Kudos
3 Replies
Paul_Curtis
Valued Contributor I
876 Views
CASE (WM_TIMER)
   nframe = nframe + 1
   IF (nframe > max_frames) nframe = 1  ! circular progression
   lret = SetCursor (LoadCursor(NULL, cursorimage(nframe)))
   lret = SetTimer (hwnd, 1, frame_interval, NULL)
   res = 1

This is a bit crude (I can immediately think of likely circumstances in which the animation would look jerky due to processer loading resulting in uneven frame rates), but may be all you need.
0 Kudos
Paul_Curtis
Valued Contributor I
876 Views
(The intel web editor really sucks, ate most of my post. It seems the src editor feature is really unreliable.)
What preceded my code sample was a suggestion that none of the available fortran-oriented text tell you squat about Win32 programming, they're all worthless wastes of time. What you need to do is sit down with Petzold, translate his examples into F90 and work with them for about 8 months, and you'll be there. This appears to be how everyone learns Windows programming, has nothing to do with whatever language you use.
For an animated cursor, you would presumably createin advance a set of cursor images, and then use a timer to pingthe proc at the frame-change interval so thecursor can be updated to the next frame, in a circular sequence.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
876 Views
Paul you overcomplicated it -- there's no need to do anything special (like WM_TIMER) for an animated cursorcompared witha normal cursor in an application. Thus, a LoadCursor plus handling WM_SETCURSOR will do (just tried it). The animated cursor (.ani) can be included as a resource, like an ordinary .cur file. Just tried it with "banana.ani" from standard Windows set:
Code:
// MyApp.rc
IDCUR_BANANA       CURSOR DISCARDABLE "C:WinntCursorsbanana.ani"
The only gotcha is that (as far as I know) VS Resource editor does not allow you to draw one -- you'll probably have to find some 3rd-party tool on the web for it (no, I don't know of any offhand).
Jugoslav
0 Kudos
Reply