iczelion tut31[4]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

appname db "testing a listview control",0
listviewclassname db "syslistview32",0
heading1 db "filename",0
heading2 db "size",0
filenamepattern db "*.*",0
filenamesortorder dd 0
sizesortorder dd 0
template db "%lu",0

.data?
hinstance hinstance ?
hlist dd ?
hmenu dd ?

.code
start:
  invoke getmodulehandle, null
  mov hinstance,eax
  invoke winmain, hinstance,null, null, sw_showdefault
  invoke exitprocess,eax
  invoke initcommoncontrols
winmain proc hinst:hinstance,hprevinst:hinstance,cmdline:lpstr,cmdshow:dword
  local wc:wndclassex
  local msg:msg
  local hwnd:hwnd

  mov wc.cbsize,sizeof wndclassex
  mov wc.style, null
  mov wc.lpfnwndproc, offset wndproc
  mov wc.cbclsextra,null
  mov wc.cbwndextra,null
  push hinstance
  pop wc.hinstance
  mov wc.hbrbackground,color_window+1
  mov wc.lpszmenuname,idm_mainmenu
  mov wc.lpszclassname,offset classname
  invoke loadicon,null,idi_application
  mov wc.hicon,eax
  mov wc.hiconsm,eax
  invoke loadcursor,null,idc_arrow
  mov wc.hcursor,eax
  invoke registerclassex, addr wc
  invoke createwindowex,null,addr classname,addr appname, ws_overlappedwindow,cw_usedefault, cw_usedefault, cw_usedefault, cw_usedefault, null, null, hinst,null
  mov hwnd,eax
  invoke showwindow, hwnd,sw_shownormal
  invoke updatewindow, hwnd
  .while true
    invoke getmessage, addr msg,null,0,0
    .break .if (!eax)
      invoke translatemessage, addr msg
      invoke dispatchmessage, addr msg
  .endw
  mov eax,msg.wparam
  ret
winmain endp

insertcolumn proc
  local lvc:lv_column

  mov lvc.imask,lvcf_text+lvcf_width
  mov lvc.psztext,offset heading1
  mov lvc.lx,150
  invoke sendmessage,hlist, lvm_insertcolumn, 0, addr lvc
  or lvc.imask,lvcf_fmt
  mov lvc.fmt,lvcfmt_right
  mov lvc.psztext,offset heading2
  mov lvc.lx,100
  invoke sendmessage,hlist, lvm_insertcolumn, 1 ,addr lvc
  ret
insertcolumn endp

showfileinfo proc uses edi row:dword, lpfind:dword
  local lvi:lv_item
  local buffer[20]:byte
  mov edi,lpfind
  assume edi:ptr win32_find_data
  mov lvi.imask,lvif_text+lvif_param
  push row
  pop lvi.iitem
  mov lvi.isubitem,0
  lea eax,[edi].cfilename
  mov lvi.psztext,eax
  push row
  pop lvi.lparam
  invoke sendmessage,hlist, lvm_insertitem,0, addr lvi
  mov lvi.imask,lvif_text
  inc lvi.isubitem
  invoke wsprintf,addr buffer, addr template,[edi].nfilesizelow
  lea eax,buffer
  mov lvi.psztext,eax
  invoke sendmessage,hlist,lvm_setitem, 0,addr lvi
  assume edi:nothing
  ret
showfileinfo endp

fillfileinfo proc uses edi
  local finddata:win32_find_data
  local fhandle:dword

  invoke findfirstfile,addr filenamepattern,addr finddata
  .if eax!=invalid_handle_value
    mov fhandle,eax
    xor edi,edi
    .while eax!=0
      test finddata.dwfileattributes,file_attribute_directory
      .if zero?
         invoke showfileinfo,edi, addr finddata
         inc edi
      .endif
      invoke findnextfile,fhandle,addr finddata
    .endw
    invoke findclose,fhandle
  .endif
  ret
fillfileinfo endp

string2dword proc uses ecx edi edx esi string:dword
  local result:dword

  mov result,0
  mov edi,string
  invoke lstrlen,string
  .while eax!=0
    xor edx,edx
    mov dl,byte ptr [edi]
    sub dl,"0"
    mov esi,eax
    dec esi
    push eax
    mov eax,edx
    push ebx
    mov ebx,10
    .while esi > 0
      mul ebx
      dec esi
    .endw
    pop ebx
    add result,eax
    pop eax
    inc edi
    dec eax
  .endw

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top