📄 calendar.asm
字号:
; ####################################################
; William F. Cravener 5/15/2003
; ####################################################
.486
.model flat,stdcall
option casemap:none ; case sensitive
; ####################################################
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\gdi32.inc
include \masm32\include\comctl32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\comctl32.lib
; ####################################################
DTN_CLOSEUP equ DTN_FIRST + 7
ID_DATETIMEPICKER equ 100
ID_BUTTON equ 300
ID_TIMER equ 400
MAX_XYSTEPS equ 5
DELAY_VALUE equ 15 ; Increase/decrease value to slow down speed up effect.
X_STEP_SIZE equ 100
Y_STEP_SIZE equ 90
X_START_SIZE equ 20
Y_START_SIZE equ 10
LMA_ALPHA equ 2
LMA_COLORKEY equ 1
WS_EX_LAYERED equ 80000h
; ----------------------------------------------------
MonthCalendar PROTO :DWORD,:DWORD,:DWORD,:DWORD
AnimateOpen PROTO :DWORD
AnimateClose PROTO :DWORD
FadeInOpen PROTO :DWORD
FadeOutClose PROTO :DWORD
Paint_Goofy_Eyes PROTO :DWORD
Paint_Goofy_Title PROTO :DWORD
TopXY PROTO :DWORD,:DWORD
; ----------------------------------------------------
.data
hInstance dd ?
libhandle dd ?
vardelay dd 0
counts dd 0
Xplace dd 0
Yplace dd 0
Xsize dd 0
Ysize dd 0
Value dd 0
sWth dd 0
sHth dd 0
pSLWA dd ?
bitmapflag dd 0
DatePicker db "The date you picked is:",0
DateString db 20 dup (0)
dlgname db "Calendar",0
User32 db "User32.dll",0
SLWA db "SetLayeredWindowAttributes",0
lib_name db "\comctl32.dll",0
d_buffer db MAX_PATH + 1 dup (?)
; --------------------------------------------------------------------------
.data?
VerInfo OSVERSIONINFO <> ;structure for OS version info
icex INITCOMMONCONTROLSEX <> ;structure for Calender and Date Picker
; --------------------------------------------------------------------------
.code
start:
; ###############################################################
invoke GetModuleHandle,NULL
mov hInstance,eax
; ------------------------------------------------------
; The Month Calendar control and Date Picker control are
; implemented in version 4.70 and later of Comctl32.dll.
; ------------------------------------------------------
mov icex.dwSize,sizeof INITCOMMONCONTROLSEX
mov icex.dwICC,ICC_DATE_CLASSES
invoke InitCommonControlsEx,ADDR icex
; -------------------------------------------
; Call the dialog box stored in resource file
; -------------------------------------------
invoke DialogBoxParam,hInstance,ADDR dlgname,0,ADDR MonthCalendar,0
invoke ExitProcess,0
; ###############################################################
MonthCalendar proc hWin:DWORD,uMsg:DWORD,aParam:DWORD,bParam:DWORD
LOCAL Ps:PAINTSTRUCT
.if uMsg == WM_INITDIALOG
mov VerInfo.dwOSVersionInfoSize,sizeof OSVERSIONINFO
invoke GetVersionEx,ADDR VerInfo
.if VerInfo.dwMajorVersion >= 5 ; Win2000 or XP ?
invoke FadeInOpen,hWin
.else
invoke AnimateOpen,hWin
.endif
invoke SetTimer,hWin,ID_TIMER,5000,0
invoke SetFocus,hWin
.elseif uMsg == WM_COMMAND
mov eax,aParam
.if eax == ID_BUTTON
invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
.endif
.elseif uMsg == WM_NOTIFY
mov eax,bParam
mov eax,(NMHDR PTR [eax]).code
.if eax == DTN_CLOSEUP
mov eax,aParam
.if eax == ID_DATETIMEPICKER
invoke GetDlgItemText,hWin,ID_DATETIMEPICKER,ADDR DateString,20
invoke MessageBox,hWin,ADDR DateString,ADDR DatePicker,MB_OK
.endif
.endif
.elseif uMsg == WM_PAINT
invoke BeginPaint,hWin,ADDR Ps
invoke Paint_Goofy_Eyes,hWin
invoke Paint_Goofy_Title,hWin
invoke EndPaint,hWin,ADDR Ps
.elseif uMsg == WM_CLOSE
.if VerInfo.dwMajorVersion >= 5 ; Win2000 or XP ?
invoke FadeOutClose,hWin
.else
invoke AnimateClose,hWin
.endif
invoke KillTimer,hWin,ID_TIMER
invoke EndDialog,hWin,NULL
.elseif uMsg == WM_TIMER
mov bitmapflag,1
invoke Paint_Goofy_Eyes,hWin
invoke Sleep,200
mov bitmapflag,0
invoke Paint_Goofy_Eyes,hWin
.endif
xor eax,eax
ret
MonthCalendar endp
; ###############################################################
AnimateOpen proc hWin:DWORD
LOCAL Rct:RECT
;-----------------------------------------------------------
; This is a simple method to animate the opening of a dialog
; box by making the dialog appear to be expanding outward.
;-----------------------------------------------------------
invoke GetWindowRect,hWin,ADDR Rct
mov Xsize,X_START_SIZE
mov Ysize,Y_START_SIZE
invoke GetSystemMetrics,SM_CXSCREEN
mov sWth,eax
invoke TopXY,Xsize,eax
mov Xplace,eax
invoke GetSystemMetrics,SM_CYSCREEN
mov sHth,eax
invoke TopXY,Ysize,eax
mov Yplace,eax
mov counts,MAX_XYSTEPS
aniloop:
invoke MoveWindow,hWin,Xplace,Yplace,Xsize,Ysize,FALSE
invoke ShowWindow,hWin,SW_SHOWNA
invoke Sleep,DELAY_VALUE
invoke ShowWindow,hWin,SW_HIDE
add Xsize,X_STEP_SIZE
add Ysize,Y_STEP_SIZE
invoke TopXY,Xsize,sWth
mov Xplace,eax
invoke TopXY,Ysize,sHth
mov Yplace,eax
dec counts
jnz aniloop
mov eax,Rct.left
mov ecx,Rct.right
sub ecx,eax
mov Xsize,ecx
mov eax,Rct.top
mov ecx,Rct.bottom
sub ecx,eax
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -