 |
|
 |
Hi, i'm having this problem, the cursor wont work in the dialog i created from a multiple document project. But when i tried with a dialog based project. it works. Any idea whats wrong?
|
|
|
|
 |
|
 |
Unfortunately the presented code only loads 16-color animated cursors from resource. However, the LoadCursorFromFile API is able to load 256-color ones directly from .ani files. Is there a possibility to load them from resources as well?
Regards,
BB
http://spin.bartoszbien.com
|
|
|
|
 |
|
 |
Where do I have to put the function LoadAniCursor()
HCURSOR LoadAniCursor(UINT nID)
{
HINSTANCE hInst=AfxGetInstanceHandle();
HRSRC hRes=FindResource(hInst,MAKEINTRESOURCE(nID),"ANICURSORS");
DWORD dwSize=SizeofResource(hInst, hRes);
HGLOBAL hGlob=LoadResource(hInst, hRes);
LPBYTE pBytes=(LPBYTE)LockResource(hGlob);
return (HCURSOR)CreateIconFromResource(pBytes,dwSize,FALSE,0x00030000);
}
Adrian
|
|
|
|
 |
|
 |
Hi,
I have included an MSFlexgrid control into my MFC application and I don't know if it is necessary to add the ocx file, as well as another files into the project to distribute the program (and what files?). And is it needed to make a registering routine for this Activex control in Windows register?
Thanks
|
|
|
|
 |
|
 |
voila comment j'ai resolu le probleme:
HCURSOR LoadAniCursor(UINT nID)
{
UINT i, j;
HANDLE hTempFile;
DWORD dwW, dwPos;
char buff[4096];
char TempFileName[MAX_PATH];
char TempDir[MAX_PATH];
//Création du nom de fichier temporaire
GetTempPath(MAX_PATH, TempDir);
GetTempFileName(TempDir, "~", 0, TempFileName);
//On recupere le pointer sur la ressource en memoire
HRSRC hRes=FindResource(hinst,MAKEINTRESOURCE(nID),"ANICURSORS");
DWORD dwSize=SizeofResource(hinst, hRes);
HGLOBAL hGlob=LoadResource(hinst, hRes);
LPBYTE pBytes=(LPBYTE)LockResource(hGlob);
//on ecrit dans le fichier temporaire
hTempFile = CreateFile(TempFileName,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
j = 0; i = 4096;
do{ for (i = 0; (i < 4096) && j < dwSize; i++, j++)
buff[i] = pBytes[j];
dwPos = SetFilePointer(hTempFile, 0, NULL, FILE_END);
LockFile(hTempFile, dwPos, 0, i, 0);
WriteFile(hTempFile, buff, i, &dwW, NULL);
UnlockFile(hTempFile, dwPos, 0, i, 0);
} while (i == 4096);
CloseHandle(hTempFile);
return (LoadCursorFromFile(TempFileName));
}
ensuite plus qu'a faire:
HCURSOR move = LoadAniCursor(ID_Move);
par exemple!
En esperant que cela vous aura aide! (j'espere bien )
@ bientot,
Joshu.
|
|
|
|
 |
|
 |
My solution:
//In CAniCursorSampleDlg.h
protected:
HICON m_hIcon;
HCURSOR m_hCur;
~~~~~~~~~~~~~~~
//Add above
//In CAniCursorSampleDlg.cpp
BOOL CAniCursorSampleDlg::OnInitDialog()
{
................
//Add follow line
m_hCur = LoadAniCursor(IDR_LUCKYS_HORSE);
}
BOOL CAniCursorSampleDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
if(m_bShowHorse)
{
SetCursor(m_hCur);
~~~~~~~~~~~~~~~~~~~
//change above line
...............
}
//
|
|
|
|
 |
|
 |
/////////////////////////////////////////////////////////////////////////////
//
// 21
//
IDR_HORSE_CURSOR 21 DISCARDABLE "res\\horse.ani"
You can use this instead of the function:
HCURSOR LoadAniCursor(UINT nID)
{
HINSTANCE hInst=AfxGetInstanceHandle();
HRSRC hRes=FindResource(hInst,MAKEINTRESOURCE(nID),"ANICURSORS");
DWORD dwSize=SizeofResource(hInst, hRes);
HGLOBAL hGlob=LoadResource(hInst, hRes);
LPBYTE pBytes=(LPBYTE)LockResource(hGlob);
return (HCURSOR)CreateIconFromResource(pBytes,dwSize,FALSE,0x00030000);
}
It has to be manually edited in your .rc file, but it gives you ANIMATED CURSORS in your Resource View. Now you can just use the regular .cur function to load your .ani file.
Either way I'm still having the same problem of my cursor disappering.
|
|
|
|
 |
|
 |
Great code but after a few clicks, my animated cursor disappears.
I'm running XP, VC++ SP5. Even the demo cursor does it. Any suggestions?
|
|
|
|
 |
|
 |
I wrote a DLL that loads animated cursors from a resource file and works on Win95 and UP.
Visit http://www.figmo.net/wmloadanicursor.html
|
|
|
|
 |
|
|
 |
|
 |
You've got to be kidding me! Do you really expect anyone to pay for that??
- Nonni
|
|
|
|
 |
|
 |
hi
i tried to use your sample but i didn't understood how exactly to import an animated gif file to the project resource
please supply forthere details/instructions for doing it
I"M SURE A LOT OF VC++ DEVELOPERS WOULD LIKE TO GET THAT ANSWER
THANKS
RON MAMAN (ISRAEL)
|
|
|
|
 |
|
 |
CreateIconFromResource() Always failed under Windows98/98SE
And WindowsMe
Windows2000 will work. ( Win95/NT not tested )
If you try to GetLastError(); You'll got a "Successful" Error.
Why ? And how to get Cursor animated in Win98/ME ?
Any suggestion
|
|
|
|
 |
|
 |
Hi...
The code is working great..
but is there any known problem when you imported more then one ani cursor??
|
|
|
|
 |
|
 |
Hi...
The code is working great..
but is there any known problem when you imported more then one ani cursor??
|
|
|
|
 |
|
 |
Why animated gifs? You use simple animated cursors
|
|
|
|
 |