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