[WIN32 程序] 写了个实现窗口半透明效果的程序 最初版 望多批评(转载)
http://www.转载自己的 也把程序帖一下罢
Dialog_SetLayeredWindowAttributes.rar
(457.89 KB)
程序代码:
;MASMPlus 代码模板 - 以对话框做为主窗口的程序 ;***************************************************************************************************************** ;作者:zklhp ;Email:zklhp@ ;QQ:493165744 ;最后更新:2010.4.3 ;版权所有 转载请保持完整 ;***************************************************************************************************************** .386 .Model Flat, StdCall Option Casemap :None Include windows.inc Include user32.inc Include kernel32.inc Include gdi32.inc Include comctl32.inc include USkin.inc includelib gdi32.lib IncludeLib user32.lib IncludeLib kernel32.lib IncludeLib comctl32.lib includelib USkin.lib Include rsrc.inc include macro.asm ;include DSkinLite.inc ;includeLib dskinlite.lib DlgProc PROTO :DWORD,:DWORD,:DWORD,:DWORD ID_TIMER1 equ 1001 WS_EXD_LAYERED equ 80000h DLG_MAIN equ 100 .data szAboutText db 'By zklhp',0dh,0ah,'Email:zklhp@',0dh,0ah db '版权所有 转载请保持完整 谢谢!',0 szHelpText db '本软件运行后会自动获取鼠标移过处的窗口 当遇到想要隐藏的窗口时 点击左Ctrl键即可将所设不透明度应用于鼠标所在窗口',0dh,0ah db '不透明值从0到255 数组越小不透明度越高 0为完全隐藏',0dh,0ah db '特别注意 请勿将不透明度设置的过低(10以下就很难看到了) 否则会造成窗口透明过度而隐藏!',0 x FLOAT 210.0f y FLOAT 1.0f .data? hInstance dd ? szBufferCaption db MAX_PATH dup(?) szBufferClass db MAX_PATH dup(?) hWindow dd ? hDlg dd ? dwAlpha dd ? .CODE START: invoke GetModuleHandle,NULL mov hInstance,eax invoke USkinInit,NULL,NULL,CTXT("VistaPerfection.msstyles") ;初使化USkin invoke USkinApplyColorTheme,x,y invoke InitCommonControls invoke DialogBoxParam,hInstance,IDD_DLG1,0,offset DlgProc,0 invoke ExitProcess,0 _TimerProc proc uses edi esi ebx, hWnd:HWND, uMsg:UINT, idEvent:UINT, dwTime:DWORD LOCAL stMousePos:POINT invoke GetCursorPos, addr stMousePos invoke WindowFromPoint, stMousePos.x, stMousePos.y mov hWindow, eax invoke GetWindowText, eax, offset szBufferCaption, sizeof szBufferCaption invoke SetDlgItemText, hDlg, IDC_CAPTION, offset szBufferCaption invoke GetClassName, hDlg, offset szBufferClass, sizeof szBufferClass invoke SetDlgItemText, hDlg, IDC_CLASS, offset szBufferClass ;按下左ctrl则使之半透明 invoke GetKeyState, VK_LCONTROL shr ax, 15 .if al && !0 invoke GetWindowLong,hWindow,GWL_EXSTYLE or eax,WS_EXD_LAYERED invoke SetWindowLong,hWindow,GWL_EXSTYLE,eax invoke SetLayeredWindowAttributes,hWindow,0,dwAlpha,LWA_ALPHA .endif ret _TimerProc endp DlgProc proc hWnd,uMsg,wParam,lParam .if uMsg==WM_INITDIALOG push hWnd pop hDlg invoke LoadIcon,hInstance,101 invoke SendMessage,hWnd,WM_SETICON,ICON_SMALL,eax invoke SetTimer,hWnd,ID_TIMER1,200d,offset _TimerProc invoke SendDlgItemMessage, hWnd, IDC_TRB1, TBM_SETRANGEMIN, NULL, 0 invoke SendDlgItemMessage, hWnd, IDC_TRB1, TBM_SETRANGEMAX, NULL, 255 invoke SendDlgItemMessage, hWnd, IDC_TRB1, TBM_SETPOS, TRUE, 255 invoke SetDlgItemInt,hWnd,IDC_EDT1,255,0 mov dwAlpha,255 .elseif uMsg == WM_HSCROLL invoke SendDlgItemMessage, hWnd, IDC_TRB1, TBM_GETPOS, NULL, NULL mov dwAlpha,eax invoke SetDlgItemInt,hWnd,IDC_EDT1,dwAlpha,0 .elseif uMsg==WM_COMMAND mov eax,wParam and eax,0ffffh .if eax==IDOK invoke SendMessage,hWnd,WM_COMMAND,IDC_BTN1,0 .elseif eax==IDC_BTN1 invoke MessageBox,hWnd,offset szAboutText,CTXT('关于'),0 .elseif eax==IDC_BTN3 invoke MessageBox,hWnd,offset szHelpText,CTXT('帮助'),0 .elseif eax==IDC_BTN2 invoke EndDialog,hWnd,wParam .elseif eax==IDCANCEL invoke SendMessage,hWnd,WM_CLOSE,0,0 .endif .elseif uMsg==WM_CLOSE invoke EndDialog,hWnd,wParam .else mov eax,FALSE ret .endif mov eax,TRUE ret DlgProc endp END START
[ 本帖最后由 zklhp 于 2010-4-7 14:12 编辑 ]