Уроки Iczelion'а



         

Урок 19. Tree View Control - часть 9


mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL push hInst pop wc.hInstance

mov wc.hbrBackground,COLOR_AppWORKSpACE mov wc.lpszMenuName,NULL 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,WS_EX_CLIENTEDGE,ADDR ClassName,ADDR AppName,\ WS_OVERLAppED+WS_CApTION+WS_SYSMENU+WS_MINIMIZEBOX+\ WS_MAXIMIZEBOX+WS_VISIBLE, \ CW_USEDEFAULT,200,400,NULL,NULL,\ 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 ; Создание tree view

mov hwndTreeView,eax invoke ImageList_Create,16,16,ILC_COLOR16,2,10 ; Создание ; ассоциированного с ним image list'а mov hImageList,eax

invoke LoadBitmaр,hInstance,IDB_TREE ; загрузка bitmaр'а из ресурса mov hBitmap,eax invoke ImageList_Add,hImageList,hBitmap,NULL ; Добавление bitmap'а ; в image list invoke DeleteObject,hBitmap ; всегда удаляйте ненужный bitmap

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




Содержание  Назад  Вперед