⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copyitems.asm

📁 一个演示了用汇编语言编写的数据排序算法,源代码非常详细
💻 ASM
📖 第 1 页 / 共 2 页
字号:
        cmp    ecx, ItemCount
        jb     @B

  .ELSE

      ;-----------------------------------------------------------------------------------
      ;-- Copy the selected items.

    @@:
        ;---------------------------------------------------------------------------------
        ;-- Get the state of the current item.
        push   ecx
        push   edx
          invoke SendMessage, hTableDialog_LV_Result, LVM_GETITEMSTATE, ecx, LVIS_SELECTED
        pop    edx
        pop    ecx


        ;---------------------------------------------------------------------------------
        ;-- Is it selected?
        test   eax, eax
        .IF !ZERO?

            ;-----------------------------------------------------------------------------
            ;-- Yes. Append the item informations to the buffer.
            push   ecx
            push   edx
              invoke CopyItemToBuffer, ecx, edx, ADDR colArray
            pop    edx
            pop    ecx


            ;-----------------------------------------------------------------------------
            ;-- Add the length of the last string to the offset of the buffer.
            dec    eax
            add    edx, eax

        .ENDIF


        ;---------------------------------------------------------------------------------
        ;-- If not all items have been processed check the next one.
        inc    ecx
        cmp    ecx, ItemCount
        jb     @B

  .ENDIF


  ;---------------------------------------------------------------------------------------
  ;-- No error occured, the buffer is filled with the requested informations.
  mov    eax, hMem_Buffer


@Return:
  .IF !eax && hMem_Buffer

      ;-----------------------------------------------------------------------------------
      ;-- Free the allocated memory.
      invoke GlobalFree, hMem_Buffer
      xor    eax, eax

  .ENDIF

  ret
CopyItemsToBuffer ENDP



;-----------------------------------------------------------------------------------------
; Purpose:     Copies all or the selected items of the result list view in the clipboard.
;
; Inputs:      IDMI - identifier of the selected menu item
;              hWnd - owner window
;
; Outputs:     Places all or the selected entries to the clipboard.
;
; Notes:       The identifier has to be equal to the one used in the resource file.
;-----------------------------------------------------------------------------------------

CopyItemsToClipboard PROC IDMI:DWORD, hWnd:DWORD

  ;---------------------------------------------------------------------------------------
  ;-- Open the clipboard.
  invoke CloseClipboard
  invoke OpenClipboard, hWnd


  ;---------------------------------------------------------------------------------------
  ;-- If an error occured return.
  test   eax, eax
  jz     @Return


    ;-------------------------------------------------------------------------------------
    ;-- Fill the buffer with the requested informations.
    xor    eax, eax
    .IF IDMI == IDMI_COPYALL

        ;---------------------------------------------------------------------------------
        ;-- If all items shall be copied the argument has to be -1, otherwise 0.
        dec    eax

    .ENDIF

    invoke CopyItemsToBuffer, eax


    .IF eax

        ;---------------------------------------------------------------------------------
        ;-- If no error occured, empty the clipboard data.
        push   eax
          invoke EmptyClipboard
        pop    eax


        ;---------------------------------------------------------------------------------
        ;-- Place the content of the buffer on the clipboard in text format. 
        invoke SetClipboardData, CF_TEXT, eax

    .ENDIF


  ;---------------------------------------------------------------------------------------
  ;-- Close the clipboard.
  invoke CloseClipboard


@Return:
  ret
CopyItemsToClipboard ENDP


;-----------------------------------------------------------------------------------------
; Purpose:     Copies the title of all visible columns of the result list view in a
;              buffer.
;
; Inputs:      lpBuffer - offset of the buffer
;              lpColArray - offset of an array containing informations about the columns
;
; Outputs:     EAX - the number of bytes copied
;
; Notes:       none
;-----------------------------------------------------------------------------------------

CopyHeadersToBuffer PROC lpBuffer:DWORD, lpColArray:DWORD

  ;---------------------------------------------------------------------------------------
  ;-- Copy the text of each visible column to the buffer.
  mov    ebx, lpColArray
  mov    ecx, -1

  mov    edx, lpBuffer
