问题
I have a Form "TForm1" having one "TAnimate1". I have one AVI Resource as File Name "Animate 01.avi" with Resource Identifier "AVI" and one "Animated Cursor" as File Name "Cursor 01.ani" with Resource Identifier "8".I wish to play "Animate 01.avi" on "FormCreate" event and set default cursor as "8". I'm using "Delphi XE2".
Please download my project file from "http://hotfile.com/dl/137675080/34f701f/KoushikHalder01.7z.html" and tell where to rectify.
回答1:
Ok, downloaded...
First, you're putting the avi in an 'RCDATA' section. As I've already said, that won't work. An animate control loads the avi file of an AVI type. So this line
AVI RCDATA "KoushikHalder.avi"
in your '.rc' file, should be in fact:
AVI AVI "KoushikHalder.avi"
You can put whatever you like for ID, but the resource type should be AVI.
Second, you would load the avi by its resource identifier. You've given an 'AVI' identifier for it. So this line in your code:
Animate01.ResName :='KoushikHalder.avi';
should in fact be:
Animate01.ResName :='AVI';
Third, your '.ani' file does not conform with the standards. See this question for details. You won't be able to load that ani file unless you correct it.
Fourth, you're not loading the ani file correctly. It's identifier is not '8', it's 8. So the below line:
Screen.Cursors[8] := LoadCursor(HInstance, '8');
Should be
Screen.Cursors[8] := LoadCursor(HInstance, MakeIntResource(8));
(or Pointer(8)..).
Lastly, you have to set the cursor somewhere to your ani file so that you can see it. For instance:
Screen.Cursor := 8;
or
BitBtn01.Cursor := 8;
I hope this helps...
来源:https://stackoverflow.com/questions/8566777/animated-cursor-playing