📄 treedemo.asm
字号:
sub eax, rect.top ; eax = height of statusbar
push eax
INVOKE GetClientRect, hWnd, addr rect
pop eax
dec eax
sub rect.bottom, eax
mov ecx, Split2
mov edx, Split1[4]
mov Split1[8], ecx
INVOKE MoveWindow, hWndTree, 1, 1, ecx, edx, TRUE
mov edx, rect.bottom
mov ecx, Split1[12]
mov edi, ecx
dec ecx
sub edx, ecx
sub edx, 2
mov ecx, Split2
INVOKE MoveWindow, hWndList, 1, edi, ecx, edx, TRUE
mov ecx, Split2
sub ecx, 4
INVOKE SendMessage, hWndList, LVM_SETCOLUMNWIDTH, 0, ecx
mov ecx, rect.right
inc Split1[8]
sub ecx, Split1[8]
mov edx, rect.bottom
mov Split2[12], edx
mov edi, Split2[8]
dec ecx
sub edx, 2
INVOKE MoveWindow, hREdit, edi, 1, ecx, edx, TRUE
.elseif wMsg == WM_NOTIFY
.if wParam == 44 ; Treeview
mov eax, lParam
mov ebx, (NM_TREEVIEW ptr [eax]).hdr.code
mov ecx, (NM_TREEVIEW ptr [eax]).itemNew.hItem
.if ebx == TVN_ITEMEXPANDING
mov edx, (NM_TREEVIEW ptr [eax]).action
.if edx == TVE_COLLAPSE
;DSPValue hWnd, edx, 1, 't'
mov First, 1
INVOKE SendMessage, hWndTree, TVM_SELECTITEM, TVGN_CARET, NULL
.endif
jmp Ret0
.endif
.if ebx == TVN_SELCHANGED
.if ecx == hParent && First
and First, 0
push ecx
push eax
INVOKE SendMessage, hWndTree, TVM_SELECTITEM, TVGN_CARET, NULL
pop eax
pop ecx
.endif
test (NM_TREEVIEW ptr [eax]).action, TVIS_FOCUSED
jz Ret0
mov tvi.hItem, ecx
mov tvi.imask, TVIF_TEXT
lea eax, szWork1
mov tvi.pszText, eax
mov tvi.cchTextMax, 64
.if ecx == hChild6 ; Clear all
INVOKE SendMessage, hWndList, LVM_DELETEALLITEMS, 0, 0
INVOKE SendMessage, hREdit, WM_SETTEXT, 0, addr szNull
INVOKE SendMessage, hWndStat, SB_SETTEXT, 0, addr szNull
INVOKE SendMessage, hWndStat, SB_SETTEXT, 1, addr szNull
INVOKE SendMessage, hWndStat, SB_SETTEXT, 2, addr szNull
INVOKE SendMessage, hWndStat, SB_SETTEXT, 3, addr szNull
jmp Ret0
.endif
push ecx
INVOKE SendMessage, hWndTree, TVM_GETITEM, NULL, addr tvi
INVOKE SendMessage, hWndStat, SB_SETTEXT, 0, addr szWork1
pop ecx
.if ecx == hChild1 ; Listview
INVOKE SendMessage, hWndList, LVM_DELETEALLITEMS, 0, 0
;---------- [Fill the Listview] ----------
mov lvi.imask, LVIF_TEXT or LVIF_PARAM
mov lvi.iItem, 0
mov lvi.lParam, 0
mov lvi.iSubItem, 0
lea eax, szItem1
mov lvi.pszText, eax
mov lvi.iImage, 0
INVOKE SendMessage, hWndList, LVM_INSERTITEM, 0, addr lvi
mov lvi.iItem, 1
mov lvi.lParam, 1
mov lvi.iSubItem, 0
lea eax, szItem2
mov lvi.pszText, eax
mov lvi.iImage, 0
INVOKE SendMessage, hWndList, LVM_INSERTITEM, 0, addr lvi
.elseif ecx == hChild2 ; Edit control
INVOKE SendMessage, hREdit, WM_SETTEXT, 0, addr szDay
.elseif ecx == hChild4 ; Stat 2
INVOKE SendMessage, hWndStat, SB_SETTEXT, 2, addr Child4
.elseif ecx == hChild5 ; Stat 3
INVOKE SendMessage, hWndStat, SB_SETTEXT, 3, addr Child5
.endif
.endif
.elseif wParam == 45 ; Listview
mov ebx, lParam ; Get pointer to NMHDR
.if [ebx.NMHDR].code == NM_CLICK ;NM_DBLCLK
INVOKE SendMessage, hWndList, LVM_GETNEXTITEM, -1, LVNI_FOCUSED
mov lvi.iItem, eax
mov lvi.iSubItem, 0
mov lvi.imask, LVIF_TEXT
lea eax, szWork1
mov lvi.pszText, eax
mov lvi.cchTextMax, 64
INVOKE SendMessage, hWndList, LVM_GETITEM, 0, addr lvi
INVOKE SendMessage, hWndStat, SB_SETTEXT, 1, addr szWork1
.endif
.endif
;---------- [System and user commands] ----------
.elseif wMsg == WM_COMMAND
mov eax, wParam
cwde ; Only low word contains command
.if eax == IDM_EXIT
INVOKE SendMessage, hwnd, WM_CLOSE, 0 ,0
.endif
;---------- [Move the splitter bars] ----------
.elseif wMsg == WM_MOUSEMOVE
;---------- [Capture the mouse if within an area] ----------
INVOKE GetClientRect, hWnd, addr rect
mov eax, lParam
mov edx, eax
and eax, 0ffffh
inc eax
mov xPos, eax
shr edx, 16
inc edx
mov yPos, edx
.if eax > Split1 && eax < Split1[8] && edx >= Split1[4] && edx <= Split1[12] && BarType != 2
INVOKE LoadCursor, hInst, 899
INVOKE SetCursor, eax
INVOKE SetCapture, hwnd
mov BarType, 1
.elseif eax >= Split2 && eax <= Split2[8] && edx > Split2[4] && edx < Split2[12] && BarType != 1
INVOKE LoadCursor, hInst, 898
INVOKE SetCursor, eax
INVOKE SetCapture, hwnd
mov BarType, 2
.else
;---------- [Release the mouse if out of the area] ----------
.if wParam != MK_LBUTTON
xor esi, esi
.if BarType == 1
lea esi, Split1
.elseif BarType == 2
lea esi, Split2
.endif
.if esi
.if eax < [esi] || eax > [esi+8] || edx < [esi+4] || edx > [esi+12]
and BarType, 0
INVOKE ReleaseCapture
.endif
.endif
.endif
INVOKE LoadCursor, 0, IDC_ARROW
INVOKE SetCursor, eax
.endif
.if wParam == MK_LBUTTON
INVOKE GetClientRect, hWnd, addr rect
mov ecx, xPos
mov edx, yPos
sub rect.bottom, 28
.if ecx > rect.left && ecx < rect.right && edx > rect.top && edx < rect.bottom
.else
jmp Ret0
.endif
;---------- [Create and drag the Splitter bar] ----------
.if BarType == 1 ; Horizontal
mov ecx, Split2
.if xPos < ecx
INVOKE LoadCursor, hInst, 899
INVOKE SetCursor, eax
.if !hSplitBar
INVOKE CreateDialogParam, hInst, 4801, hWnd, offset SplitBarProc, 0
.endif
mov eax, yPos
dec eax
dec eax
mov Split1[4], eax
add eax, 2
mov Split1[12], eax
INVOKE GetWindowRect, hWnd, addr rect
add rect.left, 6
mov eax, rect.top
add eax, 44
add eax, Split1[4]
inc eax
mov rect.top, eax
mov edx, Split1[8]
INVOKE MoveWindow, hSplitBar, rect.left, rect.top, edx, 2, 1
.endif
.endif
.if BarType == 2 ; Vertical
INVOKE LoadCursor, hInst, 898
INVOKE SetCursor, eax
.if !hSplitBar
INVOKE CreateDialogParam, hInst, 4801, hWnd, offset SplitBarProc, 0
.endif
mov eax, xPos
dec eax
dec eax
mov Split2, eax
add eax, 2
mov Split2[8], eax
INVOKE GetWindowRect, hWnd, addr rect
add rect.top, 44
mov eax, rect.top
add eax, 28
sub rect.bottom, eax
add rect.left, 6
mov ecx, rect.left
add ecx, Split2
inc ecx
INVOKE MoveWindow, hSplitBar, ecx, rect.top, 2, Split2[12], 1
.endif
.endif
.elseif wMsg == WM_LBUTTONUP
;---------- [Restore the cursor and call WM_SIZE] ----------
INVOKE LoadCursor, 0, IDC_ARROW
INVOKE SetCursor, eax
and BarType, 0
.if hSplitBar
INVOKE ReleaseCapture
INVOKE SplitBarProc, hSplitBar, WM_COMMAND, IDCANCEL, 0
and hSplitBar, 0
INVOKE GetClientRect, hWnd, addr rect
mov edx, rect.bottom
shl edx, 16
mov ecx, rect.right
mov dx, cx
INVOKE SendMessage, hWnd, WM_SIZE, 0, edx
.endif
.elseif wMsg == WM_CLOSE
INVOKE DestroyWindow, hwnd
.elseif wMsg == WM_DESTROY
INVOKE PostQuitMessage, NULL
.else
DefWin:
INVOKE DefWindowProc, hwnd, wMsg, wParam, lParam
ret
.endif
Ret0:
xor eax, eax
ret
WndProc endp
;=========================================================================
; Splitter Bar PROCEDURE
;=========================================================================
SplitBarProc PROC hdlg:DWORD, wmsg, wparam, lparam
LOCAL hBrush:DWORD
cmp wmsg, WM_INITDIALOG ; If message is INITDIALOG then
jne NotInit ; check wmsg
mov eax, hdlg
mov hSplitBar, eax
jmp DlgDone
NotInit:
cmp wmsg, WM_CTLCOLORDLG
je ColorDlg
cmp wmsg, WM_COMMAND ; Is message a WM_COMMAND?
mov eax, wparam ; Otherwise, see if it's OK or CANCEL
cmp eax, IDCANCEL ; that was pressed
je CancleIt ; and if not either of these
jmp DlgDone
ColorDlg:
INVOKE CreateSolidBrush, 0000ff00h
mov hBrush, eax
ret
CancleIt:
INVOKE DeleteObject, hBrush
INVOKE EndDialog, hdlg, wparam
mov eax, TRUE ; Return
jmp DlgRet ; with TRUE
DlgDone:
mov eax, FALSE ; Return with FALSE
DlgRet:
ret ; Return
SplitBarProc ENDP
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -