📄 lion-tutorial26.htm
字号:
.model flat, stdcall <br>
include \masm32\include\windows.inc <br>
include \masm32\include\user32.inc <br>
include \masm32\include\kernel32.inc <br>
include \masm32\include\gdi32.inc <br>
includelib \masm32\lib\user32.lib <br>
includelib \masm32\lib\kernel32.lib <br>
includelib \masm32\lib\gdi32.lib <br>
.data <br>
BitmapName db "MySplashBMP",0 <br>
ClassName db "SplashWndClass",0 <br>
hBitMap dd 0 <br>
TimerID dd 0
<p> .data <br>
hInstance dd ?
<p> .code
<p> DllEntry proc hInst:DWORD, reason:DWORD, reserved1:DWORD <br>
.if reason==DLL_PROCESS_ATTACH ; When the dll is loaded
<br>
<b> push hInst </b> <br>
<b> pop hInstance </b> <br>
<b> call ShowBitMap </b> <br>
.endif<br>
mov eax,TRUE <br>
ret <br>
DllEntry Endp <br>
ShowBitMap proc <br>
LOCAL wc:WNDCLASSEX <br>
LOCAL msg:MSG <br>
LOCAL hwnd:HWND <br>
mov wc.cbSize,SIZEOF
WNDCLASSEX <br>
mov wc.style, CS_HREDRAW
or CS_VREDRAW <br>
mov wc.lpfnWndProc,
OFFSET WndProc <br>
mov wc.cbClsExtra,NULL
<br>
mov wc.cbWndExtra,NULL
<br>
push hInstance <br>
pop wc.hInstance
<br>
mov wc.hbrBackground,COLOR_WINDOW+1
<br>
mov wc.lpszMenuName,NULL
<br>
mov wc.lpszClassName,OFFSET
ClassName <br>
invoke LoadIcon,NULL,IDI_APPLICATION
<br>
mov wc.hIcon,eax
<br>
mov wc.hIconSm,0
<br>
invoke LoadCursor,NULL,IDC_ARROW
<br>
mov wc.hCursor,eax
<br>
invoke RegisterClassEx, addr
wc <br>
INVOKE CreateWindowEx,NULL,ADDR
ClassName,NULL,\ <br>
<b>WS_POPUP</b>,CW_USEDEFAULT,\
<br>
CW_USEDEFAULT,250,250,NULL,NULL,\
<br>
hInstance,NULL
<br>
mov hwnd,eax
<br>
INVOKE ShowWindow, hwnd,SW_SHOWNORMAL
<br>
.WHILE TRUE <br>
INVOKE GetMessage, ADDR msg,NULL,0,0 <br>
.BREAK .IF (!eax) <br>
INVOKE TranslateMessage, ADDR msg <br>
INVOKE DispatchMessage, ADDR msg <br>
.ENDW <br>
mov eax,msg.wParam
<br>
ret <br>
ShowBitMap endp <br>
WndProc proc hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD <br>
LOCAL ps:PAINTSTRUCT <br>
LOCAL hdc:HDC <br>
LOCAL hMemoryDC:HDC <br>
LOCAL hOldBmp:DWORD <br>
LOCAL bitmap:BITMAP <br>
LOCAL DlgHeight:DWORD <br>
LOCAL DlgWidth:DWORD <br>
LOCAL DlgRect:RECT <br>
LOCAL DesktopRect:RECT
<p> .if uMsg==WM_DESTROY <br>
<b>
.if hBitMap!=0 </b> <br>
<b>
invoke DeleteObject,hBitMap </b> <br>
<b>
.endif </b> <br>
invoke PostQuitMessage,NULL <br>
.elseif uMsg==WM_CREATE
<br>
<b>
invoke GetWindowRect,hWnd,addr DlgRect </b> <br>
<b>
invoke GetDesktopWindow </b> <br>
<b>
mov ecx,eax </b> <br>
<b>
invoke GetWindowRect,ecx,addr DesktopRect </b> <br>
<b>
push 0 </b> <br>
<b>
mov eax,DlgRect.bottom </b> <br>
<b>
sub eax,DlgRect.top </b> <br>
<b>
mov DlgHeight,eax </b> <br>
<b>
push eax </b> <br>
<b>
mov eax,DlgRect.right </b> <br>
<b>
sub eax,DlgRect.left </b> <br>
<b>
mov DlgWidth,eax </b> <br>
<b>
push eax </b> <br>
<b>
mov eax,DesktopRect.bottom </b> <br>
<b>
sub eax,DlgHeight </b> <br>
<b>
shr eax,1 </b> <br>
<b>
push eax </b> <br>
<b>
mov eax,DesktopRect.right </b> <br>
<b>
sub eax,DlgWidth </b> <br>
<b>
shr eax,1 </b> <br>
<b>
push eax </b> <br>
<b>
push hWnd </b> <br>
<b>
call MoveWindow </b> <br>
<b>
invoke LoadBitmap,hInstance,addr BitmapName </b> <br>
<b>
mov hBitMap,eax </b> <br>
<b>
invoke SetTimer,hWnd,1,2000,NULL </b> <br>
<b>
mov TimerID,eax </b> <br>
.elseif uMsg==WM_TIMER <br>
<b>
invoke SendMessage,hWnd,WM_LBUTTONDOWN,NULL,NULL </b> <br>
<b>
invoke KillTimer,hWnd,TimerID </b> <br>
.elseif uMsg==WM_PAINT <br>
<b>
invoke BeginPaint,hWnd,addr ps </b> <br>
<b>
mov hdc,eax </b> <br>
<b>
invoke CreateCompatibleDC,hdc </b> <br>
<b>
mov hMemoryDC,eax </b> <br>
<b>
invoke SelectObject,eax,hBitMap </b> <br>
<b>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -