WIN32汇编: 19.树型视图控件[4]

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

本文简介:选择自 goddragon 的 blog

           hinst,null
    mov   hwnd,eax
    .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

wndproc proc uses edi hwnd:hwnd, umsg:uint, wparam:wparam, lparam:lparam
    local tvinsert:tv_insertstruct
    local hbitmap:dword
    local tvhit:tv_hittestinfo
    .if umsg==wm_create
        invoke createwindowex,null,addr treeviewclass,null,\
            ws_child+ws_visible+tvs_haslines+tvs_hasbuttons+tvs_linesatroot,0,\
            0,200,400,hwnd,null,\
            hinstance,null            ; create the tree view control
        mov hwndtreeview,eax
        invoke imagelist_create,16,16,ilc_color16,2,10    ; create the associated image list
        mov himagelist,eax
        invoke loadbitmap,hinstance,idb_tree        ; load the bitmap from the resource
        mov hbitmap,eax
        invoke imagelist_add,himagelist,hbitmap,null    ; add the bitmap into the image list
        invoke deleteobject,hbitmap    ; always delete the bitmap resource
        invoke sendmessage,hwndtreeview,tvm_setimagelist,0,himagelist
        mov tvinsert.hparent,null
        mov tvinsert.hinsertafter,tvi_root
        mov tvinsert.item.imask,tvif_text+tvif_image+tvif_selectedimage
        mov tvinsert.item.psztext,offset parent
        mov tvinsert.item.iimage,0
        mov tvinsert.item.iselectedimage,1
        invoke sendmessage,hwndtreeview,tvm_insertitem,0,addr tvinsert
        mov hparent,eax
        mov tvinsert.hparent,eax
        mov tvinsert.hinsertafter,tvi_last
        mov tvinsert.item.psztext,offset child1
        invoke sendmessage,hwndtreeview,tvm_insertitem,0,addr tvinsert
        mov tvinsert.item.psztext,offset child2
        invoke sendmessage,hwndtreeview,tvm_insertitem,0,addr tvinsert
    .elseif umsg==wm_mousemove
        .if dragmode==true
            mov eax,lparam
            and eax,0ffffh
            mov ecx,lparam
            shr ecx,16
            mov tvhit.pt.x,eax
            mov tvhit.pt.y,ecx
            invoke imagelist_dragmove,eax,ecx
            invoke imagelist_dragshownolock,false
            invoke sendmessage,hwndtreeview,tvm_hittest,null,addr tvhit
            .if eax!=null

本文关键:asm
 

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

go top