£ £ ±¾ÎĽéÉÜÈçºÎ¸ø¹¤¾ßÀ¸Ìí¼Ó±³¾°£¬ÓÃÕâ¸ö·½·¨ÄãÒ²¿ÉÒÔ¸øÊÓͼµÈÌí¼Ó±³¾°¡£ÏÂͼΪʾÀý³ÌÐòµÄÔËÐÐЧ¹ûͼ£¬Àý×Ó
£ £
ÔÀí
£ £ Windows ÔÚÖØ»´°¿ÚµÄ±³¾°Ê±»áÏò´°¿Ú·¢ËÍ WM_ERASEBKGND ÏûÏ¢¡£Èç¹û³ÌÐò×Ô¼º²»´¦Àí¸ÃÏûÏ¢£¬Windows »áÓÃ×¢²á´°¿ÚÀàʱ WNDCLASS ½á¹¹µÄ hbrBackground ³ÉÔ±Ö¸¶¨µÄË¢×ÓÀ´ÖØ»±³¾°¡£ÎÒÃÇÖ»ÐèÒª½Ó¹Ü¸ÃÏûÏ¢£¬»ÉÏÎÒÃÇÐèÒªµÄ±³¾°£¬È»ºó֪ͨ Windows ²»ÓÃÖØ»±³¾°¼´¿É¡£
£ £ ¾ßÌåµ½¹¤¾ßÀ¸µÄ±³¾°ÈçºÎʵÏÖ£¬Ö»ÐèÒª×ÓÀ໯¹¤¾ßÀ¸´°¿Ú£¬ÎÒÃǾÍÄܹ»´¦Àí¹¤¾ßÀ¸µÄ±³¾°ÖØ»ÏûÏ¢¡£
Àý×Ó
.386
.model flat,stdcall
option casemap:none
;****************************************************************************************
include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\gdi32.inc
include c:\masm32\include\comctl32.inc
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\gdi32.lib
includelib c:\masm32\lib\comctl32.lib
;****************************************************************************************
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
TBProc proto :DWORD,:DWORD,:DWORD,:DWORD
;****************************************************************************************
.data
ClassName db "SimpleWinClass",0
AppName db "´ø±³¾°µÄ¹¤¾ßÀ¸",0
MenuName db "MAINMENU",0
ToolbarButtons TBBUTTON <0, 1000, TBSTATE_ENABLED, TBSTYLE_BUTTON,0, NULL, NULL>
£ £ £ £ £ £ £ £ TBBUTTON <1, 1001, TBSTATE_ENABLED, TBSTYLE_BUTTON,0, NULL, NULL>
£ £ £ £ £ £ £ £ TBBUTTON <NULL, NULL, NULL, TBSTYLE_SEP, NULL, NULL>;--- seperator
£ £ £ £ £ £ £ £ TBBUTTON <2, 1002, TBSTATE_ENABLED, TBSTYLE_BUTTON,0, NULL, NULL>
£ £ £ £ £ £ £ £ TBBUTTON <3, 1003, TBSTATE_ENABLED, TBSTYLE_BUTTON,0, NULL, NULL>
£ £ £ £ £ £ £ £ TBBUTTON <4, 1004, TBSTATE_ENABLED, TBSTYLE_BUTTON,0, NULL, NULL>
£ £ £ £ £ £ £ £ TBBUTTON <NULL, NULL, NULL, TBSTYLE_SEP, NULL, NULL>;--- seperator
£ £ £ £ £ £ £ £ TBBUTTON <5, 1005, TBSTATE_ENABLED, TBSTYLE_BUTTON,0, NULL, NULL>
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hMenu dd ?
hToolBar dd ?
OldTBProc dd ?
hBmpBk dd ?
.const
IDI_MAIN equ 900
IDB_TOOLBAR equ 901
IDB_BKGROUND equ 902
IDC_FILEOPEN equ 903
;****************************************************************************************
.code
start:
£ £ £ £ invoke GetModuleHandle, NULL
£ £ £ £ mov hInstance,eax
£ £ £ £ invoke GetCommandLine
£ £ £ £ mov CommandLine,eax
£ £ £ £ invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
£ £ £ £ invoke InitCommonControls
£ £ £ £ invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
£ £ £ £ LOCAL wc:WNDCLASSEX
£ £ £ £ LOCAL msg:MSG
£ £ £ £ LOCAL hwnd:HWND
£ £ £ £ mov wc.cbSize,SIZEOF WNDCLASSEX
£ £ £ £ mov wc.style, CS_HREDRAW or CS_VREDRAW
£ £ £ £ mov wc.lpfnWndProc, offset WndProc
£ £ £ £ mov wc.cbClsExtra,NULL
£ £ £ £ mov wc.cbWndExtra,NULL
£ £ £ £ push hInstance
£ £ £ £ pop wc.hInstance
£ £ £ £ mov wc.hbrBackground,COLOR_WINDOW+1
£ £ £ £ mov wc.lpszMenuName,NULL
£ £ £ £ mov wc.lpszClassName,offset ClassName
£ £ £ £ invoke LoadIcon,NULL,IDI_APPLICATION
£ £ £ £ mov wc.hIcon,eax
£ £ £ £ mov wc.hIconSm,eax
£ £ £ £ invoke LoadCursor,NULL,IDC_ARROW
£ £ £ £ mov wc.hCursor,eax
£ £ £ £ invoke LoadMenu, hInst, offset MenuName
£ £ £ £ mov hMenu, eax
£ £ £ £ invoke RegisterClassEx, addr wc
£ £ £ £ invoke CreateWindowEx,NULL,addr ClassName,addr AppName,\
£ £ £ £ £ £ £ £ £ £ £ £ WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
£ £ £ £ £ £ £ £ £ £ £ £ CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,hMenu,\
£ £ £ £ £ £ £ £ £ £ £ £ hInst,NULL
£ £ £ £ mov hwnd,eax
£ £ £ £ invoke ShowWindow, hwnd,SW_SHOWNORMAL
£ £ £ £ invoke UpdateWindow, hwnd
£ £ £ £ .WHILE TRUE
£ £ £ £ £ £ £ £ invoke GetMessage, addr msg,NULL,0,0
£ £ £ £ £ £ £ £ .BREAK .IF (!eax)
£ £ £ £ £ £ £ £ invoke TranslateMessage, addr msg
£ £ £ £ £ £ £ £ invoke DispatchMessage, addr msg
£ £ £ £ .ENDW
£ £ £ £ mov eax,msg.wParam
£ £ £ £ ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
£ £ £ £ .IF uMsg==WM_DESTROY
£ £ £ £ £ £ £ £ invoke PostQuitMessage,NULL
£ £ £ £ .ELSEIF uMsg==WM_SIZE
£ £ £ £ £ £ £ £ invoke SendMessage, hToolBar, uMsg, wParam, lParam
£ £ £ £ .ELSEIF uMsg==WM_CREATE
£ £ £ £ £ £ £ £ invoke LoadIcon, hInstance, IDI_MAIN
£ £ £ £ £ £ £ £ invoke SendMessage, hWnd, WM_SETICON, ICON_SMALL, eax
£ £ £ £ £ £ £ £ invoke LoadBitmap, hInstance, IDB_BKGROUND
£ £ £ £ £ £ £ £ mov hBmpBk, eax
£ £ £ £ £ £ £ £ invoke CreateToolbarEx,hWnd,WS_CHILD or WS_VISIBLE or TBSTYLE_FLAT or WS_BORDER\
£ £ £ £ £ £ £ £ £ £ £ £ £ £ £ £ 1, 6, hInstance, IDB_TOOLBAR, ADDR ToolbarButtons,\
£ £ £ £ £ £ £ £ £ £ £ £ £ £ £ £ 8, 32, 32, 32, 32, SIZEOF TBBUTTON
£ £ £ £ £ £ £ £ mov hToolBar, eax
£ £ £ £ £ £ £ £ invoke SendMessage, hToolBar, TB_AUTOSIZE, NULL, NULL
£ £ £ £ £ £ £ £ invoke SetWindowLong, hToolBar, GWL_WNDPROC, addr TBProc
£ £ £ £ £ £ £ £ mov OldTBProc, eax
£ £ £ £ .ELSE
£ £ £ £ £ £ £ £ invoke DefWindowProc,hWnd,uMsg,wParam,lParam
£ £ £ £ £ £ £ £ ret
£ £ £ £ .ENDIF
£ £ £ £ xor eax,eax
£ £ £ £ ret
WndProc endp
TBProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
£ £ £ £ local rect:RECT
£ £ £ £ local hDC:HDC
£ £ £ £ local hMemDC:HDC
£ £ £ £ local bm:BITMAP
£ £ £ £ .IF uMsg==WM_ERASEBKGND
£ £ £ £ £ £ £ £ mov eax, wParam
£ £ £ £ £ £ £ £ mov hDC, eax
£ £ £ £ £ £ £ £ invoke CreateCompatibleDC, hDC
£ £ £ £ £ £ £ £ mov hMemDC, eax
£ £ £ £ £ £ £ £ invoke GetObject, hBmpBk, sizeof BITMAP, addr bm
£ £ £ £ £ £ £ £ invoke SelectObject, hMemDC, hBmpBk
£ £ £ £ £ £ £ £ invoke GetClientRect, hWnd, addr rect
£ £ £ £ £ £ £ £ mov ebx, rect.left
£ £ £ £ £ £ £ £ .WHILE ebx<rect.right
£ £ £ £ £ £ £ £ £ £ £ £ invoke BitBlt, hDC, ebx, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY
£ £ £ £ £ £ £ £ £ £ £ £ add ebx, bm.bmWidth
£ £ £ £ £ £ £ £ .ENDW
£ £ £ £ £ £ £ £ invoke DeleteDC, hMemDC
£ £ £ £ £ £ £ £ invoke ReleaseDC, hWnd, hDC
£ £ £ £ .ELSE
£ £ £ £ £ £ £ £ invoke CallWindowProc, OldTBProc, hWnd, uMsg, wParam, lParam
£ £ £ £ £ £ £ £ ret
£ £ £ £ .ENDIF
£ £ £ £ xor eax, eax
£ £ £ £ ret
TBProc endp
end start
·ÖÎö
invoke SetWindowLong, hToolBar, GWL_WNDPROC, addr TBProc
mov OldTBProc, eax
×ÓÀ໯¹¤¾ßÀ¸´°¿Ú£¬±£´æÔÀ´µÄ´°¿Ú¹ý³Ì¡£
.IF uMsg==WM_ERASEBKGND
£ £ £ £ mov eax, wParam
£ £ £ £ mov hDC, eax
£ £ £ £ invoke CreateCompatibleDC, hDC
£ £ £ £ mov hMemDC, eax
£ £ £ £ invoke GetObject, hBmpBk, sizeof BITMAP, addr bm
£ £ £ £ invoke SelectObject, hMemDC, hBmpBk
£ £ £ £ invoke GetClientRect, hWnd, addr rect
£ £ £ £ mov ebx, rect.left
£ £ £ £ .WHILE ebx<rect.right
£ £ £ £ £ £ £ £ invoke BitBlt, hDC, ebx, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY
£ £ £ £ £ £ £ £ add ebx, bm.bmWidth
£ £ £ £ .ENDW
£ £ £ £ invoke DeleteDC, hMemDC
£ £ £ £ invoke ReleaseDC, hWnd, hDC
´¦Àí¹¤¾ßÀ¸µÄ WM_ERASEBKGND ÏûÏ¢£¬¸ù¾Ý±³¾°Í¼Æ¬µÄ´óСƽÆÌÕû¸ö¹¤¾ßÀ¸¿Í»§Çø¡£
CopyRight (C) 2001-2002 Ò»¿éÈýëǮ本文地址:http://com.8s8s.com/it/it29627.htm