转个非虫老大发的实现 Windows Vista 按钮控件增强功能 的程序
;参考:http://msdn. Windows Vista 控件增强功能.386
.model flat, stdcall ;32 bit memory model
option casemap :none ;case sensitive
include VistaStyle.inc
include macros.asm
include rsrc.inc
include Strings.mac
DlgProc PROTO :HWND,:UINT,:WPARAM,:LPARAM
.data?
hInstance dd ?
hCommandLink1 dd ?
hCommandLink2 dd ?
.code
;******************* 对话框回调函数 ***********************************************************
DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL @hMenu:HMENU
LOCAL @pt:POINT
LOCAL @rect:RECT
mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem,hWnd,IDC_BTN1
mov hCommandLink1,eax
invoke SetWindowText,hCommandLink1,CTXT("bs_commandline")
invoke SendMessage,hCommandLink1,BCM_SETNOTE,0,$CTW0("note1")
invoke GetDlgItem,hWnd,IDC_BTN2
mov hCommandLink2,eax
invoke SetWindowText,hCommandLink2,CTXT("bs_defcommandline")
invoke SendMessage,hCommandLink2,BCM_SETNOTE,0,$CTW0("note2")
invoke SendMessage,hCommandLink2,BCM_SETSHIELD,0,TRUE
invoke SetDlgItemText,hWnd,IDC_BTN3,CTXT("bs_splitbutton")
invoke SetDlgItemText,hWnd,IDC_BTN4,CTXT("bs_defsplitbutton")
.elseif eax == WM_NOTIFY
mov edi,lParam
assume edi:ptr NMHDR
.if [edi].code == BCN_DROPDOWN
mov eax,wParam
.if eax == IDC_BTN3
invoke CreatePopupMenu
mov @hMenu,eax
invoke AppendMenu,@hMenu,MF_STRING,200,CTXT("关于本程序")
invoke AppendMenu,@hMenu,MF_SEPARATOR,0,NULL
invoke AppendMenu,@hMenu,MF_STRING,201,CTXT("退出")
invoke GetDlgItem,hWnd,IDC_BTN3
mov ebx,eax
invoke GetWindowRect,ebx,addr @rect
mov eax,@rect.left
mov @pt.x,eax
mov eax,@rect.bottom
mov @pt.y,eax
; invoke ClientToScreen,hWnd,addr @pt
invoke TrackPopupMenu,@hMenu,TPM_LEFTALIGN,@pt.x,@pt.y,0,hWnd,NULL
invoke DestroyMenu,@hMenu
.else
invoke CreatePopupMenu
mov @hMenu,eax
invoke AppendMenu,@hMenu,MF_STRING,201,CTXT("退出")
invoke GetDlgItem,hWnd,IDC_BTN4
mov ebx,eax
invoke GetWindowRect,ebx,addr @rect
mov eax,@rect.left
mov @pt.x,eax
mov eax,@rect.bottom
mov @pt.y,eax
; invoke ClientToScreen,hWnd,addr @pt
invoke TrackPopupMenu,@hMenu,TPM_LEFTALIGN,@pt.x,@pt.y,0,hWnd,NULL
invoke DestroyMenu,@hMenu
.endif
.endif
.elseif eax==WM_COMMAND
mov eax,wParam
movzx eax,ax
.if eax == 200
invoke MessageBox,hWnd,CTXT("vista 新样式按钮演示程序",),NULL,MB_OK
.elseif eax == 201
invoke SendMessage,hWnd,WM_CLOSE,0,0
.elseif eax == IDC_BTN1
invoke MessageBox,hWnd,CTXT("bs_commandline"),NULL,MB_OK
.elseif eax == IDC_BTN2
invoke MessageBox,hWnd,CTXT("bs_defcommandline"),NULL,MB_OK
.elseif eax == IDC_BTN3
invoke MessageBox,hWnd,CTXT("bs_splitbutton"),NULL,MB_OK
.elseif eax == IDC_BTN4
invoke MessageBox,hWnd,CTXT("bs_defsplitbutton"),NULL,MB_OK
.endif
.elseif eax==WM_CLOSE
invoke EndDialog,hWnd,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
DlgProc endp
;******************* 程序从这里开始执行 ***********************************************************
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DLG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0
end start
[[it] 本帖最后由 zklhp 于 2009-8-5 12:35 编辑 [/it]]