2007年5月14日月曜日

ツリービュー

ツリービューを作成する。


#include "comctl32.as"
#include "user32.as"

#define global TVM_INSERTITEM    0x1100
#module
#deffunc makeTree int _width, int _height
    initCCEx = 8, 0x00000002
    InitCommonControlsEx varptr(initCCEx)
    style = 0x40000000 | 0x10000000 | 0x0001 | 0x0002 | 0x0200
    CreateWindowEx 0, "SysTreeView32", "", style, ginfo_cx, ginfo_cy, _width, _height, hWnd, 0, 0, 0
    hTree = stat
    return hTree

#deffunc addTree str text, int hParent
    dim tvins, 12
    bufText = text
    hIns = 0xFFFF0002                   // TVI_LAST
    tvins = hParent, hIns, 0x0001       // 親アイテムのハンドル、挿入位置のアイテムハンドル、TVIF_TEXT
    tvins(6) = varptr(bufText), strlen(bufText)
    sendmsg hTree, TVM_INSERTITEM, 0, varptr(tvins)
    return stat
#global

    boxf
    makeTree 240, 480
    addTree "sample1", 0
    addTree "sample1の子供", stat
    addTree "sample2", 0
    addTree "sample2の子供", stat
    addTree "sample2の孫", stat
    stop

0 件のコメント: