Win7与Xp,直观上最大的区别便是界面上的改变了,win7拥有着华丽的玻璃界面.今天就写一下关于这方面的文章.
毫无疑问,一切都是微软提供,以下一切内容参考于MSDN中http://msdn.microsoft.com/en-us/library/windows/desktop/aa969540(v=vs.85).aspx这篇文章.
先给出代码.再做解释:
1 .386 2 .model flat,stdcall 3 option casemap:none 4 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 5 ; Include 文件定义 6 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 7 include windows.inc 8 include gdi32.inc 9 includelib gdi32.lib 10 include user32.inc 11 includelib user32.lib 12 include kernel32.inc 13 includelib kernel32.lib 14 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 15 ; 数据段 16 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 17 .data? 18 hInstance dd ? 19 hWinMain dd ? 20 lpAeroEnb dd ? 21 lpAero dd ? 22 lpClientEnb dd ? 23 hDll dd ? 24 25 DWM_BLURBEHIND struct 26 27 dwFlags dword ? 28 fEnable dword ? 29 hRgnBlur dword ? 30 fTransitionOnMaximized dword ? 31 32 DWM_BLURBEHIND ends 33 34 .const 35 szClassName db 'MyClass',0 36 szCaptionMain db 'Translucent windows demo',0 37 szText db 'Win32 Assembly, Simple and powerful !',0 38 szDll db 'Dwmapi.dll',0 39 szEnable db 'DwmEnableComposition',0 40 szToClient db 'DwmExtendFrameIntoClientArea',0 41 szEnableClient db 'DwmEnableBlurBehindWindow',0 42 43 44 45 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 46 ; 代码段 47 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 48 .code 49 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 50 ; 窗口过程 51 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 52 _ProcWinMain proc uses ebx edi esi hWnd,uMsg,wParam,lParam 53 local @stPs:PAINTSTRUCT 54 local @stRect:RECT 55 local @hDc 56 local @stRect1:RECT 57 local @stBlurBehind:DWM_BLURBEHIND 58 59 mov @stRect1.left,0 60 mov @stRect1.top,0 61 mov @stRect1.right,0 62 mov @stRect1.bottom,25 63 64 mov @stBlurBehind.dwFlags,1 65 mov @stBlurBehind.fEnable, TRUE 66 mov @stBlurBehind.hRgnBlur,NULL 67 mov @stBlurBehind.fTransitionOnMaximized,FALSE 68 69 mov eax,uMsg 70 ;******************************************************************** 71 .if eax == WM_CREATE 72 73 mov @stRect1.left,-1 74 mov @stRect1.top,-1 75 mov @stRect1.right,-1 76 mov @stRect1.bottom,-1 77 78 lea eax, @stRect1 79 push eax 80 push hWnd 81 call lpAero 82 83 ; lea eax, @stBlurBehind 84 ; push eax 85 ; push hWnd 86 ; call lpClientEnb 87 88 .elseif eax == WM_PAINT 89 invoke BeginPaint,hWnd,addr @stPs 90 mov @hDc,eax 91 92 invoke GetClientRect,hWnd,addr @stRect 93 94 invoke GetStockObject,BLACK_BRUSH 95 mov ebx,eax 96 97 lea ecx,@stRect 98 99 invoke FillRect,@hDc,ecx,ebx 100 101 invoke EndPaint,hWnd,addr @stPs 102 ;******************************************************************** 103 .elseif eax == WM_CLOSE 104 invoke DestroyWindow,hWinMain 105 invoke PostQuitMessage,NULL 106 ;******************************************************************** 107 .else 108 invoke DefWindowProc,hWnd,uMsg,wParam,lParam 109 ret 110 .endif 111 ;******************************************************************** 112 xor eax,eax 113 ret 114 115 _ProcWinMain endp 116 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 117 _WinMain proc 118 local @stWndClass:WNDCLASSEX 119 local @stMsg:MSG 120 121 122 invoke GetModuleHandle,NULL 123 mov hInstance,eax 124 invoke RtlZeroMemory,addr @stWndClass,sizeof @stWndClass 125 ;******************************************************************** 126 ; 注册窗口类 127 ;******************************************************************** 128 invoke LoadCursor,0,IDC_ARROW 129 mov @stWndClass.hCursor,eax 130 push hInstance 131 pop @stWndClass.hInstance 132 mov @stWndClass.cbSize,sizeof WNDCLASSEX 133 mov @stWndClass.style,CS_HREDRAW or CS_VREDRAW 134 mov @stWndClass.lpfnWndProc,offset _ProcWinMain 135 mov @stWndClass.hbrBackground,COLOR_WINDOW + 1 136 mov @stWndClass.lpszClassName,offset szClassName 137 138 139 140 141 invoke RegisterClassEx,addr @stWndClass 142 ;******************************************************************** 143 ; 建立并显示窗口 144 ;******************************************************************** 145 invoke CreateWindowEx,WS_EX_CLIENTEDGE,offset szClassName,offset szCaptionMain,\ 146 WS_OVERLAPPEDWINDOW,\ 147 100,100,600,400,\ 148 NULL,NULL,hInstance,NULL 149 mov hWinMain,eax 150 151 152 153 invoke ShowWindow,hWinMain,SW_SHOWNORMAL 154 invoke UpdateWindow,hWinMain 155 ;******************************************************************** 156 ; 消息循环 157 ;******************************************************************** 158 .while TRUE 159 invoke GetMessage,addr @stMsg,NULL,0,0 160 .break .if eax == 0 161 invoke TranslateMessage,addr @stMsg 162 invoke DispatchMessage,addr @stMsg 163 .endw 164 ret 165 166 _WinMain endp 167 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 168 start: 169 invoke LoadLibrary, offset szDll 170 mov hDll, eax 171 172 invoke GetProcAddress, hDll, offset szEnable 173 mov lpAeroEnb, eax 174 175 invoke GetProcAddress, hDll, offset szToClient 176 mov lpAero, eax 177 178 invoke GetProcAddress, hDll, offset szEnableClient 179 mov lpClientEnb, eax 180 181 push 1 182 call lpAeroEnb 183 184 call _WinMain 185 186 invoke ExitProcess,NULL 187 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 188 end start