Uncle Remus tales:#37a Animation
We are writing a player based on the
SysAnimate32 class. We create a window, on this window we upload a child window with the class
SysAnimate32 indicating the file that we want to play.
Create a child window using the
CreateWindowEx function. We do not need to register the window class, since it was already registered by Windows. When creating the screen, specify "SysAnimate32" as the class name for
CreateWindowsEx. Other parameters that we must specify are the handle of the parent window and the
ID of the control. The control
ID should be unique if we used several controls to distinguish this control from others. But since the control we have is the only one set
ID = 0. We also need to specify the screen sizes and the coordinates of its upper left corner. Normally, the child window is created during the processing of the
WM_CREATE message of the main window. We will create a child window before processing the message loop. After creating the animation management tool, we send the
ACM_OPEN message via the SendMessage function to open the AVI clip and load it into memory. The message specifies the path to the AVI file.
LRESULT WINAPI SendMessage(
_In_ HWND hWndControl, //A handle to the window whose window procedure will receive the message
_In_ UINT ACM_OPEN, //The message to be sent
_In_ WPARAM hinst, //Additional message-specific information
_In_ LPARAM lpszName //Additional message-specific information
);
Parameters- Hinst - The descriptor of the module instance from which the resource should be loaded. Set this value to the HINSTANCE module that created the window. Note - if the window is created using a DLL, then hinst is the HINSTANCE DLL value, and not the application that accesses the DLL.
- LpszName - A pointer to a buffer that contains the path to the AVI file or the name of the AVI resource. Alternatively, this parameter can consist of the AVI resource identifier in the low word and the zero in the high word. To create this value, use the MAKEINTRESOURCE macro. The control loads the AVI resource from the module specified by the hinst parameter. The AVI resource must be of type "AVI". If this parameter is zero, the system will close the AVI file, which was previously opened in the animator, if it existed. The AVI file or resource specified with lpszName should not contain audio data. It should be without sound.
; GUI #
include win64a.inc
ACM_OPEN = WM_USER + 100
ACS_AUTOPLAY = 4
ID_ANIMATE = 101
.code
WinMain proc
local msg:MSG
local hwnd:QWORD
xor ebx,ebx
mov esi,IMAGE_BASE
mov ecx,offset FileNameCur
invoke LoadCursorFromFile
mov edi,offset ClassName
push rax ;hIconSm
push rdi ;lpszClassName
push rbx ;lpszMenuName
push COLOR_WINDOW;hbrBackground
push 10005h ;hCursor
push rax ;hIcon
push rsi ;hInstance
push rbx ;cbClsExtra & cbWndExtra
pushaddr WndProc ;lpfnWndProc
push sizeof WNDCLASSEX;cbSize & style
invoke RegisterClassEx,esp ;addr WNDCLASSEX
push rbx
push rsi ;rsi=400000h
push rbx
push rbx
push 440
push 510
push 10
push 10
sub esp,20h
invoke CreateWindowEx,0,edi,edi,WS_CAPTION or WS_SYSMENU or WS_VISIBLE
mov hwnd,rax
push rbx
push rsi;IMAGE_BASE
push ID_ANIMATE
push rax;hwnd
push rbx;The width and height of the frame will be adjusted automatically
push rbx
push 20
push 20
sub esp,20h
mov r8d,offset NoText
mov edx,offset Animate32
invoke CreateWindowEx,WS_EX_STATICEDGE+WS_EX_CLIENTEDGE,,,WS_CHILD+WS_VISIBLE+WS_TABSTOP+ACS_AUTOPLAY
movr qword ptr [rsp+20h],AviFile
invoke SendDlgItemMessage,hwnd,ID_ANIMATE,ACM_OPEN,IMAGE_BASE
lea edi,msg
@@: invoke GetMessage,edi,0,0,0
invoke DispatchMessage,edi
jmp @b
WinMain endp
WndProc: cmp edx,WM_DESTROY
je wmDESTROY
jmp DefWindowProc
wmDESTROY:invoke ExitProcess,0
;---------------------------------------
ClassName db 'Uncle Remus tales:#37a Animation',0
FileNameCur db "br_Rabbit3.cur",0
AviFile db 'output.avi',0
Animate32 db "SysAnimate32"
NoText db 0
end
There is link for
output.avi file. To play via "
SysAnimate32", the avi-file should not be compressed (therefore it has such a large size) and can not contain audio data