本帖最后由 !!!橄榄树 于 2020-3-22 16:05 编辑
三、软件设计步骤
1.插入窗体,窗体名称:精美日历,窗体如下图,插入控件,其中 2020 和 01 是文本框控件, 6个框架控件,其它全是标签控件
2.插入类模块,类模块名称:cLB
3.插入普通模块,模块名称:模块1, 模块代码如下:
Private Declare PtrSafeFunction CallWindowProc Lib "user32" Alias _ "CallWindowProcA" (ByVallpPrevWndFunc As Long, ByVal Hwnd As Long, _ ByVal Msg As Long, ByVal wParam As Long,ByVal lParam As Long) As Long Private Declare PtrSafeFunction SetWindowLong Lib "user32" Alias "SetWindowLongA"_ (ByVal Hwnd As Long, ByVal nIndex AsLong, ByVal dwNewLong As Long) As Long
Private Const GWL_WNDPROC =-4 Private Const WM_MOUSEWHEEL= &H20A '滚动 Global lpPrevWndProcA AsLong Public bMouseFlag As Boolean'鼠标事件激活标志 Public TX, IMG As String,UpDw, Labid, ID, LH, SB, SD As Integer '定义全局变量 Public Sub HookMouse(ByValHwnd As Long) lpPrevWndProcA = SetWindowLong(Hwnd,GWL_WNDPROC, AddressOf WindowProc) End Sub Public Sub UnHookMouse(ByValHwnd As Long) SetWindowLong Hwnd, GWL_WNDPROC,lpPrevWndProcA End Sub Private FunctionWindowProc(ByVal hw As Long, ByVal uMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long)As Long Select Case uMsg Case WM_MOUSEWHEEL '滚动 Dim wzDelta, wKeys As Integer 'wzDelta传递滚动的快慢,该值小于零表示滚轮向后滚动(朝用户方向) '大于零表示滚轮向前滚动(朝显示器方向) wzDelta = HIWORD(wParam) 'wKeys指出是否有CTRL=8、SHIFT=4、鼠标键 '(左=2、中=16、右=2、附加)按下,允许复合 wKeys = LOWORD(wParam) '-------------------------------------------------- If wzDelta < 0 Then '朝用户方向 精美日历.DataDown Else '朝显示器方向 精美日历.DataUp End If '-------------------------------------------------- Case Else WindowProc =CallWindowProc(lpPrevWndProcA, hw, uMsg, wParam, lParam) End Select End Function Private FunctionHIWORD(LongIn As Long) As Integer HIWORD = (LongIn And &HFFFF0000) \&H10000 '取出32位值的高16位 End Function Private FunctionLOWORD(LongIn As Long) As Integer LOWORD = LongIn And &HFFFF& '取出32位值的低16位 End Function
|