@Loop1:

    ;-------------------------------------------------------------------------------------
    ;-- If all columns have been processed return.
    inc    ecx
    cmp    ecx, LVResult_ColCount
    jnb    @Return


    ;-------------------------------------------------------------------------------------
    ;-- Get the ID of the current column (ECX).
    mov    eax, DWORD PTR [ecx*4 + ebx]


    ;-------------------------------------------------------------------------------------
    ;-- If this column is not visible process the next column.
    cmp    eax, -1
    je     @Loop1


    ;-------------------------------------------------------------------------------------
    ;-- Get the offset of the column text.
    lea    eax, [eax*2 + eax]
    mov    eax, DWORD PTR [eax*4 + OFFSET LVResultInfo + 4]
    mov    eax, DWORD PTR [eax]

    push   ecx
    push   edx
    push   eax

      ;-----------------------------------------------------------------------------------
      ;-- Copy the string to the buffer.
      invoke szCopy, eax, edx

    pop    eax

      ;-----------------------------------------------------------------------------------
      ;-- Get the length of the copied string.
      invoke szLen, eax

    pop    edx
    pop    ecx


    ;-------------------------------------------------------------------------------------
    ;-- Add the lenght of the string to the offset fo teh buffer.
    add    edx, eax


    ;-------------------------------------------------------------------------------------
    ;-- Append the separating char.
    mov    al, SeparatingChar
    mov    BYTE PTR [edx], al
    inc    edx


    ;-------------------------------------------------------------------------------------
    ;-- Process the next column.
    jmp    @Loop1


@Return:
  mov    eax, lpBuffer
  .IF eax != edx
      dec    edx
  .ENDIF


  ;---------------------------------------------------------------------------------------
  ;-- Append CR+LF to the end of the buffer.
  mov    WORD PTR [edx], 0A0Dh
  mov    BYTE PTR [edx + 2], NULL


  ;-------------------------------------------------------------------------------------
  ;-- Return the length of the copied string in EAX.
  sub    eax, 3
  sub    edx, eax
  mov    eax, edx

  ret
CopyHeadersToBuffer ENDP



;-----------------------------------------------------------------------------------------
; Purpose:     Copies the texts of an item of the result list view in a buffer.
;
; Inputs:      item - item index
;              lpBuffer - offset of the buffer
;              lpColArray - offset of an array containing informations about the columns
;
; Outputs:     EAX - the number of bytes copied
;
; Notes:       none
;-----------------------------------------------------------------------------------------

CopyItemToBuffer PROC item:DWORD, lpBuffer:DWORD, lpColArray:DWORD

  ;---------------------------------------------------------------------------------------
  ;-- Copy the item texts of each visible column to the buffer.
  mov    ebx, lpColArray
  mov    ecx, -1

  mov    edx, lpBuffer

@Loop1:

    ;-------------------------------------------------------------------------------------
    ;-- If all columns have been processed return.
    inc    ecx
    cmp    ecx, LVResult_ColCount
    jnb    @Return


    ;-------------------------------------------------------------------------------------
    ;-- Get the ID of the current column (ECX).
    mov    eax, DWORD PTR [ecx*4 + ebx]


    ;-------------------------------------------------------------------------------------
    ;-- If this column is not visible process the next column.
    cmp    eax, -1
    je     @Loop1

    ;-------------------------------------------------------------------------------------
    ;-- Get the offset of the column text.
    push   ebx
    push   ecx
    push   edx

      mov    ebx, item
      mov    LVitem.iItem, ebx
      mov    LVitem.iSubItem, eax
      mov    LVitem.pszText, edx

      mov    eax, lpBuffer
      add    eax, 512
      sub    eax, edx
      mov    LVitem.cchTextMax, eax

      invoke SendMessage, hTableDialog_LV_Result, LVM_GETITEMTEXT, ebx, OFFSET LVitem

    pop    edx
    pop    ecx
    pop    ebx


    ;-------------------------------------------------------------------------------------
    ;-- Add the length of the string to the offset of the buffer.
    add    edx, eax


    ;-------------------------------------------------------------------------------------
    ;-- Append the separating char.
    mov    al, SeparatingChar
    mov    BYTE PTR [edx], al
    inc    edx


    ;-------------------------------------------------------------------------------------
    ;-- Process the next column.
    jmp    @Loop1


@Return:
  mov    eax, lpBuffer
  .IF eax != edx
      dec    edx
  .ENDIF


  ;---------------------------------------------------------------------------------------
  ;-- Append CR+LF to the end of the buffer.
  mov    WORD PTR [edx], 0A0Dh
  mov    BYTE PTR [edx + 2], NULL


  ;-------------------------------------------------------------------------------------
  ;-- Return the length of the copied string in EAX.
  sub    eax, 3
  sub    edx, eax
  mov    eax, edx

  ret
CopyItemToBuffer ENDP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -