📄 dlgtable.asm
字号:
;---------------------------------------------------------------------------
;-- Show the popup menu.
invoke ShowContextMenu_TableDialog, hMENU_Options, PT.x, PT.y, hWnd
.ELSEIF ax == IDDI_B_START2
;---------------------------------------------------------------------------
;-- Start/cancel the sorting process.
.IF !SortInfo.fSorting
;-----------------------------------------------------------------------
;-- Start the sorting process.
;-----------------------------------------------------------------------
;-- Set the delay settings to NULL.
mov SortInfo.delay, 0
mov SortInfo.fDelayPosition, 0
;-----------------------------------------------------------------------
;-- Create an initialization value for the random number generator.
invoke GetInitializationValue, hWnd, hTableDialog_CB_InitValue, TRUE
test eax, eax
jz @Return
;-----------------------------------------------------------------------
;-- Get the selected presorting.
invoke SendMessage, hTableDialog_CB_Data, CB_GETCURSEL, NULL, NULL
mov SortInfo.direction, al
;-----------------------------------------------------------------------
;-- Get the number of elements.
invoke GetIntegerFromWindowText, hWnd, hTableDialog_CB_Elements,
lpSTR_ERR_TOMANYELEMENTS,
lpSTR_ERR_INVALIDELEMENTVALUE
jc @Return
;-----------------------------------------------------------------------
;-- Is the value to large?
.IF eax > 1073741824
invoke MessageBox, hWnd, lpSTR_ERR_TOMANYELEMENTS, lpSTR_TITLE_ERROR, MB_OK or MB_ICONHAND
jmp @Return
.ENDIF
;-----------------------------------------------------------------------
;-- No. Save the number of elements.
mov SortInfo.numElements, eax
mov SortInfo.maxValue, 0FFFFFFFEh
mov SortInfo.minValue, 0
;-----------------------------------------------------------------------
;-- Allocate the required amount of memory.
shl eax, 2
invoke SysAllocStringByteLen, NULL, eax
mov SortInfo.lpElements, eax
.IF !eax
;-------------------------------------------------------------------
;-- The memory could not be allocated.
invoke MessageBox, hWnd, lpSTR_ERR_INSUFFICIENTMEMORY, lpSTR_TITLE_ERROR, MB_OK or MB_ICONHAND
jmp @Return
.ENDIF
;-----------------------------------------------------------------------
;-- Start the sorting process.
invoke StartSorting
.ELSE
;-----------------------------------------------------------------------
;-- Terminate the sorting process.
invoke CancelSorting
.ENDIF
.ENDIF
.ENDIF
.ELSEIF (eax == WM_TIMER) || (eax == WM_APP)
;-----------------------------------------------------------------------------------
;-- Show the progress of the sorting process.
;-----------------------------------------------------------------------------------
;-- Convert the comparison counter to a string and show it in the status
;-- bar.
invoke szCopy, lpSTR_SB_COMPARISONS, OFFSET Buffer
invoke StrLen, OFFSET Buffer
add eax, OFFSET Buffer
invoke QW2ASCII, OFFSET SortInfo.cmpCounter, eax
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_CMPCOUNTER, OFFSET Buffer
;-----------------------------------------------------------------------------------
;-- Convert the exchange counter to a string and show it in the status bar.
invoke szCopy, lpSTR_SB_EXCHANGES, OFFSET Buffer
invoke StrLen, OFFSET Buffer
add eax, OFFSET Buffer
invoke QW2ASCII, OFFSET SortInfo.movCounter, eax
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_MOVCOUNTER, OFFSET Buffer
.ELSEIF eax == WM_APP + 1
;-----------------------------------------------------------------------------------
;-- Show a note in the status bar that the elements are generated.
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_CMPCOUNTER, lpSTR_GENERATINGDATA
;-----------------------------------------------------------------------------------
;-- Delete the exchange counter status bar text.
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_MOVCOUNTER, NULL
;-----------------------------------------------------------------------------------
;-- Show the name of the currently processed algorithm in the status bar.
mov eax, wParam
mov eax, DWORD PTR [eax*8 + OFFSET AlgorithmsInfo]
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_ALGORITHM, eax
.ELSEIF eax == WM_APP + 2
;-----------------------------------------------------------------------------------
;-- Delete all status bar texts.
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_ALGORITHM, NULL
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_CMPCOUNTER, NULL
invoke SendMessage, hTableDialog_SB, SB_SETTEXT, SB_PART_MOVCOUNTER, NULL
.ELSEIF eax == WM_CONTEXTMENU
mov eax, wParam
.IF eax == hTableDialog_LV_Result
;-------------------------------------------------------------------------------
;-- Show the context menu of the result list-view.
mov eax, lParam
xor ebx, ebx
mov bx, ax
shr eax, 16
;-------------------------------------------------------------------------------
;-- Convert the mouse coordinates to client coordinates of the result
;-- list-view.
mov LVHTI.pt.x, ebx
mov LVHTI.pt.y, eax
invoke ScreenToClient, hTableDialog_LV_Result, OFFSET LVHTI.pt
;-------------------------------------------------------------------------------
;-- Test whether the mouse is over a list-view item.
invoke SendMessage, hTableDialog_LV_Result, LVM_HITTEST, NULL, OFFSET LVHTI
cmp eax, -1
je @Return
;-------------------------------------------------------------------------------
;-- The mouse is over a list-view item. Is at least one item selected?
invoke SendMessage, hTableDialog_LV_Result, LVM_GETSELECTEDCOUNT, NULL, NULL
test eax, eax
jz @Return
;-------------------------------------------------------------------------------
;-- Yes. Show the popup menu.
mov eax, lParam
xor ebx, ebx
mov bx, ax
shr eax, 16
invoke ShowContextMenu_TableDialog, hMENU_ItemOptions, ebx, eax, hWnd
.ENDIF
.ENDIF
@Return:
xor eax, eax
ret
TableDialogProc ENDP
;-----------------------------------------------------------------------------------------
; The procedure for the algorithm list-view (belongs to the table dialog).
;-----------------------------------------------------------------------------------------
Listview_WndProc PROC hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
mov eax, uMsg
mov ebx, hWnd
.IF ebx == hTableDialog_LV_Algorithms
.IF (eax == WM_LBUTTONDOWN) || (eax == WM_RBUTTONDOWN) || \
(eax == WM_LBUTTONDBLCLK) || (eax == WM_RBUTTONDBLCLK)
;-------------------------------------------------------------------------------
;-- Detect whether the checkbox of an item is checked.
mov eax, lParam
mov edx, eax
shr edx, 16
xor ecx, ecx
mov cx, ax
mov LVHTI.pt.x, ecx
mov LVHTI.pt.y, edx
invoke SendMessage, hWnd, LVM_HITTEST, NULL, OFFSET LVHTI
.IF eax != -1
;---------------------------------------------------------------------------
;-- Get the state of the checkbox.
push eax
invoke SendMessage, hWnd, LVM_GETITEMSTATE, eax, 8192
pop ebx
;---------------------------------------------------------------------------
;-- Invert the state.
mov LVitem.imask, LVIF_STATE
test eax, 8192
.IF !ZERO?
mov LVitem.state, 4096
.ELSE
mov LVitem.state, 8192
.ENDIF
;---------------------------------------------------------------------------
;-- Set the new state of the checkbox.
mov LVitem.stateMask, 8192 or 4096
push ebx
invoke SendMessage, hWnd, LVM_SETITEMSTATE, ebx, OFFSET LVitem
pop eax
;---------------------------------------------------------------------------
;-- Ensure that the last entry is visible.
invoke SendMessage, hWnd, LVM_ENSUREVISIBLE, eax, FALSE
;---------------------------------------------------------------------------
;-- Set the focus to the list view.
invoke SetFocus, hWnd
.ENDIF
.ELSE
jmp @OldWindowProc
.ENDIF
.ELSEIF ebx == hTableDialog_LV_Result
.IF eax == WM_KEYDOWN
invoke GetKeyState, VK_LCONTROL
mov ebx, eax
and bx, 1 SHL 15
.IF !bx
invoke GetKeyState, VK_RCONTROL
mov ebx, eax
and bx, 1 SHL 15
.ENDIF
mov eax, wParam
.IF !ebx && (eax == VK_DELETE)
;---------------------------------------------------------------------------
;-- Delete all selected items.
invoke DeleteSelectedItems, hTableDialog_LV_Result
.ELSEIF ebx && (eax == VK_A)
;---------------------------------------------------------------------------
;-- Select all items.
invoke SendMessage, hTableDialog_LV_Result, LVM_GETITEMCOUNT, NULL, NULL
dec eax
mov LVitem.imask, LVIF_STATE
mov LVitem.state, LVIS_SELECTED
mov LVitem.stateMask, LVIS_SELECTED
@@:
push eax
;-------------------------------------------------------------------------
;-- Select the item.
invoke SendMessage, hTableDialog_LV_Result, LVM_SETITEMSTATE, eax, OFFSET LVitem
pop eax
dec eax
jns @B
.ELSEIF ebx && (eax == VK_C)
;---------------------------------------------------------------------------
;-- Copy all selected items.
invoke CopyItemsToClipboard, IDMI_COPYSELECTED, hTableDialog_LV_Result
.ELSEIF ebx && (eax == VK_X)
;---------------------------------------------------------------------------
;-- Cut all selected items.
invoke CopyItemsToClipboard, IDMI_COPYSELECTED, hTableDialog_LV_Result
invoke DeleteSelectedItems, hTableDialog_LV_Result
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -