我不能加附件,只能如此了。
;====================================
.586
.model flat,stdcall
option casemap:none
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
include \masm32\include\pnglib.inc
xor eax, eax
push eax
lea eax, DWORD PTR [ebp-16]
push eax
mov eax, _hWnd
push eax
call GetWindowRect ;MROM Penalty
mov esi, wRect.bottom
sub esi, wRect.top
push esi
shr esi, 1
mov edi, wRect.right
sub edi, wRect.left
push edi
shr edi, 1
mov eax, SM_CYSCREEN
push eax
call GetSystemMetrics ;MROM Penalty
shr eax, 1
sub eax, esi
push eax
mov eax, SM_CXSCREEN
push eax
call GetSystemMetrics ;MROM Penalty
shr eax, 1
sub eax, edi
push eax
mov eax, _hWnd
push eax
call MoveWindow ;MROM Penalty
ret
CenterScreen ENDP
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; This code is largely ripped from loadfromresource example in PngLib
LoadPng proc ID:dword,pSize:dword
; In: ID: Resource ID of PNG file to load
; Out: pSize: Struct that this points to is filled with width & height of PNG
; eax Contains the handle to the new DIB
invoke GetObject,hBmp,sizeof bminfo,addr bminfo
cmp bminfo.bmBitsPixel,32
jne Abort
mov esi,bminfo.bmBits
yloop:
mov ecx,bminfo.bmWidth
; Set up the alpha for this scanline (in bl). Will be blended 50% with image alpha.
mov ebx,bminfo.bmHeight
shl bl,1
jnc xloop
not ebx
xloop:
mov eax,[esi]
rol eax,8
mov edx,eax
and eax,0FFh
mul bl
xchg eax,edx
rol eax,8
mul dh ; B * A
rol eax,8
mul dh ; G * A
rol eax,8
mul dh ; R * A
mov al,dh
ror eax,8
mov [esi],eax
add esi,4
dec ecx
jnz xloop
dec bminfo.bmHeight
jnz yloop
Abort:
ret
FadeBitmap endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; This snippet from Eoin's GUIBackBufferShell2 example
CreateCanvas Proc hDC:dword,biWidth:dword,biHeight:dword
LOCAL bih:BITMAPINFOHEADER
LOCAL pBb:dword
.IF uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.ELSEIF uMsg==WM_CREATE
; Load the Png file from the resource
invoke LoadPng,1,addr pngSize
mov hBitmap,eax
push pngSize.dWidth
pop winSize.dWidth
mov winSize.dHeight,255
; Get a screen DC, since UpdateLayeredWindow wants one.
invoke GetDC,0
mov hScreenDC,eax
; Create a new DC to select our bitmap into, since UpdateLayeredWindow doesn't accept
; bare bitmaps.
invoke CreateCompatibleDC,hScreenDC
mov hMemDC,eax
invoke SelectObject,eax,hBitmap
mov hOldBmp,eax
invoke CreateCompatibleDC,hScreenDC
mov hMemDC2,eax
invoke CreateCanvas,hMemDC2,pngSize.dWidth,255
mov hBitmap2,eax
invoke SelectObject,hMemDC2,hBitmap2
mov hOldBmp2,eax
invoke GetModuleHandle,SADD("User32")
invoke GetProcAddress,eax,SADD("UpdateLayeredWindow")
.if eax==NULL
invoke MessageBox,hWnd,SADD("Couldn't find UpdateLayeredWindow API. You need Windows XP or 2000 to run this program."),0,MB_OK
invoke SendMessage,hWnd,WM_CLOSE,0,0
.endif
mov pUlw,eax
.ELSEIF uMsg==WM_DESTROY
invoke KillTimer,hWnd,hTimer
; Free window image buffer
invoke SelectObject,hMemDC2,hOldBmp2
invoke DeleteObject,hBitmap2
invoke DeleteDC,hMemDC2
; Free PNG image buffer
invoke SelectObject,hMemDC,hOldBmp
invoke DeleteObject,hBitmap
invoke DeleteDC,hMemDC
; Release our handle to the screen DC
invoke ReleaseDC,hWnd,hScreenDC
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
.ELSEIF uMsg==WM_LBUTTONDOWN
; Move the window when holding down left mouse button
invoke SendMessage,hWnd,WM_NCLBUTTONDOWN,HTCAPTION,lParam
.ELSEIF uMsg==WM_RBUTTONUP
; Close the window when clicking right mouse button
invoke PostMessage,hWnd,WM_CLOSE,0,0
.ELSE
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.ENDIF
xor eax,eax
ret
WndProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
; Standard WinMain, except for WS_EX_LAYERED and WS_POPUP in the CreateWindowEx line.
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG