Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Animated Cursors in Resources

Posted on 1999-07-16
11
Medium Priority
?
331 Views
Last Modified: 2013-11-20
Can anybody tell me how the to place and load a animated cursor from the Resource file ?  I'm using VC 6.0 SP3..

Thanks

Wayne Gibson
0
Comment
Question by:gibson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 1310182
Hi gibson,

just create a new cursor resource, i.e. IDC_CURSOR1. FindInFiles IDC_CURSOR1 and go to following line in the *.rc file:

IDC_CURSOR1             CURSOR  DISCARDABLE     "res\\res\\cursor1.cur"

Replace the cursor file name, i.e.:

IDC_CURSOR1             CURSOR  DISCARDABLE     "res\\myCusror.ani"

that's all,

hope that helps,

ZOPPO
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 1310183
Sorry, forgot stuff to load, but it's the same as with normal cursors:

HCURSOR hCursor = AfxGetApp()->LoadCursor( IDC_CURSOR1 );

Use OnSetCursor() handler or SetClassLong() to set the cursor

ZOPPO
0
 

Author Comment

by:gibson
ID: 1310184
We tried this but it doesn't work, but hCursor keeps return NULL. Do you have any example have any other examples ?

0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 31

Expert Comment

by:Zoppo
ID: 1310185
Hi gibson,

this is what I wrote to test it:

---------------------------------------------------
HCURSOR hCursor;

BOOL CDmtDlg::OnInitDialog()
{
      CDialog::OnInitDialog();

      hCursor = AfxGetApp()->LoadCursor( IDC_CURSOR1 );
      SetClassLong( m_hWnd, GCL_HCURSOR, (LONG)hCursor );
...
}
---------------------------------------------------

it works here.

Make sure that the resource instance handle is correct. If not, use AfxSetResourceHandle() with the instance handle of the module containing the resource for the cursor.

hope that helps,

ZOPPO
0
 
LVL 3

Expert Comment

by:VCGuru
ID: 1310186
Do not edit any resource
In your view's constructor
CMyView::CMyView()
{
hcur = LoadCursorFromFile("c:\\windows\\cursor\\AppStart.ani");
}

In the SetCursor
CMyView::OnSetCursor()
{
if(nHitTest == HTCLIENT)
      {
      
            SetCursor(hcur);
            return 1;
      }
else
      return CView::OnSetCursor(pWnd, nHitTest, message);
}
This will work.
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 1310187
Hi VCGuru,

Question was 'how to place and load ... from resource'.

and why not, it's possible...

With FindResource( ..., ..., RT_ANICURSOR ) you can get a resource handle which can be used with LoadResource(...).

ZOPPO
0
 

Author Comment

by:gibson
ID: 1310188
This isn't load the Cursor from the resource, it's loading it from the file....  I want to be able to send the application out without any ANI files...
0
 

Author Comment

by:gibson
ID: 1310189
Hi Zoppo,

>HCURSOR hCursor;
>BOOL CDmtDlg::OnInitDialog()
>{
>CDialog::OnInitDialog();
>
>hCursor = AfxGetApp()->LoadCursor( IDC_CURSOR1 );
>SetClassLong( m_hWnd, GCL_HCURSOR, (LONG)hCursor );
>}
The Value that we get back at
   hCursor = AfxGetApp()->LoadCursor( IDC_CURSOR1 );
is 0x000000(NULL)

Any ideas ???

Wayne


0
 
LVL 31

Expert Comment

by:Zoppo
ID: 1310190
What OS do you use?

I found one MSDN article (Poking Around Under the Hood: A Programmer's View of Windows NT 4.0) which tells following:

----------------------
...
Finally, the Windows NT USER32 introduces two new resource types. The RT_ANICURSOR and RT_ANIICON resources (animated cursors and animated icons) will be joining other illustrious resources such as menus, bitmaps, and string tables in an RC file near you. The binary format for a resource file is the same as for Windows 95.
...
----------------------

Because I have WinNT4 I cannot tell you if it's possible with Win95, but help for FindResource() or DrawIconEx() does not describe any restriction with Win95. Hmm, don't know...

ZOPPO

0
 
LVL 2

Expert Comment

by:wyy_cq
ID: 1310191
LoadImage can load each icon from a ani_file.

0
 

Accepted Solution

by:
lakshminarasimman earned 200 total points
ID: 1310192
First you can import the resource giving the path of the animated cursor using the resource import option. Then proceed as usual to load the cursor using LoadCursor function and SetCursor to display the cursor
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question